diff options
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/volumes.c | 28 | ||||
-rw-r--r-- | fs/btrfs/volumes.h | 2 |
2 files changed, 17 insertions, 13 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, | |||
642 | error_brelse: | 644 | error_brelse: |
643 | brelse(bh); | 645 | brelse(bh); |
644 | error_close: | 646 | error_close: |
645 | close_bdev_exclusive(bdev, FMODE_READ); | 647 | blkdev_put(bdev, flags); |
646 | error: | 648 | error: |
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); |
722 | error_close: | 725 | error_close: |
723 | close_bdev_exclusive(bdev, flags); | 726 | blkdev_put(bdev, flags); |
724 | error: | 727 | error: |
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); |
1295 | error_close: | 1298 | error_close: |
1296 | if (bdev) | 1299 | if (bdev) |
1297 | close_bdev_exclusive(bdev, FMODE_READ); | 1300 | blkdev_put(bdev, FMODE_READ | FMODE_EXCL); |
1298 | out: | 1301 | out: |
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; |
1574 | error: | 1578 | error: |
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); |
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 2740db49eb04..1be781079450 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h | |||
@@ -50,7 +50,7 @@ struct btrfs_device { | |||
50 | 50 | ||
51 | struct block_device *bdev; | 51 | struct block_device *bdev; |
52 | 52 | ||
53 | /* the mode sent to open_bdev_exclusive */ | 53 | /* the mode sent to blkdev_get */ |
54 | fmode_t mode; | 54 | fmode_t mode; |
55 | 55 | ||
56 | char *name; | 56 | char *name; |