aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-11-19 21:17:22 -0500
committerChris Mason <chris.mason@oracle.com>2008-11-19 21:17:22 -0500
commit15916de835a683bd8133a0d1ac0c982b795ab4ff (patch)
tree20603c2e0cade00d2e40a3b5390f5def36a02711 /fs/btrfs/volumes.c
parentae20a6afec1cf21919d97303f2d8b737eac5acc7 (diff)
Btrfs: Fixes for 2.6.28-rc API changes
* open/close_bdev_excl -> open/close_bdev_exclusive * blkdev_issue_discard takes a GFP mask now * Fix blkdev_issue_discard usage now that it is enabled Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ecf0633ab8cc..c3ee63f92a5f 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -85,7 +85,7 @@ int btrfs_cleanup_fs_uuids(void)
85 dev = list_entry(fs_devices->devices.next, 85 dev = list_entry(fs_devices->devices.next,
86 struct btrfs_device, dev_list); 86 struct btrfs_device, dev_list);
87 if (dev->bdev) { 87 if (dev->bdev) {
88 close_bdev_excl(dev->bdev); 88 close_bdev_exclusive(dev->bdev, dev->mode);
89 fs_devices->open_devices--; 89 fs_devices->open_devices--;
90 } 90 }
91 fs_devices->num_devices--; 91 fs_devices->num_devices--;
@@ -317,7 +317,7 @@ again:
317 continue; 317 continue;
318 318
319 if (device->bdev) { 319 if (device->bdev) {
320 close_bdev_excl(device->bdev); 320 close_bdev_exclusive(device->bdev, device->mode);
321 device->bdev = NULL; 321 device->bdev = NULL;
322 fs_devices->open_devices--; 322 fs_devices->open_devices--;
323 } 323 }
@@ -356,7 +356,7 @@ again:
356 list_for_each(cur, &fs_devices->devices) { 356 list_for_each(cur, &fs_devices->devices) {
357 device = list_entry(cur, struct btrfs_device, dev_list); 357 device = list_entry(cur, struct btrfs_device, dev_list);
358 if (device->bdev) { 358 if (device->bdev) {
359 close_bdev_excl(device->bdev); 359 close_bdev_exclusive(device->bdev, device->mode);
360 fs_devices->open_devices--; 360 fs_devices->open_devices--;
361 } 361 }
362 if (device->writeable) { 362 if (device->writeable) {
@@ -391,7 +391,8 @@ int btrfs_close_devices(struct btrfs_fs_devices *fs_devices)
391 return ret; 391 return ret;
392} 392}
393 393
394int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder) 394int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
395 int flags, void *holder)
395{ 396{
396 struct block_device *bdev; 397 struct block_device *bdev;
397 struct list_head *head = &fs_devices->devices; 398 struct list_head *head = &fs_devices->devices;
@@ -413,7 +414,7 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder)
413 if (!device->name) 414 if (!device->name)
414 continue; 415 continue;
415 416
416 bdev = open_bdev_excl(device->name, MS_RDONLY, holder); 417 bdev = open_bdev_exclusive(device->name, flags, holder);
417 if (IS_ERR(bdev)) { 418 if (IS_ERR(bdev)) {
418 printk("open %s failed\n", device->name); 419 printk("open %s failed\n", device->name);
419 goto error; 420 goto error;
@@ -453,6 +454,8 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder)
453 454
454 device->bdev = bdev; 455 device->bdev = bdev;
455 device->in_fs_metadata = 0; 456 device->in_fs_metadata = 0;
457 device->mode = flags;
458
456 fs_devices->open_devices++; 459 fs_devices->open_devices++;
457 if (device->writeable) { 460 if (device->writeable) {
458 fs_devices->rw_devices++; 461 fs_devices->rw_devices++;
@@ -464,7 +467,7 @@ int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, void *holder)
464error_brelse: 467error_brelse:
465 brelse(bh); 468 brelse(bh);
466error_close: 469error_close:
467 close_bdev_excl(bdev); 470 close_bdev_exclusive(bdev, MS_RDONLY);
468error: 471error:
469 continue; 472 continue;
470 } 473 }
@@ -496,7 +499,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
496 ret = 0; 499 ret = 0;
497 } 500 }
498 } else { 501 } else {
499 ret = __btrfs_open_devices(fs_devices, holder); 502 ret = __btrfs_open_devices(fs_devices, flags, holder);
500 } 503 }
501 mutex_unlock(&uuid_mutex); 504 mutex_unlock(&uuid_mutex);
502 return ret; 505 return ret;
@@ -514,7 +517,7 @@ int btrfs_scan_one_device(const char *path, int flags, void *holder,
514 517
515 mutex_lock(&uuid_mutex); 518 mutex_lock(&uuid_mutex);
516 519
517 bdev = open_bdev_excl(path, flags, holder); 520 bdev = open_bdev_exclusive(path, flags, holder);
518 521
519 if (IS_ERR(bdev)) { 522 if (IS_ERR(bdev)) {
520 ret = PTR_ERR(bdev); 523 ret = PTR_ERR(bdev);
@@ -551,7 +554,7 @@ int btrfs_scan_one_device(const char *path, int flags, void *holder,
551error_brelse: 554error_brelse:
552 brelse(bh); 555 brelse(bh);
553error_close: 556error_close:
554 close_bdev_excl(bdev); 557 close_bdev_exclusive(bdev, flags);
555error: 558error:
556 mutex_unlock(&uuid_mutex); 559 mutex_unlock(&uuid_mutex);
557 return ret; 560 return ret;
@@ -1003,7 +1006,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
1003 goto out; 1006 goto out;
1004 } 1007 }
1005 } else { 1008 } else {
1006 bdev = open_bdev_excl(device_path, MS_RDONLY, 1009 bdev = open_bdev_exclusive(device_path, MS_RDONLY,
1007 root->fs_info->bdev_holder); 1010 root->fs_info->bdev_holder);
1008 if (IS_ERR(bdev)) { 1011 if (IS_ERR(bdev)) {
1009 ret = PTR_ERR(bdev); 1012 ret = PTR_ERR(bdev);
@@ -1073,10 +1076,10 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
1073 BUG_ON(device->writeable); 1076 BUG_ON(device->writeable);
1074 brelse(bh); 1077 brelse(bh);
1075 if (bdev) 1078 if (bdev)
1076 close_bdev_excl(bdev); 1079 close_bdev_exclusive(bdev, MS_RDONLY);
1077 1080
1078 if (device->bdev) { 1081 if (device->bdev) {
1079 close_bdev_excl(device->bdev); 1082 close_bdev_exclusive(device->bdev, device->mode);
1080 device->bdev = NULL; 1083 device->bdev = NULL;
1081 device->fs_devices->open_devices--; 1084 device->fs_devices->open_devices--;
1082 } 1085 }
@@ -1112,11 +1115,11 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
1112 1115
1113 if (device->bdev) { 1116 if (device->bdev) {
1114 /* one close for the device struct or super_block */ 1117 /* one close for the device struct or super_block */
1115 close_bdev_excl(device->bdev); 1118 close_bdev_exclusive(device->bdev, device->mode);
1116 } 1119 }
1117 if (bdev) { 1120 if (bdev) {
1118 /* one close for us */ 1121 /* one close for us */
1119 close_bdev_excl(bdev); 1122 close_bdev_exclusive(bdev, MS_RDONLY);
1120 } 1123 }
1121 kfree(device->name); 1124 kfree(device->name);
1122 kfree(device); 1125 kfree(device);
@@ -1127,7 +1130,7 @@ error_brelse:
1127 brelse(bh); 1130 brelse(bh);
1128error_close: 1131error_close:
1129 if (bdev) 1132 if (bdev)
1130 close_bdev_excl(bdev); 1133 close_bdev_exclusive(bdev, MS_RDONLY);
1131out: 1134out:
1132 mutex_unlock(&root->fs_info->volume_mutex); 1135 mutex_unlock(&root->fs_info->volume_mutex);
1133 mutex_unlock(&uuid_mutex); 1136 mutex_unlock(&uuid_mutex);
@@ -1272,7 +1275,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
1272 if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding) 1275 if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding)
1273 return -EINVAL; 1276 return -EINVAL;
1274 1277
1275 bdev = open_bdev_excl(device_path, 0, root->fs_info->bdev_holder); 1278 bdev = open_bdev_exclusive(device_path, 0, root->fs_info->bdev_holder);
1276 if (!bdev) { 1279 if (!bdev) {
1277 return -EIO; 1280 return -EIO;
1278 } 1281 }
@@ -1331,6 +1334,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
1331 device->dev_root = root->fs_info->dev_root; 1334 device->dev_root = root->fs_info->dev_root;
1332 device->bdev = bdev; 1335 device->bdev = bdev;
1333 device->in_fs_metadata = 1; 1336 device->in_fs_metadata = 1;
1337 device->mode = 0;
1334 set_blocksize(device->bdev, 4096); 1338 set_blocksize(device->bdev, 4096);
1335 1339
1336 if (seeding_dev) { 1340 if (seeding_dev) {
@@ -1379,7 +1383,7 @@ out:
1379 mutex_unlock(&root->fs_info->volume_mutex); 1383 mutex_unlock(&root->fs_info->volume_mutex);
1380 return ret; 1384 return ret;
1381error: 1385error:
1382 close_bdev_excl(bdev); 1386 close_bdev_exclusive(bdev, 0);
1383 if (seeding_dev) { 1387 if (seeding_dev) {
1384 mutex_unlock(&uuid_mutex); 1388 mutex_unlock(&uuid_mutex);
1385 up_write(&sb->s_umount); 1389 up_write(&sb->s_umount);
@@ -2907,7 +2911,8 @@ static int open_seed_devices(struct btrfs_root *root, u8 *fsid)
2907 goto out; 2911 goto out;
2908 } 2912 }
2909 2913
2910 ret = __btrfs_open_devices(fs_devices, root->fs_info->bdev_holder); 2914 ret = __btrfs_open_devices(fs_devices, MS_RDONLY,
2915 root->fs_info->bdev_holder);
2911 if (ret) 2916 if (ret)
2912 goto out; 2917 goto out;
2913 2918