aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-11-13 05:55:18 -0500
committerTejun Heo <tj@kernel.org>2010-11-13 05:55:18 -0500
commitd4d77629953eabd3c14f6fa5746f6b28babfc55f (patch)
tree38cce0d4764ecb34a9f7f49332959780e28bb786 /fs/btrfs/volumes.c
parent75f1dc0d076d1c1168f2115f1941ea627d38bd5a (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/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c24
1 files changed, 14 insertions, 10 deletions
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,
638error_brelse: 640error_brelse:
639 brelse(bh); 641 brelse(bh);
640error_close: 642error_close:
641 blkdev_put(bdev, flags | FMODE_EXCL); 643 blkdev_put(bdev, flags);
642error: 644error:
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);
718error_close: 721error_close:
719 blkdev_put(bdev, flags | FMODE_EXCL); 722 blkdev_put(bdev, flags);
720error: 723error:
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