All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nbd/client: Request larger block status by default
@ 2021-09-21 16:17 Eric Blake
  2021-09-21 17:25 ` Vladimir Sementsov-Ogievskiy
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Blake @ 2021-09-21 16:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, hreitz, vsementsov, qemu-block

Now that commit 5a1cfd21 has clarified that a driver's block_status
can report larger *pnum than in the original request, we can take
advantage of that in the NBD driver.  Rather that limiting our request
to the server based on the maximum @bytes our caller mentioned, we
instead ask for as much status as possible (the minimum of our 4G
limit or the rest of the export); the server will still only give us
one extent in its answer (because we are using NBD_CMD_FLAG_REQ_ONE),
but now the block layer's caching of data areas can take advantage of
cases where the server gives us a large answer to avoid the need for
future NBD_CMD_BLOCK_STATUS calls.

Signed-off-by: Eric Blake <eblake@redhat.com>
---
 block/nbd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/block/nbd.c b/block/nbd.c
index f6ff1c4fb472..7c4ec058b0aa 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -1479,10 +1479,15 @@ static int coroutine_fn nbd_client_co_block_status(
     BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
     Error *local_err = NULL;

+    /*
+     * No need to limit our over-the-wire request to @bytes; rather,
+     * ask the server for as much as it can send in one go, and the
+     * block layer will then cap things.
+     */
     NBDRequest request = {
         .type = NBD_CMD_BLOCK_STATUS,
         .from = offset,
         .len = MIN(QEMU_ALIGN_DOWN(INT_MAX, bs->bl.request_alignment),
-                   MIN(bytes, s->info.size - offset)),
+                   s->info.size - offset),
         .flags = NBD_CMD_FLAG_REQ_ONE,
     };

-- 
2.31.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-22  7:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21 16:17 [PATCH] nbd/client: Request larger block status by default Eric Blake
2021-09-21 17:25 ` Vladimir Sementsov-Ogievskiy
2021-09-21 18:08   ` Eric Blake
2021-09-21 19:12     ` Vladimir Sementsov-Ogievskiy
2021-09-21 20:00       ` Eric Blake
2021-09-22  7:28         ` Vladimir Sementsov-Ogievskiy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.