diff options
author | Tejun Heo <tj@kernel.org> | 2010-11-13 05:55:18 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2010-11-13 05:55:18 -0500 |
commit | d4d77629953eabd3c14f6fa5746f6b28babfc55f (patch) | |
tree | 38cce0d4764ecb34a9f7f49332959780e28bb786 /fs | |
parent | 75f1dc0d076d1c1168f2115f1941ea627d38bd5a (diff) |
block: clean up blkdev_get() wrappers and their users
After recent blkdev_get() modifications, open_by_devnum() and
open_bdev_exclusive() are simple wrappers around blkdev_get().
Replace them with blkdev_get_by_dev() and blkdev_get_by_path().
blkdev_get_by_dev() is identical to open_by_devnum().
blkdev_get_by_path() is slightly different in that it doesn't
automatically add %FMODE_EXCL to @mode.
All users are converted. Most conversions are mechanical and don't
introduce any behavior difference. There are several exceptions.
* btrfs now sets FMODE_EXCL in btrfs_device->mode, so there's no
reason to OR it explicitly on blkdev_put().
* gfs2, nilfs2 and the generic mount_bdev() now set FMODE_EXCL in
sb->s_mode.
* With the above changes, sb->s_mode now always should contain
FMODE_EXCL. WARN_ON_ONCE() added to kill_block_super() to detect
errors.
The new blkdev_get_*() functions are with proper docbook comments.
While at it, add function description to blkdev_get() too.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Philipp Reisner <philipp.reisner@linbit.com>
Cc: Neil Brown <neilb@suse.de>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Joern Engel <joern@lazybastard.org>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Jan Kara <jack@suse.cz>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: KONISHI Ryusuke <konishi.ryusuke@lab.ntt.co.jp>
Cc: reiserfs-devel@vger.kernel.org
Cc: xfs-masters@oss.sgi.com
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/block_dev.c | 139 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 24 | ||||
-rw-r--r-- | fs/btrfs/volumes.h | 2 | ||||
-rw-r--r-- | fs/ext3/super.c | 2 | ||||
-rw-r--r-- | fs/ext4/super.c | 2 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 8 | ||||
-rw-r--r-- | fs/jfs/jfs_logmgr.c | 4 | ||||
-rw-r--r-- | fs/logfs/dev_bdev.c | 3 | ||||
-rw-r--r-- | fs/nilfs2/super.c | 8 | ||||
-rw-r--r-- | fs/reiserfs/journal.c | 6 | ||||
-rw-r--r-- | fs/super.c | 9 | ||||
-rw-r--r-- | fs/xfs/linux-2.6/xfs_super.c | 3 |
12 files changed, 132 insertions, 78 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 606a5259f87f..c1c1b8c3fb99 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -854,24 +854,6 @@ static inline void bd_unlink_disk_holder(struct block_device *bdev) | |||
854 | { } | 854 | { } |
855 | #endif | 855 | #endif |
856 | 856 | ||
857 | /* | ||
858 | * Tries to open block device by device number. Use it ONLY if you | ||
859 | * really do not have anything better - i.e. when you are behind a | ||
860 | * truly sucky interface and all you are given is a device number. _Never_ | ||
861 | * to be used for internal purposes. If you ever need it - reconsider | ||
862 | * your API. | ||
863 | */ | ||
864 | struct block_device *open_by_devnum(dev_t dev, fmode_t mode, void *holder) | ||
865 | { | ||
866 | struct block_device *bdev = bdget(dev); | ||
867 | int err = -ENOMEM; | ||
868 | if (bdev) | ||
869 | err = blkdev_get(bdev, mode, holder); | ||
870 | return err ? ERR_PTR(err) : bdev; | ||
871 | } | ||
872 | |||
873 | EXPORT_SYMBOL(open_by_devnum); | ||
874 | |||
875 | /** | 857 | /** |
876 | * flush_disk - invalidates all buffer-cache entries on a disk | 858 | * flush_disk - invalidates all buffer-cache entries on a disk |
877 | * | 859 | * |
@@ -1132,6 +1114,25 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
1132 | return ret; | 1114 | return ret; |
1133 | } | 1115 | } |
1134 | 1116 | ||
1117 | /** | ||
1118 | * blkdev_get - open a block device | ||
1119 | * @bdev: block_device to open | ||
1120 | * @mode: FMODE_* mask | ||
1121 | * @holder: exclusive holder identifier | ||
1122 | * | ||
1123 | * Open @bdev with @mode. If @mode includes %FMODE_EXCL, @bdev is | ||
1124 | * open with exclusive access. Specifying %FMODE_EXCL with %NULL | ||
1125 | * @holder is invalid. Exclusive opens may nest for the same @holder. | ||
1126 | * | ||
1127 | * On success, the reference count of @bdev is unchanged. On failure, | ||
1128 | * @bdev is put. | ||
1129 | * | ||
1130 | * CONTEXT: | ||
1131 | * Might sleep. | ||
1132 | * | ||
1133 | * RETURNS: | ||
1134 | * 0 on success, -errno on failure. | ||
1135 | */ | ||
1135 | int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder) | 1136 | int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder) |
1136 | { | 1137 | { |
1137 | struct block_device *whole = NULL; | 1138 | struct block_device *whole = NULL; |
@@ -1186,6 +1187,80 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder) | |||
1186 | } | 1187 | } |
1187 | EXPORT_SYMBOL(blkdev_get); | 1188 | EXPORT_SYMBOL(blkdev_get); |
1188 | 1189 | ||
1190 | /** | ||
1191 | * blkdev_get_by_path - open a block device by name | ||
1192 | * @path: path to the block device to open | ||
1193 | * @mode: FMODE_* mask | ||
1194 | * @holder: exclusive holder identifier | ||
1195 | * | ||
1196 | * Open the blockdevice described by the device file at @path. @mode | ||
1197 | * and @holder are identical to blkdev_get(). | ||
1198 | * | ||
1199 | * On success, the returned block_device has reference count of one. | ||
1200 | * | ||
1201 | * CONTEXT: | ||
1202 | * Might sleep. | ||
1203 | * | ||
1204 | * RETURNS: | ||
1205 | * Pointer to block_device on success, ERR_PTR(-errno) on failure. | ||
1206 | */ | ||
1207 | struct block_device *blkdev_get_by_path(const char *path, fmode_t mode, | ||
1208 | void *holder) | ||
1209 | { | ||
1210 | struct block_device *bdev; | ||
1211 | int err; | ||
1212 | |||
1213 | bdev = lookup_bdev(path); | ||
1214 | if (IS_ERR(bdev)) | ||
1215 | return bdev; | ||
1216 | |||
1217 | err = blkdev_get(bdev, mode, holder); | ||
1218 | if (err) | ||
1219 | return ERR_PTR(err); | ||
1220 | |||
1221 | return bdev; | ||
1222 | } | ||
1223 | EXPORT_SYMBOL(blkdev_get_by_path); | ||
1224 | |||
1225 | /** | ||
1226 | * blkdev_get_by_dev - open a block device by device number | ||
1227 | * @dev: device number of block device to open | ||
1228 | * @mode: FMODE_* mask | ||
1229 | * @holder: exclusive holder identifier | ||
1230 | * | ||
1231 | * Open the blockdevice described by device number @dev. @mode and | ||
1232 | * @holder are identical to blkdev_get(). | ||
1233 | * | ||
1234 | * Use it ONLY if you really do not have anything better - i.e. when | ||
1235 | * you are behind a truly sucky interface and all you are given is a | ||
1236 | * device number. _Never_ to be used for internal purposes. If you | ||
1237 | * ever need it - reconsider your API. | ||
1238 | * | ||
1239 | * On success, the returned block_device has reference count of one. | ||
1240 | * | ||
1241 | * CONTEXT: | ||
1242 | * Might sleep. | ||
1243 | * | ||
1244 | * RETURNS: | ||
1245 | * Pointer to block_device on success, ERR_PTR(-errno) on failure. | ||
1246 | */ | ||
1247 | struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder) | ||
1248 | { | ||
1249 | struct block_device *bdev; | ||
1250 | int err; | ||
1251 | |||
1252 | bdev = bdget(dev); | ||
1253 | if (!bdev) | ||
1254 | return ERR_PTR(-ENOMEM); | ||
1255 | |||
1256 | err = blkdev_get(bdev, mode, holder); | ||
1257 | if (err) | ||
1258 | return ERR_PTR(err); | ||
1259 | |||
1260 | return bdev; | ||
1261 | } | ||
1262 | EXPORT_SYMBOL(blkdev_get_by_dev); | ||
1263 | |||
1189 | static int blkdev_open(struct inode * inode, struct file * filp) | 1264 | static int blkdev_open(struct inode * inode, struct file * filp) |
1190 | { | 1265 | { |
1191 | struct block_device *bdev; | 1266 | struct block_device *bdev; |
@@ -1436,34 +1511,6 @@ fail: | |||
1436 | } | 1511 | } |
1437 | EXPORT_SYMBOL(lookup_bdev); | 1512 | EXPORT_SYMBOL(lookup_bdev); |
1438 | 1513 | ||
1439 | /** | ||
1440 | * open_bdev_exclusive - open a block device by name and set it up for use | ||
1441 | * | ||
1442 | * @path: special file representing the block device | ||
1443 | * @mode: FMODE_... combination to pass be used | ||
1444 | * @holder: owner for exclusion | ||
1445 | * | ||
1446 | * Open the blockdevice described by the special file at @path, claim it | ||
1447 | * for the @holder. | ||
1448 | */ | ||
1449 | struct block_device *open_bdev_exclusive(const char *path, fmode_t mode, void *holder) | ||
1450 | { | ||
1451 | struct block_device *bdev; | ||
1452 | int error; | ||
1453 | |||
1454 | bdev = lookup_bdev(path); | ||
1455 | if (IS_ERR(bdev)) | ||
1456 | return bdev; | ||
1457 | |||
1458 | error = blkdev_get(bdev, mode | FMODE_EXCL, holder); | ||
1459 | if (error) | ||
1460 | return ERR_PTR(error); | ||
1461 | |||
1462 | return bdev; | ||
1463 | } | ||
1464 | |||
1465 | EXPORT_SYMBOL(open_bdev_exclusive); | ||
1466 | |||
1467 | int __invalidate_device(struct block_device *bdev) | 1514 | int __invalidate_device(struct block_device *bdev) |
1468 | { | 1515 | { |
1469 | struct super_block *sb = get_super(bdev); | 1516 | struct super_block *sb = get_super(bdev); |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index f1b729d3b883..95324e9f9280 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -489,7 +489,7 @@ again: | |||
489 | continue; | 489 | continue; |
490 | 490 | ||
491 | if (device->bdev) { | 491 | if (device->bdev) { |
492 | blkdev_put(device->bdev, device->mode | FMODE_EXCL); | 492 | blkdev_put(device->bdev, device->mode); |
493 | device->bdev = NULL; | 493 | device->bdev = NULL; |
494 | fs_devices->open_devices--; | 494 | fs_devices->open_devices--; |
495 | } | 495 | } |
@@ -523,7 +523,7 @@ static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices) | |||
523 | 523 | ||
524 | list_for_each_entry(device, &fs_devices->devices, dev_list) { | 524 | list_for_each_entry(device, &fs_devices->devices, dev_list) { |
525 | if (device->bdev) { | 525 | if (device->bdev) { |
526 | blkdev_put(device->bdev, device->mode | FMODE_EXCL); | 526 | blkdev_put(device->bdev, device->mode); |
527 | fs_devices->open_devices--; | 527 | fs_devices->open_devices--; |
528 | } | 528 | } |
529 | if (device->writeable) { | 529 | if (device->writeable) { |
@@ -580,13 +580,15 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, | |||
580 | int seeding = 1; | 580 | int seeding = 1; |
581 | int ret = 0; | 581 | int ret = 0; |
582 | 582 | ||
583 | flags |= FMODE_EXCL; | ||
584 | |||
583 | list_for_each_entry(device, head, dev_list) { | 585 | list_for_each_entry(device, head, dev_list) { |
584 | if (device->bdev) | 586 | if (device->bdev) |
585 | continue; | 587 | continue; |
586 | if (!device->name) | 588 | if (!device->name) |
587 | continue; | 589 | continue; |
588 | 590 | ||
589 | bdev = open_bdev_exclusive(device->name, flags, holder); | 591 | bdev = blkdev_get_by_path(device->name, flags, holder); |
590 | if (IS_ERR(bdev)) { | 592 | if (IS_ERR(bdev)) { |
591 | printk(KERN_INFO "open %s failed\n", device->name); | 593 | printk(KERN_INFO "open %s failed\n", device->name); |
592 | goto error; | 594 | goto error; |
@@ -638,7 +640,7 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, | |||
638 | error_brelse: | 640 | error_brelse: |
639 | brelse(bh); | 641 | brelse(bh); |
640 | error_close: | 642 | error_close: |
641 | blkdev_put(bdev, flags | FMODE_EXCL); | 643 | blkdev_put(bdev, flags); |
642 | error: | 644 | error: |
643 | continue; | 645 | continue; |
644 | } | 646 | } |
@@ -684,7 +686,8 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, | |||
684 | 686 | ||
685 | mutex_lock(&uuid_mutex); | 687 | mutex_lock(&uuid_mutex); |
686 | 688 | ||
687 | bdev = open_bdev_exclusive(path, flags, holder); | 689 | flags |= FMODE_EXCL; |
690 | bdev = blkdev_get_by_path(path, flags, holder); | ||
688 | 691 | ||
689 | if (IS_ERR(bdev)) { | 692 | if (IS_ERR(bdev)) { |
690 | ret = PTR_ERR(bdev); | 693 | ret = PTR_ERR(bdev); |
@@ -716,7 +719,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, | |||
716 | 719 | ||
717 | brelse(bh); | 720 | brelse(bh); |
718 | error_close: | 721 | error_close: |
719 | blkdev_put(bdev, flags | FMODE_EXCL); | 722 | blkdev_put(bdev, flags); |
720 | error: | 723 | error: |
721 | mutex_unlock(&uuid_mutex); | 724 | mutex_unlock(&uuid_mutex); |
722 | return ret; | 725 | return ret; |
@@ -1179,8 +1182,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1179 | goto out; | 1182 | goto out; |
1180 | } | 1183 | } |
1181 | } else { | 1184 | } else { |
1182 | bdev = open_bdev_exclusive(device_path, FMODE_READ, | 1185 | bdev = blkdev_get_by_path(device_path, FMODE_READ | FMODE_EXCL, |
1183 | root->fs_info->bdev_holder); | 1186 | root->fs_info->bdev_holder); |
1184 | if (IS_ERR(bdev)) { | 1187 | if (IS_ERR(bdev)) { |
1185 | ret = PTR_ERR(bdev); | 1188 | ret = PTR_ERR(bdev); |
1186 | goto out; | 1189 | goto out; |
@@ -1244,7 +1247,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1244 | root->fs_info->fs_devices->latest_bdev = next_device->bdev; | 1247 | root->fs_info->fs_devices->latest_bdev = next_device->bdev; |
1245 | 1248 | ||
1246 | if (device->bdev) { | 1249 | if (device->bdev) { |
1247 | blkdev_put(device->bdev, device->mode | FMODE_EXCL); | 1250 | blkdev_put(device->bdev, device->mode); |
1248 | device->bdev = NULL; | 1251 | device->bdev = NULL; |
1249 | device->fs_devices->open_devices--; | 1252 | device->fs_devices->open_devices--; |
1250 | } | 1253 | } |
@@ -1439,7 +1442,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
1439 | if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding) | 1442 | if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding) |
1440 | return -EINVAL; | 1443 | return -EINVAL; |
1441 | 1444 | ||
1442 | bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder); | 1445 | bdev = blkdev_get_by_path(device_path, FMODE_EXCL, |
1446 | root->fs_info->bdev_holder); | ||
1443 | if (IS_ERR(bdev)) | 1447 | if (IS_ERR(bdev)) |
1444 | return PTR_ERR(bdev); | 1448 | return PTR_ERR(bdev); |
1445 | 1449 | ||
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 2b638b6e4eea..856e75770304 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h | |||
@@ -49,7 +49,7 @@ struct btrfs_device { | |||
49 | 49 | ||
50 | struct block_device *bdev; | 50 | struct block_device *bdev; |
51 | 51 | ||
52 | /* the mode sent to open_bdev_exclusive */ | 52 | /* the mode sent to blkdev_get */ |
53 | fmode_t mode; | 53 | fmode_t mode; |
54 | 54 | ||
55 | char *name; | 55 | char *name; |
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 23e7513dba9c..123720ba786d 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -347,7 +347,7 @@ static struct block_device *ext3_blkdev_get(dev_t dev, struct super_block *sb) | |||
347 | struct block_device *bdev; | 347 | struct block_device *bdev; |
348 | char b[BDEVNAME_SIZE]; | 348 | char b[BDEVNAME_SIZE]; |
349 | 349 | ||
350 | bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb); | 350 | bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb); |
351 | if (IS_ERR(bdev)) | 351 | if (IS_ERR(bdev)) |
352 | goto fail; | 352 | goto fail; |
353 | return bdev; | 353 | return bdev; |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 5dd0b3e76fa8..bd63e6927219 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -647,7 +647,7 @@ static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb) | |||
647 | struct block_device *bdev; | 647 | struct block_device *bdev; |
648 | char b[BDEVNAME_SIZE]; | 648 | char b[BDEVNAME_SIZE]; |
649 | 649 | ||
650 | bdev = open_by_devnum(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb); | 650 | bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb); |
651 | if (IS_ERR(bdev)) | 651 | if (IS_ERR(bdev)) |
652 | goto fail; | 652 | goto fail; |
653 | return bdev; | 653 | return bdev; |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index c1f0763a022b..bc56ccf98ffd 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -1268,7 +1268,7 @@ static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, | |||
1268 | { | 1268 | { |
1269 | struct block_device *bdev; | 1269 | struct block_device *bdev; |
1270 | struct super_block *s; | 1270 | struct super_block *s; |
1271 | fmode_t mode = FMODE_READ; | 1271 | fmode_t mode = FMODE_READ | FMODE_EXCL; |
1272 | int error; | 1272 | int error; |
1273 | struct gfs2_args args; | 1273 | struct gfs2_args args; |
1274 | struct gfs2_sbd *sdp; | 1274 | struct gfs2_sbd *sdp; |
@@ -1276,7 +1276,7 @@ static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, | |||
1276 | if (!(flags & MS_RDONLY)) | 1276 | if (!(flags & MS_RDONLY)) |
1277 | mode |= FMODE_WRITE; | 1277 | mode |= FMODE_WRITE; |
1278 | 1278 | ||
1279 | bdev = open_bdev_exclusive(dev_name, mode, fs_type); | 1279 | bdev = blkdev_get_by_path(dev_name, mode, fs_type); |
1280 | if (IS_ERR(bdev)) | 1280 | if (IS_ERR(bdev)) |
1281 | return ERR_CAST(bdev); | 1281 | return ERR_CAST(bdev); |
1282 | 1282 | ||
@@ -1298,7 +1298,7 @@ static struct dentry *gfs2_mount(struct file_system_type *fs_type, int flags, | |||
1298 | goto error_bdev; | 1298 | goto error_bdev; |
1299 | 1299 | ||
1300 | if (s->s_root) | 1300 | if (s->s_root) |
1301 | blkdev_put(bdev, mode | FMODE_EXCL); | 1301 | blkdev_put(bdev, mode); |
1302 | 1302 | ||
1303 | memset(&args, 0, sizeof(args)); | 1303 | memset(&args, 0, sizeof(args)); |
1304 | args.ar_quota = GFS2_QUOTA_DEFAULT; | 1304 | args.ar_quota = GFS2_QUOTA_DEFAULT; |
@@ -1342,7 +1342,7 @@ error_super: | |||
1342 | deactivate_locked_super(s); | 1342 | deactivate_locked_super(s); |
1343 | return ERR_PTR(error); | 1343 | return ERR_PTR(error); |
1344 | error_bdev: | 1344 | error_bdev: |
1345 | blkdev_put(bdev, mode | FMODE_EXCL); | 1345 | blkdev_put(bdev, mode); |
1346 | return ERR_PTR(error); | 1346 | return ERR_PTR(error); |
1347 | } | 1347 | } |
1348 | 1348 | ||
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c index 5a290f22dcc3..278e3fb40b71 100644 --- a/fs/jfs/jfs_logmgr.c +++ b/fs/jfs/jfs_logmgr.c | |||
@@ -1120,8 +1120,8 @@ int lmLogOpen(struct super_block *sb) | |||
1120 | * file systems to log may have n-to-1 relationship; | 1120 | * file systems to log may have n-to-1 relationship; |
1121 | */ | 1121 | */ |
1122 | 1122 | ||
1123 | bdev = open_by_devnum(sbi->logdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, | 1123 | bdev = blkdev_get_by_dev(sbi->logdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, |
1124 | log); | 1124 | log); |
1125 | if (IS_ERR(bdev)) { | 1125 | if (IS_ERR(bdev)) { |
1126 | rc = -PTR_ERR(bdev); | 1126 | rc = -PTR_ERR(bdev); |
1127 | goto free; | 1127 | goto free; |
diff --git a/fs/logfs/dev_bdev.c b/fs/logfs/dev_bdev.c index 734b9025858e..723bc5bca09a 100644 --- a/fs/logfs/dev_bdev.c +++ b/fs/logfs/dev_bdev.c | |||
@@ -325,7 +325,8 @@ int logfs_get_sb_bdev(struct logfs_super *p, struct file_system_type *type, | |||
325 | { | 325 | { |
326 | struct block_device *bdev; | 326 | struct block_device *bdev; |
327 | 327 | ||
328 | bdev = open_bdev_exclusive(devname, FMODE_READ|FMODE_WRITE, type); | 328 | bdev = blkdev_get_by_path(devname, FMODE_READ|FMODE_WRITE|FMODE_EXCL, |
329 | type); | ||
329 | if (IS_ERR(bdev)) | 330 | if (IS_ERR(bdev)) |
330 | return PTR_ERR(bdev); | 331 | return PTR_ERR(bdev); |
331 | 332 | ||
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 756a6798d7c8..0030640e2d72 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
@@ -1147,14 +1147,14 @@ nilfs_mount(struct file_system_type *fs_type, int flags, | |||
1147 | { | 1147 | { |
1148 | struct nilfs_super_data sd; | 1148 | struct nilfs_super_data sd; |
1149 | struct super_block *s; | 1149 | struct super_block *s; |
1150 | fmode_t mode = FMODE_READ; | 1150 | fmode_t mode = FMODE_READ | FMODE_EXCL; |
1151 | struct dentry *root_dentry; | 1151 | struct dentry *root_dentry; |
1152 | int err, s_new = false; | 1152 | int err, s_new = false; |
1153 | 1153 | ||
1154 | if (!(flags & MS_RDONLY)) | 1154 | if (!(flags & MS_RDONLY)) |
1155 | mode |= FMODE_WRITE; | 1155 | mode |= FMODE_WRITE; |
1156 | 1156 | ||
1157 | sd.bdev = open_bdev_exclusive(dev_name, mode, fs_type); | 1157 | sd.bdev = blkdev_get_by_path(dev_name, mode, fs_type); |
1158 | if (IS_ERR(sd.bdev)) | 1158 | if (IS_ERR(sd.bdev)) |
1159 | return ERR_CAST(sd.bdev); | 1159 | return ERR_CAST(sd.bdev); |
1160 | 1160 | ||
@@ -1233,7 +1233,7 @@ nilfs_mount(struct file_system_type *fs_type, int flags, | |||
1233 | } | 1233 | } |
1234 | 1234 | ||
1235 | if (!s_new) | 1235 | if (!s_new) |
1236 | blkdev_put(sd.bdev, mode | FMODE_EXCL); | 1236 | blkdev_put(sd.bdev, mode); |
1237 | 1237 | ||
1238 | return root_dentry; | 1238 | return root_dentry; |
1239 | 1239 | ||
@@ -1242,7 +1242,7 @@ nilfs_mount(struct file_system_type *fs_type, int flags, | |||
1242 | 1242 | ||
1243 | failed: | 1243 | failed: |
1244 | if (!s_new) | 1244 | if (!s_new) |
1245 | blkdev_put(sd.bdev, mode | FMODE_EXCL); | 1245 | blkdev_put(sd.bdev, mode); |
1246 | return ERR_PTR(err); | 1246 | return ERR_PTR(err); |
1247 | } | 1247 | } |
1248 | 1248 | ||
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index b488136f5ace..e2fce519c0f2 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
@@ -2585,7 +2585,8 @@ static int journal_init_dev(struct super_block *super, | |||
2585 | if ((!jdev_name || !jdev_name[0])) { | 2585 | if ((!jdev_name || !jdev_name[0])) { |
2586 | if (jdev == super->s_dev) | 2586 | if (jdev == super->s_dev) |
2587 | blkdev_mode &= ~FMODE_EXCL; | 2587 | blkdev_mode &= ~FMODE_EXCL; |
2588 | journal->j_dev_bd = open_by_devnum(jdev, blkdev_mode, journal); | 2588 | journal->j_dev_bd = blkdev_get_by_dev(jdev, blkdev_mode, |
2589 | journal); | ||
2589 | journal->j_dev_mode = blkdev_mode; | 2590 | journal->j_dev_mode = blkdev_mode; |
2590 | if (IS_ERR(journal->j_dev_bd)) { | 2591 | if (IS_ERR(journal->j_dev_bd)) { |
2591 | result = PTR_ERR(journal->j_dev_bd); | 2592 | result = PTR_ERR(journal->j_dev_bd); |
@@ -2601,8 +2602,7 @@ static int journal_init_dev(struct super_block *super, | |||
2601 | } | 2602 | } |
2602 | 2603 | ||
2603 | journal->j_dev_mode = blkdev_mode; | 2604 | journal->j_dev_mode = blkdev_mode; |
2604 | journal->j_dev_bd = open_bdev_exclusive(jdev_name, | 2605 | journal->j_dev_bd = blkdev_get_by_path(jdev_name, blkdev_mode, journal); |
2605 | blkdev_mode, journal); | ||
2606 | if (IS_ERR(journal->j_dev_bd)) { | 2606 | if (IS_ERR(journal->j_dev_bd)) { |
2607 | result = PTR_ERR(journal->j_dev_bd); | 2607 | result = PTR_ERR(journal->j_dev_bd); |
2608 | journal->j_dev_bd = NULL; | 2608 | journal->j_dev_bd = NULL; |
diff --git a/fs/super.c b/fs/super.c index 22374bf0ba87..5d9a4497849a 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -766,13 +766,13 @@ struct dentry *mount_bdev(struct file_system_type *fs_type, | |||
766 | { | 766 | { |
767 | struct block_device *bdev; | 767 | struct block_device *bdev; |
768 | struct super_block *s; | 768 | struct super_block *s; |
769 | fmode_t mode = FMODE_READ; | 769 | fmode_t mode = FMODE_READ | FMODE_EXCL; |
770 | int error = 0; | 770 | int error = 0; |
771 | 771 | ||
772 | if (!(flags & MS_RDONLY)) | 772 | if (!(flags & MS_RDONLY)) |
773 | mode |= FMODE_WRITE; | 773 | mode |= FMODE_WRITE; |
774 | 774 | ||
775 | bdev = open_bdev_exclusive(dev_name, mode, fs_type); | 775 | bdev = blkdev_get_by_path(dev_name, mode, fs_type); |
776 | if (IS_ERR(bdev)) | 776 | if (IS_ERR(bdev)) |
777 | return ERR_CAST(bdev); | 777 | return ERR_CAST(bdev); |
778 | 778 | ||
@@ -807,7 +807,7 @@ struct dentry *mount_bdev(struct file_system_type *fs_type, | |||
807 | * holding an active reference. | 807 | * holding an active reference. |
808 | */ | 808 | */ |
809 | up_write(&s->s_umount); | 809 | up_write(&s->s_umount); |
810 | blkdev_put(bdev, mode | FMODE_EXCL); | 810 | blkdev_put(bdev, mode); |
811 | down_write(&s->s_umount); | 811 | down_write(&s->s_umount); |
812 | } else { | 812 | } else { |
813 | char b[BDEVNAME_SIZE]; | 813 | char b[BDEVNAME_SIZE]; |
@@ -831,7 +831,7 @@ struct dentry *mount_bdev(struct file_system_type *fs_type, | |||
831 | error_s: | 831 | error_s: |
832 | error = PTR_ERR(s); | 832 | error = PTR_ERR(s); |
833 | error_bdev: | 833 | error_bdev: |
834 | blkdev_put(bdev, mode | FMODE_EXCL); | 834 | blkdev_put(bdev, mode); |
835 | error: | 835 | error: |
836 | return ERR_PTR(error); | 836 | return ERR_PTR(error); |
837 | } | 837 | } |
@@ -862,6 +862,7 @@ void kill_block_super(struct super_block *sb) | |||
862 | bdev->bd_super = NULL; | 862 | bdev->bd_super = NULL; |
863 | generic_shutdown_super(sb); | 863 | generic_shutdown_super(sb); |
864 | sync_blockdev(bdev); | 864 | sync_blockdev(bdev); |
865 | WARN_ON_ONCE(!(mode & FMODE_EXCL)); | ||
865 | blkdev_put(bdev, mode | FMODE_EXCL); | 866 | blkdev_put(bdev, mode | FMODE_EXCL); |
866 | } | 867 | } |
867 | 868 | ||
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index a1a6e5ceea67..9209cd199c47 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -609,7 +609,8 @@ xfs_blkdev_get( | |||
609 | { | 609 | { |
610 | int error = 0; | 610 | int error = 0; |
611 | 611 | ||
612 | *bdevp = open_bdev_exclusive(name, FMODE_READ|FMODE_WRITE, mp); | 612 | *bdevp = blkdev_get_by_path(name, FMODE_READ|FMODE_WRITE|FMODE_EXCL, |
613 | mp); | ||
613 | if (IS_ERR(*bdevp)) { | 614 | if (IS_ERR(*bdevp)) { |
614 | error = PTR_ERR(*bdevp); | 615 | error = PTR_ERR(*bdevp); |
615 | printk("XFS: Invalid device [%s], error=%d\n", name, error); | 616 | printk("XFS: Invalid device [%s], error=%d\n", name, error); |