aboutsummaryrefslogtreecommitdiffstats
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-11-13 05:55:17 -0500
committerTejun Heo <tj@kernel.org>2010-11-13 05:55:17 -0500
commit75f1dc0d076d1c1168f2115f1941ea627d38bd5a (patch)
treeaf12858b842579e8924b30cb636b96fcca6f46b1 /fs/block_dev.c
parent6a027eff62f6ae32d49f2ae5dadd6f4eee1ddae2 (diff)
block: check bdev_read_only() from blkdev_get()
bdev read-only status can be queried using bdev_read_only() and may change while the device is being opened. Enforce it by checking it from blkdev_get() after open succeeds. This makes bdev_read_only() check in open_bdev_exclusive() and fsg_lun_open() unnecessary. Drop them. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: linux-usb@vger.kernel.org
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 269bfbbd10fc..606a5259f87f 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1149,6 +1149,12 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder)
1149 1149
1150 res = __blkdev_get(bdev, mode, 0); 1150 res = __blkdev_get(bdev, mode, 0);
1151 1151
1152 /* __blkdev_get() may alter read only status, check it afterwards */
1153 if (!res && (mode & FMODE_WRITE) && bdev_read_only(bdev)) {
1154 __blkdev_put(bdev, mode, 0);
1155 res = -EACCES;
1156 }
1157
1152 if (whole) { 1158 if (whole) {
1153 /* finish claiming */ 1159 /* finish claiming */
1154 spin_lock(&bdev_lock); 1160 spin_lock(&bdev_lock);
@@ -1453,11 +1459,6 @@ struct block_device *open_bdev_exclusive(const char *path, fmode_t mode, void *h
1453 if (error) 1459 if (error)
1454 return ERR_PTR(error); 1460 return ERR_PTR(error);
1455 1461
1456 if ((mode & FMODE_WRITE) && bdev_read_only(bdev)) {
1457 blkdev_put(bdev, mode);
1458 return ERR_PTR(-EACCES);
1459 }
1460
1461 return bdev; 1462 return bdev;
1462} 1463}
1463 1464