summaryrefslogtreecommitdiff
path: root/block/ioctl.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-11-03 13:00:11 +0300
committerJens Axboe <axboe@kernel.dk>2020-11-16 18:14:29 +0300
commite00adcadf3af7a8335026d71ab9f0e0a922191ac (patch)
tree7d7f22326e387ef08b23cf9a3a76e6f16fc1b089 /block/ioctl.c
parent4a9d6d667f0bafed55a9e9f5ae8bceb3680749d7 (diff)
downloadlinux-e00adcadf3af7a8335026d71ab9f0e0a922191ac.tar.xz
block: add a new set_read_only method
Add a new method to allow for driver-specific processing when setting or clearing the block device read-only state. This allows to replace the cumbersome and error-prone override of the whole ioctl implementation. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/ioctl.c')
-rw-r--r--block/ioctl.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/block/ioctl.c b/block/ioctl.c
index c6d8863f0409..a6fa16b97705 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -389,6 +389,11 @@ static int blkdev_roset(struct block_device *bdev, fmode_t mode,
return ret;
if (get_user(n, (int __user *)arg))
return -EFAULT;
+ if (bdev->bd_disk->fops->set_read_only) {
+ ret = bdev->bd_disk->fops->set_read_only(bdev, n);
+ if (ret)
+ return ret;
+ }
set_device_ro(bdev, n);
return 0;
}