public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: fix race between allocate and release extent buffer.
@ 2010-02-04  8:46 Yan, Zheng
  2010-02-04  8:56 ` Yan, Zheng
  2010-02-04 12:23 ` Chris Mason
  0 siblings, 2 replies; 3+ messages in thread
From: Yan, Zheng @ 2010-02-04  8:46 UTC (permalink / raw)
  To: linux-btrfs, chris Mason

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>

---
diff -urp 1/fs/btrfs/extent_io.c 2/fs/btrfs/extent_io.c
--- 1/fs/btrfs/extent_io.c	2010-01-17 15:48:16.770302026 +0800
+++ 2/fs/btrfs/extent_io.c	2010-02-04 16:37:45.704800682 +0800
@@ -3165,10 +3165,9 @@ struct extent_buffer *alloc_extent_buffe
 		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:

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-04 12:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-04  8:46 [PATCH] btrfs: fix race between allocate and release extent buffer Yan, Zheng
2010-02-04  8:56 ` Yan, Zheng
2010-02-04 12:23 ` Chris Mason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox