diff options
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 41ecbb2347f2..9df8e3f1ccab 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -256,13 +256,13 @@ loop_lock: | |||
256 | wake_up(&fs_info->async_submit_wait); | 256 | wake_up(&fs_info->async_submit_wait); |
257 | 257 | ||
258 | BUG_ON(atomic_read(&cur->bi_cnt) == 0); | 258 | BUG_ON(atomic_read(&cur->bi_cnt) == 0); |
259 | submit_bio(cur->bi_rw, cur); | ||
260 | num_run++; | ||
261 | batch_run++; | ||
262 | 259 | ||
263 | if (bio_rw_flagged(cur, BIO_RW_SYNCIO)) | 260 | if (bio_rw_flagged(cur, BIO_RW_SYNCIO)) |
264 | num_sync_run++; | 261 | num_sync_run++; |
265 | 262 | ||
263 | submit_bio(cur->bi_rw, cur); | ||
264 | num_run++; | ||
265 | batch_run++; | ||
266 | if (need_resched()) { | 266 | if (need_resched()) { |
267 | if (num_sync_run) { | 267 | if (num_sync_run) { |
268 | blk_run_backing_dev(bdi, NULL); | 268 | blk_run_backing_dev(bdi, NULL); |
@@ -325,16 +325,6 @@ loop_lock: | |||
325 | num_sync_run = 0; | 325 | num_sync_run = 0; |
326 | blk_run_backing_dev(bdi, NULL); | 326 | blk_run_backing_dev(bdi, NULL); |
327 | } | 327 | } |
328 | |||
329 | cond_resched(); | ||
330 | if (again) | ||
331 | goto loop; | ||
332 | |||
333 | spin_lock(&device->io_lock); | ||
334 | if (device->pending_bios.head || device->pending_sync_bios.head) | ||
335 | goto loop_lock; | ||
336 | spin_unlock(&device->io_lock); | ||
337 | |||
338 | /* | 328 | /* |
339 | * IO has already been through a long path to get here. Checksumming, | 329 | * IO has already been through a long path to get here. Checksumming, |
340 | * async helper threads, perhaps compression. We've done a pretty | 330 | * async helper threads, perhaps compression. We've done a pretty |
@@ -346,6 +336,16 @@ loop_lock: | |||
346 | * cared about found its way down here. | 336 | * cared about found its way down here. |
347 | */ | 337 | */ |
348 | blk_run_backing_dev(bdi, NULL); | 338 | blk_run_backing_dev(bdi, NULL); |
339 | |||
340 | cond_resched(); | ||
341 | if (again) | ||
342 | goto loop; | ||
343 | |||
344 | spin_lock(&device->io_lock); | ||
345 | if (device->pending_bios.head || device->pending_sync_bios.head) | ||
346 | goto loop_lock; | ||
347 | spin_unlock(&device->io_lock); | ||
348 | |||
349 | done: | 349 | done: |
350 | return 0; | 350 | return 0; |
351 | } | 351 | } |
@@ -365,6 +365,7 @@ static noinline int device_list_add(const char *path, | |||
365 | struct btrfs_device *device; | 365 | struct btrfs_device *device; |
366 | struct btrfs_fs_devices *fs_devices; | 366 | struct btrfs_fs_devices *fs_devices; |
367 | u64 found_transid = btrfs_super_generation(disk_super); | 367 | u64 found_transid = btrfs_super_generation(disk_super); |
368 | char *name; | ||
368 | 369 | ||
369 | fs_devices = find_fsid(disk_super->fsid); | 370 | fs_devices = find_fsid(disk_super->fsid); |
370 | if (!fs_devices) { | 371 | if (!fs_devices) { |
@@ -411,6 +412,12 @@ static noinline int device_list_add(const char *path, | |||
411 | 412 | ||
412 | device->fs_devices = fs_devices; | 413 | device->fs_devices = fs_devices; |
413 | fs_devices->num_devices++; | 414 | fs_devices->num_devices++; |
415 | } else if (strcmp(device->name, path)) { | ||
416 | name = kstrdup(path, GFP_NOFS); | ||
417 | if (!name) | ||
418 | return -ENOMEM; | ||
419 | kfree(device->name); | ||
420 | device->name = name; | ||
414 | } | 421 | } |
415 | 422 | ||
416 | if (found_transid > fs_devices->latest_trans) { | 423 | if (found_transid > fs_devices->latest_trans) { |
@@ -592,7 +599,7 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, | |||
592 | goto error_close; | 599 | goto error_close; |
593 | 600 | ||
594 | disk_super = (struct btrfs_super_block *)bh->b_data; | 601 | disk_super = (struct btrfs_super_block *)bh->b_data; |
595 | devid = le64_to_cpu(disk_super->dev_item.devid); | 602 | devid = btrfs_stack_device_id(&disk_super->dev_item); |
596 | if (devid != device->devid) | 603 | if (devid != device->devid) |
597 | goto error_brelse; | 604 | goto error_brelse; |
598 | 605 | ||
@@ -694,7 +701,7 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder, | |||
694 | goto error_close; | 701 | goto error_close; |
695 | } | 702 | } |
696 | disk_super = (struct btrfs_super_block *)bh->b_data; | 703 | disk_super = (struct btrfs_super_block *)bh->b_data; |
697 | devid = le64_to_cpu(disk_super->dev_item.devid); | 704 | devid = btrfs_stack_device_id(&disk_super->dev_item); |
698 | transid = btrfs_super_generation(disk_super); | 705 | transid = btrfs_super_generation(disk_super); |
699 | if (disk_super->label[0]) | 706 | if (disk_super->label[0]) |
700 | printk(KERN_INFO "device label %s ", disk_super->label); | 707 | printk(KERN_INFO "device label %s ", disk_super->label); |
@@ -1187,7 +1194,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
1187 | goto error_close; | 1194 | goto error_close; |
1188 | } | 1195 | } |
1189 | disk_super = (struct btrfs_super_block *)bh->b_data; | 1196 | disk_super = (struct btrfs_super_block *)bh->b_data; |
1190 | devid = le64_to_cpu(disk_super->dev_item.devid); | 1197 | devid = btrfs_stack_device_id(&disk_super->dev_item); |
1191 | dev_uuid = disk_super->dev_item.uuid; | 1198 | dev_uuid = disk_super->dev_item.uuid; |
1192 | device = btrfs_find_device(root, devid, dev_uuid, | 1199 | device = btrfs_find_device(root, devid, dev_uuid, |
1193 | disk_super->fsid); | 1200 | disk_super->fsid); |