diff options
author | Chuck Ebbert <cebbert@redhat.com> | 2011-02-16 18:11:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-02-16 19:48:13 -0500 |
commit | e51900f7d38cbcfb481d84567fd92540e7e1d23a (patch) | |
tree | f732388a0efab2967fddc0afd0f2200731e34d02 | |
parent | a2640111d5edb3f4e6dd6089c0dbddc7590110b4 (diff) |
block: revert block_dev read-only check
This reverts commit 75f1dc0d076d ("block: check bdev_read_only() from
blkdev_get()"). That commit added stricter checking to make sure
devices that were being used read-only were actually opened in that
mode.
It turns out that the change breaks a bunch of kernel code that opens
block devices. Affected systems include dm, md, and the loop device.
Because strict checking for read-only opens of block devices was not
done before this, the code that opens the devices was opening them
read-write even if they were being used read-only. Auditing all that
code will take time, and new userspace packages for dm, mdadm, etc.
will also be required.
Signed-off-by: Chuck Ebbert <cebbert@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/block_dev.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 333a7bb4cb9c..4fb8a3431531 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -1215,12 +1215,6 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder) | |||
1215 | 1215 | ||
1216 | res = __blkdev_get(bdev, mode, 0); | 1216 | res = __blkdev_get(bdev, mode, 0); |
1217 | 1217 | ||
1218 | /* __blkdev_get() may alter read only status, check it afterwards */ | ||
1219 | if (!res && (mode & FMODE_WRITE) && bdev_read_only(bdev)) { | ||
1220 | __blkdev_put(bdev, mode, 0); | ||
1221 | res = -EACCES; | ||
1222 | } | ||
1223 | |||
1224 | if (whole) { | 1218 | if (whole) { |
1225 | /* finish claiming */ | 1219 | /* finish claiming */ |
1226 | mutex_lock(&bdev->bd_mutex); | 1220 | mutex_lock(&bdev->bd_mutex); |
@@ -1298,6 +1292,11 @@ struct block_device *blkdev_get_by_path(const char *path, fmode_t mode, | |||
1298 | if (err) | 1292 | if (err) |
1299 | return ERR_PTR(err); | 1293 | return ERR_PTR(err); |
1300 | 1294 | ||
1295 | if ((mode & FMODE_WRITE) && bdev_read_only(bdev)) { | ||
1296 | blkdev_put(bdev, mode); | ||
1297 | return ERR_PTR(-EACCES); | ||
1298 | } | ||
1299 | |||
1301 | return bdev; | 1300 | return bdev; |
1302 | } | 1301 | } |
1303 | EXPORT_SYMBOL(blkdev_get_by_path); | 1302 | EXPORT_SYMBOL(blkdev_get_by_path); |