From: Yan, Zheng Date: Thu, 4 Feb 2010 08:46:56 +0000 (+0000) Subject: Btrfs: fix race between allocate and release extent buffer. X-Git-Tag: v2.6.32.19~41 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=85d0fbf78459afd67f19052fca86e804db8e1251;p=karo-tx-linux.git Btrfs: fix race between allocate and release extent buffer. commit f044ba7835b84e69c68b620ca8fa27e5ef67759d upstream. Increase extent buffer's reference count while holding the lock. Otherwise it can race with try_release_extent_buffer. Signed-off-by: Yan Zheng Signed-off-by: Chris Mason Acked-by: Jeff Mahoney Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 96577e8bf9fd..b177ed319612 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -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: