aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorWuBo <wu.bo@cn.fujitsu.com>2011-07-25 23:30:11 -0400
committerChris Mason <chris.mason@oracle.com>2011-08-01 14:30:43 -0400
commit61cfea9bb84d41b09e59822c33b3eb27acc48358 (patch)
tree6c20e098a3be7aad77419dc273bfd670dc470f3a /fs/btrfs
parent1bf85046e493c88be1c1bad9084428373089f618 (diff)
Btrfs: Protect the readonly flag of block group
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> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index db2057f262ad..a4db88da125e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6549,8 +6549,6 @@ static int set_block_group_ro(struct btrfs_block_group_cache *cache, int force)
6549 u64 min_allocable_bytes; 6549 u64 min_allocable_bytes;
6550 int ret = -ENOSPC; 6550 int ret = -ENOSPC;
6551 6551
6552 if (cache->ro)
6553 return 0;
6554 6552
6555 /* 6553 /*
6556 * We need some metadata space and system metadata space for 6554 * We need some metadata space and system metadata space for
@@ -6566,6 +6564,12 @@ static int set_block_group_ro(struct btrfs_block_group_cache *cache, int force)
6566 6564
6567 spin_lock(&sinfo->lock); 6565 spin_lock(&sinfo->lock);
6568 spin_lock(&cache->lock); 6566 spin_lock(&cache->lock);
6567
6568 if (cache->ro) {
6569 ret = 0;
6570 goto out;
6571 }
6572
6569 num_bytes = cache->key.offset - cache->reserved - cache->pinned - 6573 num_bytes = cache->key.offset - cache->reserved - cache->pinned -
6570 cache->bytes_super - btrfs_block_group_used(&cache->item); 6574 cache->bytes_super - btrfs_block_group_used(&cache->item);
6571 6575
@@ -6579,7 +6583,7 @@ static int set_block_group_ro(struct btrfs_block_group_cache *cache, int force)
6579 cache->ro = 1; 6583 cache->ro = 1;
6580 ret = 0; 6584 ret = 0;
6581 } 6585 }
6582 6586out:
6583 spin_unlock(&cache->lock); 6587 spin_unlock(&cache->lock);
6584 spin_unlock(&sinfo->lock); 6588 spin_unlock(&sinfo->lock);
6585 return ret; 6589 return ret;