]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: remove ourselves from the cluster list under lock
authorJosef Bacik <jbacik@fusionio.com>
Thu, 22 Aug 2013 21:03:29 +0000 (17:03 -0400)
committerChris Mason <chris.mason@fusionio.com>
Sun, 1 Sep 2013 12:16:23 +0000 (08:16 -0400)
A user was reporting weird warnings from btrfs_put_delayed_ref() and I noticed
that we were doing this list_del_init() on our head ref outside of
delayed_refs->lock.  This is a problem if we have people still on the list, we
could end up modifying old pointers and such.  Fix this by removing us from the
list before we do our run_delayed_ref on our head ref.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/extent-tree.c

index 69083330ee168c62d835fab72f31f02931a17446..cfb3cf711b34d6555afed3d21dd16480c662cc55 100644 (file)
@@ -2440,6 +2440,8 @@ static noinline int run_clustered_refs(struct btrfs_trans_handle *trans,
                        default:
                                WARN_ON(1);
                        }
+               } else {
+                       list_del_init(&locked_ref->cluster);
                }
                spin_unlock(&delayed_refs->lock);
 
@@ -2462,7 +2464,6 @@ static noinline int run_clustered_refs(struct btrfs_trans_handle *trans,
                 * list before we release it.
                 */
                if (btrfs_delayed_ref_is_head(ref)) {
-                       list_del_init(&locked_ref->cluster);
                        btrfs_delayed_ref_unlock(locked_ref);
                        locked_ref = NULL;
                }