All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	"open list:Network Block Dev..." <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PULL 9/9] nbd: Implement server use of NBD FAST_ZERO
Date: Thu,  5 Sep 2019 13:21:32 -0500	[thread overview]
Message-ID: <20190905182132.3563-10-eblake@redhat.com> (raw)
In-Reply-To: <20190905182132.3563-1-eblake@redhat.com>

The server side is fairly straightforward: we can always advertise
support for detection of fast zero, and implement it by mapping the
request to the block layer BDRV_REQ_NO_FALLBACK.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190823143726.27062-5-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 nbd/server.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/nbd/server.c b/nbd/server.c
index 4992148de1c4..28c3c8be854c 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -1513,7 +1513,8 @@ NBDExport *nbd_export_new(BlockDriverState *bs, uint64_t dev_offset,
             exp->nbdflags |= NBD_FLAG_CAN_MULTI_CONN;
         }
     } else {
-        exp->nbdflags |= NBD_FLAG_SEND_TRIM | NBD_FLAG_SEND_WRITE_ZEROES;
+        exp->nbdflags |= (NBD_FLAG_SEND_TRIM | NBD_FLAG_SEND_WRITE_ZEROES |
+                          NBD_FLAG_SEND_FAST_ZERO);
     }
     assert(size <= INT64_MAX - dev_offset);
     exp->size = QEMU_ALIGN_DOWN(size, BDRV_SECTOR_SIZE);
@@ -2166,7 +2167,7 @@ static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request,
     if (request->type == NBD_CMD_READ && client->structured_reply) {
         valid_flags |= NBD_CMD_FLAG_DF;
     } else if (request->type == NBD_CMD_WRITE_ZEROES) {
-        valid_flags |= NBD_CMD_FLAG_NO_HOLE;
+        valid_flags |= NBD_CMD_FLAG_NO_HOLE | NBD_CMD_FLAG_FAST_ZERO;
     } else if (request->type == NBD_CMD_BLOCK_STATUS) {
         valid_flags |= NBD_CMD_FLAG_REQ_ONE;
     }
@@ -2305,6 +2306,9 @@ static coroutine_fn int nbd_handle_request(NBDClient *client,
         if (!(request->flags & NBD_CMD_FLAG_NO_HOLE)) {
             flags |= BDRV_REQ_MAY_UNMAP;
         }
+        if (request->flags & NBD_CMD_FLAG_FAST_ZERO) {
+            flags |= BDRV_REQ_NO_FALLBACK;
+        }
         ret = blk_pwrite_zeroes(exp->blk, request->from + exp->dev_offset,
                                 request->len, flags);
         return nbd_send_generic_reply(client, request->handle, ret,
-- 
2.21.0



  parent reply	other threads:[~2019-09-05 18:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05 18:21 [Qemu-devel] [PULL 0/9] NBD patches through 2019-09-05 Eric Blake
2019-09-05 18:21 ` [Qemu-devel] [PULL 1/9] nbd: Advertise multi-conn for shared read-only connections Eric Blake
2019-09-05 18:21 ` [Qemu-devel] [PULL 2/9] nbd: Use g_autofree in a few places Eric Blake
2019-09-05 18:21 ` [Qemu-devel] [PULL 3/9] nbd: Tolerate more errors to structured reply request Eric Blake
2019-09-05 18:21 ` [Qemu-devel] [PULL 4/9] block: workaround for unaligned byte range in fallocate() Eric Blake
2019-09-06 12:51   ` Andrey Shinkevich
2019-09-05 18:21 ` [Qemu-devel] [PULL 5/9] docs: Update preferred NBD device syntax Eric Blake
2019-09-05 18:21 ` [Qemu-devel] [PULL 6/9] nbd: Improve per-export flag handling in server Eric Blake
2019-09-05 18:21 ` [Qemu-devel] [PULL 7/9] nbd: Prepare for NBD_CMD_FLAG_FAST_ZERO Eric Blake
2019-09-05 18:21 ` [Qemu-devel] [PULL 8/9] nbd: Implement client use of NBD FAST_ZERO Eric Blake
2019-09-05 18:21 ` Eric Blake [this message]
2019-09-05 20:47 ` [Qemu-devel] [PULL 0/9] NBD patches through 2019-09-05 Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190905182132.3563-10-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.