* [PATCH] nbd: add support for rotational devices
@ 2024-07-25 16:45 Wouter Verhelst
2024-07-25 18:30 ` Eric Blake
2024-07-25 19:59 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Wouter Verhelst @ 2024-07-25 16:45 UTC (permalink / raw)
To: Josef Bacik, Jens Axboe; +Cc: Wouter Verhelst, linux-block, nbd, linux-kernel
The NBD protocol defines the flag NBD_FLAG_ROTATIONAL to flag that the
export in use should be treated as a rotational device.
Add support for that flag to the kernel driver.
Signed-off-by: Wouter Verhelst <w@uter.be>
---
drivers/block/nbd.c | 3 +++
include/uapi/linux/nbd.h | 3 ++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 41a90150b501..5b1811b1ba5f 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -350,6 +350,9 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
lim.features |= BLK_FEAT_WRITE_CACHE;
lim.features &= ~BLK_FEAT_FUA;
}
+ if (nbd->config->flags & NBD_FLAG_ROTATIONAL)
+ lim.features |= BLK_FEAT_ROTATIONAL;
+
lim.logical_block_size = blksize;
lim.physical_block_size = blksize;
error = queue_limits_commit_update(nbd->disk->queue, &lim);
diff --git a/include/uapi/linux/nbd.h b/include/uapi/linux/nbd.h
index 80ce0ef43afd..d75215f2c675 100644
--- a/include/uapi/linux/nbd.h
+++ b/include/uapi/linux/nbd.h
@@ -51,8 +51,9 @@ enum {
#define NBD_FLAG_READ_ONLY (1 << 1) /* device is read-only */
#define NBD_FLAG_SEND_FLUSH (1 << 2) /* can flush writeback cache */
#define NBD_FLAG_SEND_FUA (1 << 3) /* send FUA (forced unit access) */
-/* there is a gap here to match userspace */
+#define NBD_FLAG_ROTATIONAL (1 << 4) /* device is rotational */
#define NBD_FLAG_SEND_TRIM (1 << 5) /* send trim/discard */
+/* there is a gap here to match userspace */
#define NBD_FLAG_CAN_MULTI_CONN (1 << 8) /* Server supports multiple connections per export. */
/* values for cmd flags in the upper 16 bits of request type */
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] nbd: add support for rotational devices
2024-07-25 16:45 [PATCH] nbd: add support for rotational devices Wouter Verhelst
@ 2024-07-25 18:30 ` Eric Blake
2024-07-25 19:59 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2024-07-25 18:30 UTC (permalink / raw)
To: Wouter Verhelst; +Cc: Josef Bacik, Jens Axboe, linux-block, nbd, linux-kernel
On Thu, Jul 25, 2024 at 06:45:36PM GMT, Wouter Verhelst wrote:
> The NBD protocol defines the flag NBD_FLAG_ROTATIONAL to flag that the
> export in use should be treated as a rotational device.
>
> Add support for that flag to the kernel driver.
>
> Signed-off-by: Wouter Verhelst <w@uter.be>
> ---
> drivers/block/nbd.c | 3 +++
> include/uapi/linux/nbd.h | 3 ++-
> 2 files changed, 5 insertions(+), 1 deletion(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
For what it's worth, the nbdkit project recently made it possible to
aad a filter on top of any existing NBD server to change the setting
of the rotational bit[1], as well as a filter to intentionally
simulate delays of a rotational device[2], in order to experiment with
how much impact changing the bit can have when it is not ignored.
[1] https://libguestfs.org/nbdkit-rotational-filter.1.html
[2] https://libguestfs.org/nbdkit-spinning-filter.1.html
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nbd: add support for rotational devices
2024-07-25 16:45 [PATCH] nbd: add support for rotational devices Wouter Verhelst
2024-07-25 18:30 ` Eric Blake
@ 2024-07-25 19:59 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2024-07-25 19:59 UTC (permalink / raw)
To: Josef Bacik, Wouter Verhelst; +Cc: linux-block, nbd, linux-kernel
On Thu, 25 Jul 2024 18:45:36 +0200, Wouter Verhelst wrote:
> The NBD protocol defines the flag NBD_FLAG_ROTATIONAL to flag that the
> export in use should be treated as a rotational device.
>
> Add support for that flag to the kernel driver.
>
>
Applied, thanks!
[1/1] nbd: add support for rotational devices
commit: 45c7d3321b0ce575705bb62b6069efad48a51d67
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-25 19:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-25 16:45 [PATCH] nbd: add support for rotational devices Wouter Verhelst
2024-07-25 18:30 ` Eric Blake
2024-07-25 19:59 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®