linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: Protect the readonly flag of block group
@ 2011-07-26  3:30 WuBo
  0 siblings, 0 replies; only message in thread
From: WuBo @ 2011-07-26  3:30 UTC (permalink / raw)
  To: Linux Btrfs

The access for ro in btrfs_block_group_cache should be protected
because of the racy lock in relocation.

Signed-off-by: Wu Bo <wu.bo@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 9ee6bd5..cc9bf80 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -8143,11 +8143,14 @@ static int set_block_group_ro(struct btrfs_block_group_cache *cache)
 	u64 num_bytes;
 	int ret = -ENOSPC;
 
-	if (cache->ro)
-		return 0;
-
 	spin_lock(&sinfo->lock);
 	spin_lock(&cache->lock);
+
+	if (cache->ro) {
+		ret = 0;
+		goto out;
+	}
+
 	num_bytes = cache->key.offset - cache->reserved - cache->pinned -
 		    cache->bytes_super - btrfs_block_group_used(&cache->item);
 
@@ -8160,7 +8163,7 @@ static int set_block_group_ro(struct btrfs_block_group_cache *cache)
 		cache->ro = 1;
 		ret = 0;
 	}
-
+out:
 	spin_unlock(&cache->lock);
 	spin_unlock(&sinfo->lock);
 	return ret;
-- 1.7.3.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-07-26  3:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-26  3:30 [PATCH] Btrfs: Protect the readonly flag of block group WuBo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).