aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 13:45:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 13:45:01 -0500
commit275220f0fcff1adf28a717076e00f575edf05fda (patch)
treed249bccc80c64443dab211639050c4fb14332648 /fs/btrfs/volumes.c
parentfe3c560b8a22cb28e54fe8950abef38e88d75831 (diff)
parent81c5e2ae33c4b19e53966b427e33646bf6811830 (diff)
Merge branch 'for-2.6.38/core' of git://git.kernel.dk/linux-2.6-block
* 'for-2.6.38/core' of git://git.kernel.dk/linux-2.6-block: (43 commits) block: ensure that completion error gets properly traced blktrace: add missing probe argument to block_bio_complete block cfq: don't use atomic_t for cfq_group block cfq: don't use atomic_t for cfq_queue block: trace event block fix unassigned field block: add internal hd part table references block: fix accounting bug on cross partition merges kref: add kref_test_and_get bio-integrity: mark kintegrityd_wq highpri and CPU intensive block: make kblockd_workqueue smarter Revert "sd: implement sd_check_events()" block: Clean up exit_io_context() source code. Fix compile warnings due to missing removal of a 'ret' variable fs/block: type signature of major_to_index(int) to major_to_index(unsigned) block: convert !IS_ERR(p) && p to !IS_ERR_NOR_NULL(p) cfq-iosched: don't check cfqg in choose_service_tree() fs/splice: Pull buf->ops->confirm() from splice_from_pipe actors cdrom: export cdrom_check_events() sd: implement sd_check_events() sr: implement sr_check_events() ...
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 6b9884507837..1718e1a5c320 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -493,7 +493,7 @@ again:
493 continue; 493 continue;
494 494
495 if (device->bdev) { 495 if (device->bdev) {
496 close_bdev_exclusive(device->bdev, device->mode); 496 blkdev_put(device->bdev, device->mode);
497 device->bdev = NULL; 497 device->bdev = NULL;
498 fs_devices->open_devices--; 498 fs_devices->open_devices--;
499 } 499 }
@@ -527,7 +527,7 @@ static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
527 527
528 list_for_each_entry(device, &fs_devices->devices, dev_list) { 528 list_for_each_entry(device, &fs_devices->devices, dev_list) {
529 if (device->bdev) { 529 if (device->bdev) {
530 close_bdev_exclusive(device->bdev, device->mode); 530 blkdev_put(device->bdev, device->mode);
531 fs_devices->open_devices--; 531 fs_devices->open_devices--;
532 } 532 }
533 if (device->writeable) { 533 if (device->writeable) {
@@ -584,13 +584,15 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
584 int seeding = 1; 584 int seeding = 1;
585 int ret = 0; 585 int ret = 0;
586 586
587 flags |= FMODE_EXCL;
588
587 list_for_each_entry(device, head, dev_list) { 589 list_for_each_entry(device, head, dev_list) {
588 if (device->bdev) 590 if (device->bdev)
589 continue; 591 continue;
590 if (!device->name) 592 if (!device->name)
591 continue; 593 continue;
592 594
593 bdev = open_bdev_exclusive(device->name, flags, holder); 595 bdev = blkdev_get_by_path(device->name, flags, holder);
594 if (IS_ERR(bdev)) { 596 if (IS_ERR(bdev)) {
595 printk(KERN_INFO "open %s failed\n", device->name); 597 printk(KERN_INFO "open %s failed\n", device->name);
596 goto error; 598 goto error;
@@ -642,7 +644,7 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
642error_brelse: 644error_brelse:
643 brelse(bh); 645 brelse(bh);
644error_close: 646error_close:
645 close_bdev_exclusive(bdev, FMODE_READ); 647 blkdev_put(bdev, flags);
646error: 648error:
647 continue; 649 continue;
648 } 650 }
@@ -688,7 +690,8 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
688 690
689 mutex_lock(&uuid_mutex); 691 mutex_lock(&uuid_mutex);
690 692
691 bdev = open_bdev_exclusive(path, flags, holder); 693 flags |= FMODE_EXCL;
694 bdev = blkdev_get_by_path(path, flags, holder);
692 695
693 if (IS_ERR(bdev)) { 696 if (IS_ERR(bdev)) {
694 ret = PTR_ERR(bdev); 697 ret = PTR_ERR(bdev);
@@ -720,7 +723,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
720 723
721 brelse(bh); 724 brelse(bh);
722error_close: 725error_close:
723 close_bdev_exclusive(bdev, flags); 726 blkdev_put(bdev, flags);
724error: 727error:
725 mutex_unlock(&uuid_mutex); 728 mutex_unlock(&uuid_mutex);
726 return ret; 729 return ret;
@@ -1183,8 +1186,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
1183 goto out; 1186 goto out;
1184 } 1187 }
1185 } else { 1188 } else {
1186 bdev = open_bdev_exclusive(device_path, FMODE_READ, 1189 bdev = blkdev_get_by_path(device_path, FMODE_READ | FMODE_EXCL,
1187 root->fs_info->bdev_holder); 1190 root->fs_info->bdev_holder);
1188 if (IS_ERR(bdev)) { 1191 if (IS_ERR(bdev)) {
1189 ret = PTR_ERR(bdev); 1192 ret = PTR_ERR(bdev);
1190 goto out; 1193 goto out;
@@ -1251,7 +1254,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
1251 root->fs_info->fs_devices->latest_bdev = next_device->bdev; 1254 root->fs_info->fs_devices->latest_bdev = next_device->bdev;
1252 1255
1253 if (device->bdev) { 1256 if (device->bdev) {
1254 close_bdev_exclusive(device->bdev, device->mode); 1257 blkdev_put(device->bdev, device->mode);
1255 device->bdev = NULL; 1258 device->bdev = NULL;
1256 device->fs_devices->open_devices--; 1259 device->fs_devices->open_devices--;
1257 } 1260 }
@@ -1294,7 +1297,7 @@ error_brelse:
1294 brelse(bh); 1297 brelse(bh);
1295error_close: 1298error_close:
1296 if (bdev) 1299 if (bdev)
1297 close_bdev_exclusive(bdev, FMODE_READ); 1300 blkdev_put(bdev, FMODE_READ | FMODE_EXCL);
1298out: 1301out:
1299 mutex_unlock(&root->fs_info->volume_mutex); 1302 mutex_unlock(&root->fs_info->volume_mutex);
1300 mutex_unlock(&uuid_mutex); 1303 mutex_unlock(&uuid_mutex);
@@ -1446,7 +1449,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
1446 if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding) 1449 if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding)
1447 return -EINVAL; 1450 return -EINVAL;
1448 1451
1449 bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder); 1452 bdev = blkdev_get_by_path(device_path, FMODE_EXCL,
1453 root->fs_info->bdev_holder);
1450 if (IS_ERR(bdev)) 1454 if (IS_ERR(bdev))
1451 return PTR_ERR(bdev); 1455 return PTR_ERR(bdev);
1452 1456
@@ -1572,7 +1576,7 @@ out:
1572 mutex_unlock(&root->fs_info->volume_mutex); 1576 mutex_unlock(&root->fs_info->volume_mutex);
1573 return ret; 1577 return ret;
1574error: 1578error:
1575 close_bdev_exclusive(bdev, 0); 1579 blkdev_put(bdev, FMODE_EXCL);
1576 if (seeding_dev) { 1580 if (seeding_dev) {
1577 mutex_unlock(&uuid_mutex); 1581 mutex_unlock(&uuid_mutex);
1578 up_write(&sb->s_umount); 1582 up_write(&sb->s_umount);