aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-28 13:07:35 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-28 13:07:35 -0400
commitf6167514c819cb7794e60cf36b9466598a789013 (patch)
tree53cd063b30ad8314d57f1a58a4c2d27b968a55f2 /fs/btrfs/tree-log.c
parent2cd0b50a189febfe1855b13be98297a621864741 (diff)
parent570dd45042a7c8a7aba1ee029c5dd0f5ccf41b9b (diff)
Merge branch 'for-linus-4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs fixes from Chris Mason: "My patch fixes the btrfs list_head abuse that we tracked down during Dave Jones' memory corruption investigation. With both Jens and my patches in place, I'm no longer able to trigger problems. Filipe is fixing a difficult old bug between snapshots, balance and send. Dave is cooking a few more for the next rc, but these are tested and ready" * 'for-linus-4.9' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: btrfs: fix races on root_log_ctx lists btrfs: fix incremental send failure caused by balance
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 528cae123dc9..3d33c4e41e5f 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2713,14 +2713,12 @@ static inline void btrfs_remove_all_log_ctxs(struct btrfs_root *root,
2713 int index, int error) 2713 int index, int error)
2714{ 2714{
2715 struct btrfs_log_ctx *ctx; 2715 struct btrfs_log_ctx *ctx;
2716 struct btrfs_log_ctx *safe;
2716 2717
2717 if (!error) { 2718 list_for_each_entry_safe(ctx, safe, &root->log_ctxs[index], list) {
2718 INIT_LIST_HEAD(&root->log_ctxs[index]); 2719 list_del_init(&ctx->list);
2719 return;
2720 }
2721
2722 list_for_each_entry(ctx, &root->log_ctxs[index], list)
2723 ctx->log_ret = error; 2720 ctx->log_ret = error;
2721 }
2724 2722
2725 INIT_LIST_HEAD(&root->log_ctxs[index]); 2723 INIT_LIST_HEAD(&root->log_ctxs[index]);
2726} 2724}
@@ -2961,13 +2959,9 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
2961 mutex_unlock(&root->log_mutex); 2959 mutex_unlock(&root->log_mutex);
2962 2960
2963out_wake_log_root: 2961out_wake_log_root:
2964 /* 2962 mutex_lock(&log_root_tree->log_mutex);
2965 * We needn't get log_mutex here because we are sure all
2966 * the other tasks are blocked.
2967 */
2968 btrfs_remove_all_log_ctxs(log_root_tree, index2, ret); 2963 btrfs_remove_all_log_ctxs(log_root_tree, index2, ret);
2969 2964
2970 mutex_lock(&log_root_tree->log_mutex);
2971 log_root_tree->log_transid_committed++; 2965 log_root_tree->log_transid_committed++;
2972 atomic_set(&log_root_tree->log_commit[index2], 0); 2966 atomic_set(&log_root_tree->log_commit[index2], 0);
2973 mutex_unlock(&log_root_tree->log_mutex); 2967 mutex_unlock(&log_root_tree->log_mutex);
@@ -2978,10 +2972,8 @@ out_wake_log_root:
2978 if (waitqueue_active(&log_root_tree->log_commit_wait[index2])) 2972 if (waitqueue_active(&log_root_tree->log_commit_wait[index2]))
2979 wake_up(&log_root_tree->log_commit_wait[index2]); 2973 wake_up(&log_root_tree->log_commit_wait[index2]);
2980out: 2974out:
2981 /* See above. */
2982 btrfs_remove_all_log_ctxs(root, index1, ret);
2983
2984 mutex_lock(&root->log_mutex); 2975 mutex_lock(&root->log_mutex);
2976 btrfs_remove_all_log_ctxs(root, index1, ret);
2985 root->log_transid_committed++; 2977 root->log_transid_committed++;
2986 atomic_set(&root->log_commit[index1], 0); 2978 atomic_set(&root->log_commit[index1], 0);
2987 mutex_unlock(&root->log_mutex); 2979 mutex_unlock(&root->log_mutex);