qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 2178a5: nbd/server: Fix blockstatus trace


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 2178a5: nbd/server: Fix blockstatus trace
Date: Tue, 09 Apr 2019 01:56:36 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 2178a569be16b18f04ed854d24fd2281b6a429c5
      
https://github.com/qemu/qemu/commit/2178a569be16b18f04ed854d24fd2281b6a429c5
  Author: Eric Blake <address@hidden>
  Date:   2019-04-08 (Mon, 08 Apr 2019)

  Changed paths:
    M nbd/server.c

  Log Message:
  -----------
  nbd/server: Fix blockstatus trace

Don't increment remaining_bytes until we know that we will actually be
including the current block status extent in the reply; otherwise, the
value traced will include a bytes value that is oversized by the
length of the next block status extent which did not get sent because
it instead ended the loop.

Fixes: fb7afc79
Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>


  Commit: 6e280648d21d8c0aa8a101b62d0732cd1e608743
      
https://github.com/qemu/qemu/commit/6e280648d21d8c0aa8a101b62d0732cd1e608743
  Author: Eric Blake <address@hidden>
  Date:   2019-04-08 (Mon, 08 Apr 2019)

  Changed paths:
    M nbd/server.c
    M nbd/trace-events

  Log Message:
  -----------
  nbd/server: Trace client noncompliance on unaligned requests

We've recently added traces for clients to flag server non-compliance;
let's do the same for servers to flag client non-compliance. According
to the spec, if the client requests NBD_INFO_BLOCK_SIZE, it is
promising to send all requests aligned to those boundaries.  Of
course, if the client does not request NBD_INFO_BLOCK_SIZE, then it
made no promises so we shouldn't flag anything; and because we are
willing to handle clients that made no promises (the spec allows us to
use NBD_REP_ERR_BLOCK_SIZE_REQD if we had been unwilling), we already
have to handle unaligned requests (which the block layer already does
on our behalf).  So even though the spec allows us to return EINVAL
for clients that promised to behave, it's easier to always answer
unaligned requests.  Still, flagging non-compliance can be useful in
debugging a client that is trying to be maximally portable.

Qemu as client used to have one spot where it sent non-compliant
requests: if the server sends an unaligned reply to
NBD_CMD_BLOCK_STATUS, and the client was iterating over the entire
disk, the next request would start at that unaligned point; this was
fixed in commit a39286dd when the client was taught to work around
server non-compliance; but is equally fixed if the server is patched
to not send unaligned replies in the first place (yes, qemu 4.0 as
server still has few such bugs, although they will be patched in
4.1). Fortunately, I did not find any more spots where qemu as client
was non-compliant. I was able to test the patch by using the following
hack to convince qemu-io to run various unaligned commands, coupled
with serving 512-byte alignment by intentionally omitting '-f raw' on
the server while viewing server traces.

| diff --git i/nbd/client.c w/nbd/client.c
| index 427980bdd22..1858b2aac35 100644
| --- i/nbd/client.c
| +++ w/nbd/client.c
| @@ -449,6 +449,7 @@ static int nbd_opt_info_or_go(QIOChannel *ioc, uint32_t 
opt,
|                  nbd_send_opt_abort(ioc);
|                  return -1;
|              }
| +            info->min_block = 1;//hack
|              if (!is_power_of_2(info->min_block)) {
|                  error_setg(errp, "server minimum block size %" PRIu32
|                             " is not a power of two", info->min_block);

Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
[eblake: address minor review nits]
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>


  Commit: 099fbcd65c2064a4ba8251e749bf600055027759
      
https://github.com/qemu/qemu/commit/099fbcd65c2064a4ba8251e749bf600055027759
  Author: Eric Blake <address@hidden>
  Date:   2019-04-08 (Mon, 08 Apr 2019)

  Changed paths:
    M nbd/server.c

  Log Message:
  -----------
  nbd/server: Don't fail NBD_OPT_INFO for byte-aligned sources

In commit 0c1d50bd, I added a couple of TODO comments about whether we
consult bl.request_alignment when responding to NBD_OPT_INFO. At the
time, qemu as server was hard-coding an advertised alignment of 512 to
clients that promised to obey constraints, and there was no function
for getting at a device's preferred alignment. But in hindsight,
advertising 512 when the block device prefers 1 caused other
compliance problems, and commit b0245d64 changed one of the two TODO
comments to advertise a more accurate alignment. Time to fix the other
TODO.  Doesn't really impact qemu as client (our normal client doesn't
use NBD_OPT_INFO, and qemu-nbd --list promises to obey block sizes),
but it might prove useful to other clients.

Fixes: b0245d64
Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>


  Commit: e53f88df77e70350b0eda92a2e5e39f67792008f
      
https://github.com/qemu/qemu/commit/e53f88df77e70350b0eda92a2e5e39f67792008f
  Author: Eric Blake <address@hidden>
  Date:   2019-04-08 (Mon, 08 Apr 2019)

  Changed paths:
    M nbd/client.c

  Log Message:
  -----------
  nbd/client: Fix error message for server with unusable sizing

Add a missing space to the error message used when giving up on a
server that insists on an alignment which renders the last few bytes
of the export unreadable.

Fixes: 3add3ab78
Signed-off-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>


  Commit: 7fe1427b5723583f55c753d5c75e23c93cc9a7e8
      
https://github.com/qemu/qemu/commit/7fe1427b5723583f55c753d5c75e23c93cc9a7e8
  Author: Peter Maydell <address@hidden>
  Date:   2019-04-08 (Mon, 08 Apr 2019)

  Changed paths:
    M nbd/client.c
    M nbd/server.c
    M nbd/trace-events

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2019-04-08' into 
staging

nbd patches for 2019-04-08

- Fix minor issues in recent alignment patches

# gpg: Signature made Mon 08 Apr 2019 19:53:48 BST
# gpg:                using RSA key A7A16B4A2527436A
# gpg: Good signature from "Eric Blake <address@hidden>" [full]
# gpg:                 aka "Eric Blake (Free Software Programmer) 
<address@hidden>" [full]
# gpg:                 aka "[jpeg image of size 6874]" [full]
# Primary key fingerprint: 71C2 CC22 B1C4 6029 27D2  F3AA A7A1 6B4A 2527 436A

* remotes/ericb/tags/pull-nbd-2019-04-08:
  nbd/client: Fix error message for server with unusable sizing
  nbd/server: Don't fail NBD_OPT_INFO for byte-aligned sources
  nbd/server: Trace client noncompliance on unaligned requests
  nbd/server: Fix blockstatus trace

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/5263724b78f8...7fe1427b5723



reply via email to

[Prev in Thread] Current Thread [Next in Thread]