34 lines
895 B
Diff
34 lines
895 B
Diff
This reverts commit 75f1dc0d076d1c1168f2115f1941ea627d38bd5a. The revert
|
|
could not be done automatically because changes after that commit
|
|
altered the code too much.
|
|
|
|
Signed-off-by: Chuck Ebbert <cebbert@redhat.com>
|
|
|
|
--- a/fs/block_dev.c
|
|
+++ b/fs/block_dev.c
|
|
@@ -1215,12 +1215,6 @@ int blkdev_get(struct block_device *bdev
|
|
|
|
res = __blkdev_get(bdev, mode, 0);
|
|
|
|
- /* __blkdev_get() may alter read only status, check it afterwards */
|
|
- if (!res && (mode & FMODE_WRITE) && bdev_read_only(bdev)) {
|
|
- __blkdev_put(bdev, mode, 0);
|
|
- res = -EACCES;
|
|
- }
|
|
-
|
|
if (whole) {
|
|
/* finish claiming */
|
|
mutex_lock(&bdev->bd_mutex);
|
|
@@ -1298,6 +1292,11 @@ struct block_device *blkdev_get_by_path(
|
|
if (err)
|
|
return ERR_PTR(err);
|
|
|
|
+ if ((mode & FMODE_WRITE) && bdev_read_only(bdev)) {
|
|
+ blkdev_put(bdev, mode);
|
|
+ return ERR_PTR(-EACCES);
|
|
+ }
|
|
+
|
|
return bdev;
|
|
}
|
|
EXPORT_SYMBOL(blkdev_get_by_path);
|