[Nbd] [CFT][PATCH 3/4] nbd: support ROTATIONAL
- To: nbd-general@...72...
- Cc: Paul Clements <Paul.Clements@...124...>
- Subject: [Nbd] [CFT][PATCH 3/4] nbd: support ROTATIONAL
- From: Paolo Bonzini <pbonzini@...696...>
- Date: Tue, 13 Sep 2011 13:09:52 +0200
- Message-id: <1315912193-25959-4-git-send-email-pbonzini@...696...>
- In-reply-to: <1315912193-25959-1-git-send-email-pbonzini@...696...>
- References: <1315912193-25959-1-git-send-email-pbonzini@...696...>
From: Alex Bligh <alex@...872...>
Cc: Paul Clements <Paul.Clements@...124...>
Cc: <nbd-general@...72...>
Signed-off-by: Alex Bligh <alex@...872...>
Signed-off-by: Paolo Bonzini <pbonzini@...696...>
---
drivers/block/nbd.c | 8 ++++----
include/linux/nbd.h | 1 +
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index bece3cc..930b4df 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -699,6 +699,10 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *lo,
return -EINVAL;
mutex_unlock(&lo->tx_lock);
+ if (lo->flags & NBD_FLAG_ROTATIONAL)
+ queue_flag_clear_unlocked(QUEUE_FLAG_NONROT, lo->disk->queue);
+ else
+ queue_flag_set_unlocked(QUEUE_FLAG_NONROT, lo->disk->queue);
thread = kthread_create(nbd_thread, lo, lo->disk->disk_name);
if (IS_ERR(thread)) {
@@ -820,10 +824,6 @@ static int __init nbd_init(void)
* unless the relevant flag bit is set
*/
blk_queue_flush(disk->queue, REQ_FLUSH | REQ_FUA);
- /*
- * Tell the block layer that we are not a rotational device
- */
- queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue);
}
if (register_blkdev(NBD_MAJOR, "nbd")) {
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index d8cd251..5037b0b 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
@@ -44,6 +44,7 @@ enum {
#define NBD_FLAG_READ_ONLY (1 << 1) /* Device is read only */
#define NBD_FLAG_SEND_FLUSH (1 << 2) /* Send FLUSH */
#define NBD_FLAG_SEND_FUA (1 << 3) /* Send FUA (Force Unit Access) */
+#define NBD_FLAG_ROTATIONAL (1 << 4) /* Use elevator algorithm - rotational media */
#define nbd_cmd(req) ((req)->cmd[0])
--
1.7.6
Reply to: