]> www.infradead.org Git - users/hch/block.git/commitdiff
nbd: add support for rotational devices
authorWouter Verhelst <w@uter.be>
Thu, 25 Jul 2024 16:45:36 +0000 (18:45 +0200)
committerJens Axboe <axboe@kernel.dk>
Sun, 28 Jul 2024 22:47:52 +0000 (16:47 -0600)
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>
Reviewed-by: Eric Blake <eblake@redhat.com>
Link: https://lore.kernel.org/r/20240725164536.1275851-1-w@uter.be
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/nbd.c
include/uapi/linux/nbd.h

index 41a90150b501d7210480ce1d971fbbbbcfd8545d..5b1811b1ba5fc280099564fc3dbdab6ff5cffca3 100644 (file)
@@ -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);
index 80ce0ef43afda69d586ae8becab793ed5b939ef7..d75215f2c675340c0ed00817b3dbd743e8c17e7a 100644 (file)
@@ -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 */