block: add a new set_read_only method
[ Upstream commit e00adcadf3af7a8335026d71ab9f0e0a922191ac ] 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> Stable-dep-of: 9674f54e41ff ("md: Don't clear MD_CLOSING when the raid is about to stop") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Sasha Levin
parent
dc51c01a3d
commit
f28658bc8a
@@ -451,6 +451,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user