]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
Btrfs: check cache->caching_ctl before returning if caching has started
authorJosef Bacik <josef@redhat.com>
Thu, 16 Sep 2010 20:17:03 +0000 (16:17 -0400)
committerChris Mason <chris.mason@oracle.com>
Fri, 29 Oct 2010 13:26:35 +0000 (09:26 -0400)
With the free space disk caching we can mark the block group as started with the
caching, but we don't have a caching ctl.  This can race with anybody else who
tries to get the caching ctl before we cache (this is very hard to do btw).  So
instead check to see if cache->caching_ctl is set, and if not return NULL.
Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
fs/btrfs/extent-tree.c

index 9a325e465ad9be7c850a56719a1e821b58697489..5c9ef3ac25e1416846d04690225c45bd9f871257 100644 (file)
@@ -242,6 +242,12 @@ get_caching_control(struct btrfs_block_group_cache *cache)
                return NULL;
        }
 
+       /* We're loading it the fast way, so we don't have a caching_ctl. */
+       if (!cache->caching_ctl) {
+               spin_unlock(&cache->lock);
+               return NULL;
+       }
+
        ctl = cache->caching_ctl;
        atomic_inc(&ctl->count);
        spin_unlock(&cache->lock);