aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-07-25 15:11:47 -0400
committerChris Mason <chris.mason@fusionio.com>2013-08-09 19:30:23 -0400
commitcfad392b22163eba71d882950e17d2c4d43b2bad (patch)
tree7a3807402e20389d22975e87291ad05a4f98665d /fs
parentf3b15ccdbb9a79781578249a63318805e55a6c34 (diff)
Btrfs: check to see if root_list is empty before adding it to dead roots
A user reported a panic when running with autodefrag and deleting snapshots. This is because we could end up trying to add the root to the dead roots list twice. To fix this check to see if we are empty before adding ourselves to the dead roots list. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/transaction.c8
-rw-r--r--fs/btrfs/transaction.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index d58cce77fc6c..af1931a5960d 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -983,12 +983,12 @@ static noinline int commit_cowonly_roots(struct btrfs_trans_handle *trans,
983 * a dirty root struct and adds it into the list of dead roots that need to 983 * a dirty root struct and adds it into the list of dead roots that need to
984 * be deleted 984 * be deleted
985 */ 985 */
986int btrfs_add_dead_root(struct btrfs_root *root) 986void btrfs_add_dead_root(struct btrfs_root *root)
987{ 987{
988 spin_lock(&root->fs_info->trans_lock); 988 spin_lock(&root->fs_info->trans_lock);
989 list_add_tail(&root->root_list, &root->fs_info->dead_roots); 989 if (list_empty(&root->root_list))
990 list_add_tail(&root->root_list, &root->fs_info->dead_roots);
990 spin_unlock(&root->fs_info->trans_lock); 991 spin_unlock(&root->fs_info->trans_lock);
991 return 0;
992} 992}
993 993
994/* 994/*
@@ -1925,7 +1925,7 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
1925 } 1925 }
1926 root = list_first_entry(&fs_info->dead_roots, 1926 root = list_first_entry(&fs_info->dead_roots,
1927 struct btrfs_root, root_list); 1927 struct btrfs_root, root_list);
1928 list_del(&root->root_list); 1928 list_del_init(&root->root_list);
1929 spin_unlock(&fs_info->trans_lock); 1929 spin_unlock(&fs_info->trans_lock);
1930 1930
1931 pr_debug("btrfs: cleaner removing %llu\n", 1931 pr_debug("btrfs: cleaner removing %llu\n",
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 005b0375d18c..defbc4269897 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -143,7 +143,7 @@ int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid);
143int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans, 143int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
144 struct btrfs_root *root); 144 struct btrfs_root *root);
145 145
146int btrfs_add_dead_root(struct btrfs_root *root); 146void btrfs_add_dead_root(struct btrfs_root *root);
147int btrfs_defrag_root(struct btrfs_root *root); 147int btrfs_defrag_root(struct btrfs_root *root);
148int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root); 148int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root);
149int btrfs_commit_transaction(struct btrfs_trans_handle *trans, 149int btrfs_commit_transaction(struct btrfs_trans_handle *trans,