]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Btrfs: Protect the readonly flag of block group
authorWuBo <wu.bo@cn.fujitsu.com>
Tue, 26 Jul 2011 03:30:11 +0000 (03:30 +0000)
committerChris Mason <chris.mason@oracle.com>
Mon, 1 Aug 2011 18:30:43 +0000 (14:30 -0400)
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>
fs/btrfs/extent-tree.c

index db2057f262ad9298392c9b5b109c8fcd99c87369..a4db88da125e9ba8d9d5441160b629c455d4acf1 100644 (file)
@@ -6549,8 +6549,6 @@ static int set_block_group_ro(struct btrfs_block_group_cache *cache, int force)
        u64 min_allocable_bytes;
        int ret = -ENOSPC;
 
-       if (cache->ro)
-               return 0;
 
        /*
         * 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)
 
        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);
 
@@ -6579,7 +6583,7 @@ static int set_block_group_ro(struct btrfs_block_group_cache *cache, int force)
                cache->ro = 1;
                ret = 0;
        }
-
+out:
        spin_unlock(&cache->lock);
        spin_unlock(&sinfo->lock);
        return ret;