Btrfs: fix race between allocate and release extent buffer.
authorYan, Zheng <zheng.yan@oracle.com>
Thu, 4 Feb 2010 08:46:56 +0000 (08:46 +0000)
committerChris Mason <chris.mason@oracle.com>
Thu, 4 Feb 2010 16:31:44 +0000 (11:31 -0500)
Increase extent buffer's reference count while holding the lock.
Otherwise it can race with try_release_extent_buffer.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/extent_io.c

index 96577e8..b177ed3 100644 (file)
@@ -3165,10 +3165,9 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
                spin_unlock(&tree->buffer_lock);
                goto free_eb;
        }
-       spin_unlock(&tree->buffer_lock);
-
        /* add one reference for the tree */
        atomic_inc(&eb->refs);
+       spin_unlock(&tree->buffer_lock);
        return eb;
 
 free_eb: