diff mbox series

[3/5] nbd: Implement client use of NBD FAST_ZERO

Message ID 20190823143726.27062-4-eblake@redhat.com (mailing list archive)
State New, archived
Headers show
Series Add NBD fast zero support to qemu client and server | expand

Commit Message

Eric Blake Aug. 23, 2019, 2:37 p.m. UTC
The client side is fairly straightforward: if the server advertised
fast zero support, then we can map that to BDRV_REQ_NO_FALLBACK
support.  A server that advertises FAST_ZERO but not WRITE_ZEROES
is technically broken, but we can ignore that situation as it does
not change our behavior.

Signed-off-by: Eric Blake <eblake@redhat.com>

---

Perhaps this is worth merging with the previous patch.
---
 block/nbd.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Vladimir Sementsov-Ogievskiy Aug. 30, 2019, 6:11 p.m. UTC | #1
23.08.2019 17:37, Eric Blake wrote:
> The client side is fairly straightforward: if the server advertised
> fast zero support, then we can map that to BDRV_REQ_NO_FALLBACK
> support.  A server that advertises FAST_ZERO but not WRITE_ZEROES
> is technically broken, but we can ignore that situation as it does
> not change our behavior.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

> 
> ---
> 
> Perhaps this is worth merging with the previous patch.
> ---
>   block/nbd.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/block/nbd.c b/block/nbd.c
> index beed46fb3414..8339d7106366 100644
> --- a/block/nbd.c
> +++ b/block/nbd.c
> @@ -1044,6 +1044,10 @@ static int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
>       if (!(flags & BDRV_REQ_MAY_UNMAP)) {
>           request.flags |= NBD_CMD_FLAG_NO_HOLE;
>       }
> +    if (flags & BDRV_REQ_NO_FALLBACK) {
> +        assert(s->info.flags & NBD_FLAG_SEND_FAST_ZERO);
> +        request.flags |= NBD_CMD_FLAG_FAST_ZERO;
> +    }
> 
>       if (!bytes) {
>           return 0;
> @@ -1239,6 +1243,9 @@ static int nbd_client_connect(BlockDriverState *bs, Error **errp)
>       }
>       if (s->info.flags & NBD_FLAG_SEND_WRITE_ZEROES) {
>           bs->supported_zero_flags |= BDRV_REQ_MAY_UNMAP;
> +        if (s->info.flags & NBD_FLAG_SEND_FAST_ZERO) {
> +            bs->supported_zero_flags |= BDRV_REQ_NO_FALLBACK;
> +        }
>       }
> 
>       s->sioc = sioc;
>
diff mbox series

Patch

diff --git a/block/nbd.c b/block/nbd.c
index beed46fb3414..8339d7106366 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -1044,6 +1044,10 @@  static int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
     if (!(flags & BDRV_REQ_MAY_UNMAP)) {
         request.flags |= NBD_CMD_FLAG_NO_HOLE;
     }
+    if (flags & BDRV_REQ_NO_FALLBACK) {
+        assert(s->info.flags & NBD_FLAG_SEND_FAST_ZERO);
+        request.flags |= NBD_CMD_FLAG_FAST_ZERO;
+    }

     if (!bytes) {
         return 0;
@@ -1239,6 +1243,9 @@  static int nbd_client_connect(BlockDriverState *bs, Error **errp)
     }
     if (s->info.flags & NBD_FLAG_SEND_WRITE_ZEROES) {
         bs->supported_zero_flags |= BDRV_REQ_MAY_UNMAP;
+        if (s->info.flags & NBD_FLAG_SEND_FAST_ZERO) {
+            bs->supported_zero_flags |= BDRV_REQ_NO_FALLBACK;
+        }
     }

     s->sioc = sioc;