]> git.hungrycats.org Git - linux/commitdiff
Btrfs: fix ASSERT(list_empty(&cur_trans->dirty_bgs_list)
authorJosef Bacik <jbacik@fb.com>
Mon, 2 Mar 2015 17:46:55 +0000 (12:46 -0500)
committerChris Mason <clm@fb.com>
Tue, 3 Mar 2015 02:56:05 +0000 (18:56 -0800)
Dave could hit this assert consistently running btrfs/078.  This is because
when we update the block groups we could truncate the free space, which would
try to delete the csums for that range and dirty the csum root.  For this to
happen we have to have already written out the csum root so it's kind of hard to
hit this case.  This patch fixes this by changing the logic to only write the
dirty block groups if the dirty_cowonly_roots list is empty.  This will get us
the same effect as before since we add the extent root last, and will cover the
case that we dirty some other root again but not the extent root.  Thanks,

Reported-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/transaction.c

index 038fcf6051e001a9e2f876468b9b4f91956f6e45..a7a413f33af44f5d342c273c6772d9518839240a 100644 (file)
@@ -1023,16 +1023,22 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
        u64 old_root_bytenr;
        u64 old_root_used;
        struct btrfs_root *tree_root = root->fs_info->tree_root;
-       bool extent_root = (root->objectid == BTRFS_EXTENT_TREE_OBJECTID);
+       struct btrfs_fs_info *fs_info = root->fs_info;
 
        old_root_used = btrfs_root_used(&root->root_item);
        btrfs_write_dirty_block_groups(trans, root);
 
        while (1) {
                old_root_bytenr = btrfs_root_bytenr(&root->root_item);
+
+               /*
+                * We can only break out if our root matches the root item and
+                * we either have more roots to process or we have no more roots
+                * to process and there are no empty bgs.
+                */
                if (old_root_bytenr == root->node->start &&
                    old_root_used == btrfs_root_used(&root->root_item) &&
-                   (!extent_root ||
+                   (!list_empty(&fs_info->dirty_cowonly_roots) ||
                     list_empty(&trans->transaction->dirty_bgs)))
                        break;
 
@@ -1044,7 +1050,7 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
                        return ret;
 
                old_root_used = btrfs_root_used(&root->root_item);
-               if (extent_root) {
+               if (list_empty(&fs_info->dirty_cowonly_roots)) {
                        ret = btrfs_write_dirty_block_groups(trans, root);
                        if (ret)
                                return ret;