Skip to content

Commit 7543ae2

Browse files
yoeaxboe
authored andcommitted
nbd: add support for rotational devices
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 <[email protected]> Reviewed-by: Eric Blake <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 7960af3 commit 7543ae2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

drivers/block/nbd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
350350
lim.features |= BLK_FEAT_WRITE_CACHE;
351351
lim.features &= ~BLK_FEAT_FUA;
352352
}
353+
if (nbd->config->flags & NBD_FLAG_ROTATIONAL)
354+
lim.features |= BLK_FEAT_ROTATIONAL;
355+
353356
lim.logical_block_size = blksize;
354357
lim.physical_block_size = blksize;
355358
error = queue_limits_commit_update(nbd->disk->queue, &lim);

include/uapi/linux/nbd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ enum {
5151
#define NBD_FLAG_READ_ONLY (1 << 1) /* device is read-only */
5252
#define NBD_FLAG_SEND_FLUSH (1 << 2) /* can flush writeback cache */
5353
#define NBD_FLAG_SEND_FUA (1 << 3) /* send FUA (forced unit access) */
54-
/* there is a gap here to match userspace */
54+
#define NBD_FLAG_ROTATIONAL (1 << 4) /* device is rotational */
5555
#define NBD_FLAG_SEND_TRIM (1 << 5) /* send trim/discard */
56+
/* there is a gap here to match userspace */
5657
#define NBD_FLAG_CAN_MULTI_CONN (1 << 8) /* Server supports multiple connections per export. */
5758

5859
/* values for cmd flags in the upper 16 bits of request type */

0 commit comments

Comments
 (0)