On 8/30/19 6:32 PM, Eric Blake wrote: >>>> @@ -458,10 +458,13 @@ static int nbd_negotiate_handle_export_name(NBDClient *client, >>>> return -EINVAL; >>>> } >>>> >>>> - trace_nbd_negotiate_new_style_size_flags(client->exp->size, >>>> - client->exp->nbdflags | myflags); >>>> + myflags = client->exp->nbdflags; >>>> + if (client->structured_reply) { >>>> + myflags |= NBD_FLAG_SEND_DF; >>>> + } >>> >>> >>> why we cant do just >>> client->exp->nbdflags |= NBD_FLAG_SEND_DF ? >> >> Because myflags is the runtime flags for _this_ client, while >> client->exp->nbdflags are the base flags shared by _all_ clients. If >> client A requests structured reply, but client B does not, then we don't >> want to advertise DF to client B; but amending client->exp->nbdflags >> would have that effect. > > I stand corrected - it looks like a fresh client->exp is created per > client, as evidenced by: I need to quit replying to myself, but my test was flawed. Modern clients don't go through NBD_OPT_EXPORT_NAME, so my added line... > +++ w/nbd/server.c > @@ -457,6 +457,7 @@ static int > nbd_negotiate_handle_export_name(NBDClient *client, bool no_zeroes, > myflags = client->exp->nbdflags; > if (client->structured_reply) { > myflags |= NBD_FLAG_SEND_DF; > + client->exp->nbdflags |= NBD_FLAG_SEND_DF; > } ...was not getting reached. If I instead tweak NBD_OPT_GO: diff --git i/nbd/server.c w/nbd/server.c index 6f3a83704fb3..da1ef793f6df 100644 --- i/nbd/server.c +++ w/nbd/server.c @@ -640,6 +640,7 @@ static int nbd_negotiate_handle_info(NBDClient *client, Error **errp) myflags = exp->nbdflags; if (client->structured_reply) { myflags |= NBD_FLAG_SEND_DF; + exp->nbdflags |= NBD_FLAG_SEND_DF; } trace_nbd_negotiate_new_style_size_flags(exp->size, myflags); stq_be_p(buf, exp->size); > $ ./qemu-nbd -r -f raw file -t & > > $ ~/qemu/qemu-io -r -f raw --trace=nbd_\*size_flags > nbd://localhost:10809 -c quit > 32145@1567207628.519883:nbd_receive_negotiate_size_flags Size is > 1049088, export flags 0x48f > > $ MY_HACK=1 ~/qemu/qemu-io -r -f raw --trace=nbd_\*size_flags > nbd://localhost:10809 -c quit > 32156@1567207630.417815:nbd_receive_negotiate_size_flags Size is > 1049088, export flags 0x40f > Then this reports 0x48f, proving that my initial reaction was correct: client->exp is a shared resource across multiple connections, but advertising DF must be a per-connection decision. > $ ~/qemu/qemu-io -r -f raw --trace=nbd_\*size_flags > nbd://localhost:10809 -c quit > 32167@1567207635.202940:nbd_receive_negotiate_size_flags Size is > 1049088, export flags 0x48f > > The export flags change per client, so I _can_ store into > client->exp->nbdflags. Will do that for v2. I see nothing to change for v2, so I'm inclined to take this patch as is. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org