diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-02-27 17:05:26 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 19:10:22 -0800 |
commit | a83e814b5bb948850e903585d18b6298b7093cb2 (patch) | |
tree | 3dcb99f6b6c94df5fd32a57a12606416c32f442a /drivers/block/nbd.c | |
parent | 3a2d63f87989e01437ba994df5f297528c353d7d (diff) | |
download | linux-a83e814b5bb948850e903585d18b6298b7093cb2.tar.gz linux-a83e814b5bb948850e903585d18b6298b7093cb2.tar.bz2 linux-a83e814b5bb948850e903585d18b6298b7093cb2.zip |
nbd: show read-only state in sysfs
Pass the read-only flag to set_device_ro, so that it will be visible to
the block layer and in sysfs.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Paul Clements <Paul.Clements@steeleye.com>
Cc: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r-- | drivers/block/nbd.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 869861a87f40..52003d7a69ae 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -703,6 +703,8 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, mutex_unlock(&nbd->tx_lock); + if (nbd->flags & NBD_FLAG_READ_ONLY) + set_device_ro(bdev, true); if (nbd->flags & NBD_FLAG_SEND_TRIM) queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue); @@ -730,6 +732,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, dev_warn(disk_to_dev(nbd->disk), "queue cleared\n"); kill_bdev(bdev); queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue); + set_device_ro(bdev, false); if (file) fput(file); nbd->flags = 0; |