On 10/06/2017 02:34 AM, Vladimir Sementsov-Ogievskiy wrote: >> - if the chunk is NBD_REPLY_TYPE_NONE, there is no payload, and this >> should be the final chunk, so the return to the caller can be the same >> as for old-style (return 1 if we had no earlier error packets, or the >> saved negative value corresponding to the first error received) >> - if the command is read, we can read the payload into qiov (saves >> malloc'ing space for the reply only to copy it into the qiov), so we > > but here you said "This is putting a LOT of smarts directly into the > receive routine" About the only reason to justify putting smarts into the receive routine is if it is the most common case, where the overhead of not special-casing will penalize us. READ happens to be a frequent command, all other commands, like BLOCK_STATUS, will probably be infrequent. Making READ malloc the result, only to then copy it into the qiov, is a waste of time; no other structured command will pass a qiov. So yeah, maybe I'm stating things a bit differently than in my earlier messages, but that's because I've now stated reasonings for why it is okay to special-case READ with a qiov differently from all other commands (none of which will pass a qiov to the receive routine). Thanks for persisting with this, and I'm looking forward to the next revision that you post; hopefully, by taking this discussion, we are making sure that the design is solid. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org