From: Alex Bligh <[email protected]>

Cc: Paul Clements <[email protected]>
Cc: <[email protected]>
Signed-off-by: Alex Bligh <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
---
 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



------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry&reg; mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry&reg; DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
_______________________________________________
Nbd-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nbd-general

Reply via email to