From: Josh Durgin Date: Tue, 1 Oct 2013 03:10:04 +0000 (-0700) Subject: rbd: only set disk to read-only once X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=22001f619f29ddf66582d834223dcff4c0b74595;p=linux-beck.git rbd: only set disk to read-only once rbd_open(), called every time the device is opened, calls set_device_ro(). There's no reason to set the device read-only or read-write every time it is opened. Just do this once during device setup, using set_disk_ro() instead because the struct block_device isn't available to us there. Signed-off-by: Josh Durgin Reviewed-by: Alex Elder --- diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 6423f6e3b07c..bbeb404b3a07 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -541,7 +541,6 @@ static int rbd_open(struct block_device *bdev, fmode_t mode) return -ENOENT; (void) get_device(&rbd_dev->dev); - set_device_ro(bdev, rbd_dev->mapping.read_only); return 0; } @@ -5060,6 +5059,7 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev) if (ret) goto err_out_disk; set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); + set_disk_ro(rbd_dev->disk, rbd_dev->mapping.read_only); ret = rbd_bus_add_dev(rbd_dev); if (ret)