diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-05 15:17:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-05 15:17:24 -0400 |
commit | e62063d69911886a5a92c719d262a2a87e1e5b60 (patch) | |
tree | c72519e2092ccba257ab74318b21eb924a1ee9cf /fs | |
parent | 85f6d2dbfdc7e6c6ac955012c03ce31a8f947b94 (diff) | |
parent | b208c2f7ceafacbc44f13d1b5a9fbada98226183 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs fixes from Chris Mason:
"This is a small collection of fixes, including a regression fix from
Liu Bo that solves rare crashes with compression on.
I've merged my for-linus up to 3.12-rc3 because the top commit is only
meant for 3.12. The rest of the fixes are also available in my master
branch on top of my last 3.11 based pull"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
btrfs: Fix crash due to not allocating integrity data for a bioset
Btrfs: fix a use-after-free bug in btrfs_dev_replace_finishing
Btrfs: eliminate races in worker stopping code
Btrfs: fix crash of compressed writes
Btrfs: fix transid verify errors when recovering log tree
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/async-thread.c | 25 | ||||
-rw-r--r-- | fs/btrfs/async-thread.h | 2 | ||||
-rw-r--r-- | fs/btrfs/dev-replace.c | 5 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 10 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 7 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 7 |
6 files changed, 39 insertions, 17 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index 58b7d14b08ee..08cc08f037a6 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c | |||
@@ -107,7 +107,8 @@ static void check_idle_worker(struct btrfs_worker_thread *worker) | |||
107 | worker->idle = 1; | 107 | worker->idle = 1; |
108 | 108 | ||
109 | /* the list may be empty if the worker is just starting */ | 109 | /* the list may be empty if the worker is just starting */ |
110 | if (!list_empty(&worker->worker_list)) { | 110 | if (!list_empty(&worker->worker_list) && |
111 | !worker->workers->stopping) { | ||
111 | list_move(&worker->worker_list, | 112 | list_move(&worker->worker_list, |
112 | &worker->workers->idle_list); | 113 | &worker->workers->idle_list); |
113 | } | 114 | } |
@@ -127,7 +128,8 @@ static void check_busy_worker(struct btrfs_worker_thread *worker) | |||
127 | spin_lock_irqsave(&worker->workers->lock, flags); | 128 | spin_lock_irqsave(&worker->workers->lock, flags); |
128 | worker->idle = 0; | 129 | worker->idle = 0; |
129 | 130 | ||
130 | if (!list_empty(&worker->worker_list)) { | 131 | if (!list_empty(&worker->worker_list) && |
132 | !worker->workers->stopping) { | ||
131 | list_move_tail(&worker->worker_list, | 133 | list_move_tail(&worker->worker_list, |
132 | &worker->workers->worker_list); | 134 | &worker->workers->worker_list); |
133 | } | 135 | } |
@@ -412,6 +414,7 @@ void btrfs_stop_workers(struct btrfs_workers *workers) | |||
412 | int can_stop; | 414 | int can_stop; |
413 | 415 | ||
414 | spin_lock_irq(&workers->lock); | 416 | spin_lock_irq(&workers->lock); |
417 | workers->stopping = 1; | ||
415 | list_splice_init(&workers->idle_list, &workers->worker_list); | 418 | list_splice_init(&workers->idle_list, &workers->worker_list); |
416 | while (!list_empty(&workers->worker_list)) { | 419 | while (!list_empty(&workers->worker_list)) { |
417 | cur = workers->worker_list.next; | 420 | cur = workers->worker_list.next; |
@@ -455,6 +458,7 @@ void btrfs_init_workers(struct btrfs_workers *workers, char *name, int max, | |||
455 | workers->ordered = 0; | 458 | workers->ordered = 0; |
456 | workers->atomic_start_pending = 0; | 459 | workers->atomic_start_pending = 0; |
457 | workers->atomic_worker_start = async_helper; | 460 | workers->atomic_worker_start = async_helper; |
461 | workers->stopping = 0; | ||
458 | } | 462 | } |
459 | 463 | ||
460 | /* | 464 | /* |
@@ -480,15 +484,19 @@ static int __btrfs_start_workers(struct btrfs_workers *workers) | |||
480 | atomic_set(&worker->num_pending, 0); | 484 | atomic_set(&worker->num_pending, 0); |
481 | atomic_set(&worker->refs, 1); | 485 | atomic_set(&worker->refs, 1); |
482 | worker->workers = workers; | 486 | worker->workers = workers; |
483 | worker->task = kthread_run(worker_loop, worker, | 487 | worker->task = kthread_create(worker_loop, worker, |
484 | "btrfs-%s-%d", workers->name, | 488 | "btrfs-%s-%d", workers->name, |
485 | workers->num_workers + 1); | 489 | workers->num_workers + 1); |
486 | if (IS_ERR(worker->task)) { | 490 | if (IS_ERR(worker->task)) { |
487 | ret = PTR_ERR(worker->task); | 491 | ret = PTR_ERR(worker->task); |
488 | kfree(worker); | ||
489 | goto fail; | 492 | goto fail; |
490 | } | 493 | } |
494 | |||
491 | spin_lock_irq(&workers->lock); | 495 | spin_lock_irq(&workers->lock); |
496 | if (workers->stopping) { | ||
497 | spin_unlock_irq(&workers->lock); | ||
498 | goto fail_kthread; | ||
499 | } | ||
492 | list_add_tail(&worker->worker_list, &workers->idle_list); | 500 | list_add_tail(&worker->worker_list, &workers->idle_list); |
493 | worker->idle = 1; | 501 | worker->idle = 1; |
494 | workers->num_workers++; | 502 | workers->num_workers++; |
@@ -496,8 +504,13 @@ static int __btrfs_start_workers(struct btrfs_workers *workers) | |||
496 | WARN_ON(workers->num_workers_starting < 0); | 504 | WARN_ON(workers->num_workers_starting < 0); |
497 | spin_unlock_irq(&workers->lock); | 505 | spin_unlock_irq(&workers->lock); |
498 | 506 | ||
507 | wake_up_process(worker->task); | ||
499 | return 0; | 508 | return 0; |
509 | |||
510 | fail_kthread: | ||
511 | kthread_stop(worker->task); | ||
500 | fail: | 512 | fail: |
513 | kfree(worker); | ||
501 | spin_lock_irq(&workers->lock); | 514 | spin_lock_irq(&workers->lock); |
502 | workers->num_workers_starting--; | 515 | workers->num_workers_starting--; |
503 | spin_unlock_irq(&workers->lock); | 516 | spin_unlock_irq(&workers->lock); |
diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h index 063698b90ce2..1f26792683ed 100644 --- a/fs/btrfs/async-thread.h +++ b/fs/btrfs/async-thread.h | |||
@@ -107,6 +107,8 @@ struct btrfs_workers { | |||
107 | 107 | ||
108 | /* extra name for this worker, used for current->name */ | 108 | /* extra name for this worker, used for current->name */ |
109 | char *name; | 109 | char *name; |
110 | |||
111 | int stopping; | ||
110 | }; | 112 | }; |
111 | 113 | ||
112 | void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work); | 114 | void btrfs_queue_worker(struct btrfs_workers *workers, struct btrfs_work *work); |
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 70681686e8dc..9efb94e95858 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -535,10 +535,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
535 | list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list); | 535 | list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list); |
536 | 536 | ||
537 | btrfs_rm_dev_replace_srcdev(fs_info, src_device); | 537 | btrfs_rm_dev_replace_srcdev(fs_info, src_device); |
538 | if (src_device->bdev) { | 538 | |
539 | /* zero out the old super */ | ||
540 | btrfs_scratch_superblock(src_device); | ||
541 | } | ||
542 | /* | 539 | /* |
543 | * this is again a consistent state where no dev_replace procedure | 540 | * this is again a consistent state where no dev_replace procedure |
544 | * is running, the target device is part of the filesystem, the | 541 | * is running, the target device is part of the filesystem, the |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index c09a40db53db..22bda32acb89 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -145,8 +145,16 @@ int __init extent_io_init(void) | |||
145 | offsetof(struct btrfs_io_bio, bio)); | 145 | offsetof(struct btrfs_io_bio, bio)); |
146 | if (!btrfs_bioset) | 146 | if (!btrfs_bioset) |
147 | goto free_buffer_cache; | 147 | goto free_buffer_cache; |
148 | |||
149 | if (bioset_integrity_create(btrfs_bioset, BIO_POOL_SIZE)) | ||
150 | goto free_bioset; | ||
151 | |||
148 | return 0; | 152 | return 0; |
149 | 153 | ||
154 | free_bioset: | ||
155 | bioset_free(btrfs_bioset); | ||
156 | btrfs_bioset = NULL; | ||
157 | |||
150 | free_buffer_cache: | 158 | free_buffer_cache: |
151 | kmem_cache_destroy(extent_buffer_cache); | 159 | kmem_cache_destroy(extent_buffer_cache); |
152 | extent_buffer_cache = NULL; | 160 | extent_buffer_cache = NULL; |
@@ -1614,7 +1622,7 @@ again: | |||
1614 | *start = delalloc_start; | 1622 | *start = delalloc_start; |
1615 | *end = delalloc_end; | 1623 | *end = delalloc_end; |
1616 | free_extent_state(cached_state); | 1624 | free_extent_state(cached_state); |
1617 | return found; | 1625 | return 0; |
1618 | } | 1626 | } |
1619 | 1627 | ||
1620 | /* | 1628 | /* |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index e7a95356df83..8c81bdc1ef9b 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -1838,11 +1838,8 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
1838 | assert_qgroups_uptodate(trans); | 1838 | assert_qgroups_uptodate(trans); |
1839 | update_super_roots(root); | 1839 | update_super_roots(root); |
1840 | 1840 | ||
1841 | if (!root->fs_info->log_root_recovering) { | 1841 | btrfs_set_super_log_root(root->fs_info->super_copy, 0); |
1842 | btrfs_set_super_log_root(root->fs_info->super_copy, 0); | 1842 | btrfs_set_super_log_root_level(root->fs_info->super_copy, 0); |
1843 | btrfs_set_super_log_root_level(root->fs_info->super_copy, 0); | ||
1844 | } | ||
1845 | |||
1846 | memcpy(root->fs_info->super_for_commit, root->fs_info->super_copy, | 1843 | memcpy(root->fs_info->super_for_commit, root->fs_info->super_copy, |
1847 | sizeof(*root->fs_info->super_copy)); | 1844 | sizeof(*root->fs_info->super_copy)); |
1848 | 1845 | ||
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index a10645830223..043b215769c2 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1716,6 +1716,7 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info, | |||
1716 | struct btrfs_device *srcdev) | 1716 | struct btrfs_device *srcdev) |
1717 | { | 1717 | { |
1718 | WARN_ON(!mutex_is_locked(&fs_info->fs_devices->device_list_mutex)); | 1718 | WARN_ON(!mutex_is_locked(&fs_info->fs_devices->device_list_mutex)); |
1719 | |||
1719 | list_del_rcu(&srcdev->dev_list); | 1720 | list_del_rcu(&srcdev->dev_list); |
1720 | list_del_rcu(&srcdev->dev_alloc_list); | 1721 | list_del_rcu(&srcdev->dev_alloc_list); |
1721 | fs_info->fs_devices->num_devices--; | 1722 | fs_info->fs_devices->num_devices--; |
@@ -1725,9 +1726,13 @@ void btrfs_rm_dev_replace_srcdev(struct btrfs_fs_info *fs_info, | |||
1725 | } | 1726 | } |
1726 | if (srcdev->can_discard) | 1727 | if (srcdev->can_discard) |
1727 | fs_info->fs_devices->num_can_discard--; | 1728 | fs_info->fs_devices->num_can_discard--; |
1728 | if (srcdev->bdev) | 1729 | if (srcdev->bdev) { |
1729 | fs_info->fs_devices->open_devices--; | 1730 | fs_info->fs_devices->open_devices--; |
1730 | 1731 | ||
1732 | /* zero out the old super */ | ||
1733 | btrfs_scratch_superblock(srcdev); | ||
1734 | } | ||
1735 | |||
1731 | call_rcu(&srcdev->rcu, free_device); | 1736 | call_rcu(&srcdev->rcu, free_device); |
1732 | } | 1737 | } |
1733 | 1738 | ||