diff options
author | Jens Axboe <jaxboe@fusionio.com> | 2010-11-27 13:49:18 -0500 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-11-27 13:49:18 -0500 |
commit | f30195c50245d8ace628e1978b1daa8df86e7224 (patch) | |
tree | edf4f91c4356c41d50fb07f15cebd1e6442538ad /fs/btrfs/volumes.c | |
parent | d07335e51df0c6dec202d315fc4f1f7e100eec4e (diff) | |
parent | d4d77629953eabd3c14f6fa5746f6b28babfc55f (diff) |
Merge branch 'cleanup-bd_claim' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/misc into for-2.6.38/core
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index cc04dc1445d6..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 | close_bdev_exclusive(device->bdev, device->mode); | 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 | close_bdev_exclusive(device->bdev, device->mode); | 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 | close_bdev_exclusive(bdev, FMODE_READ); | 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 | close_bdev_exclusive(bdev, flags); | 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 | close_bdev_exclusive(device->bdev, device->mode); | 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 | } |
@@ -1287,7 +1290,7 @@ error_brelse: | |||
1287 | brelse(bh); | 1290 | brelse(bh); |
1288 | error_close: | 1291 | error_close: |
1289 | if (bdev) | 1292 | if (bdev) |
1290 | close_bdev_exclusive(bdev, FMODE_READ); | 1293 | blkdev_put(bdev, FMODE_READ | FMODE_EXCL); |
1291 | out: | 1294 | out: |
1292 | mutex_unlock(&root->fs_info->volume_mutex); | 1295 | mutex_unlock(&root->fs_info->volume_mutex); |
1293 | mutex_unlock(&uuid_mutex); | 1296 | mutex_unlock(&uuid_mutex); |
@@ -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 | ||
@@ -1565,7 +1569,7 @@ out: | |||
1565 | mutex_unlock(&root->fs_info->volume_mutex); | 1569 | mutex_unlock(&root->fs_info->volume_mutex); |
1566 | return ret; | 1570 | return ret; |
1567 | error: | 1571 | error: |
1568 | close_bdev_exclusive(bdev, 0); | 1572 | blkdev_put(bdev, FMODE_EXCL); |
1569 | if (seeding_dev) { | 1573 | if (seeding_dev) { |
1570 | mutex_unlock(&uuid_mutex); | 1574 | mutex_unlock(&uuid_mutex); |
1571 | up_write(&sb->s_umount); | 1575 | up_write(&sb->s_umount); |