Btrfs: Fix async caching interaction with unmount
authorYan Zheng <zheng.yan@oracle.com>
Tue, 28 Jul 2009 12:41:57 +0000 (08:41 -0400)
committerChris Mason <chris.mason@oracle.com>
Tue, 28 Jul 2009 12:41:57 +0000 (08:41 -0400)
- don't stop the caching thread until btrfs_commit_super return.

- if caching is interrupted by umount, set last to (u64)-1.
  otherwise the un-scanned range of block group will be considered
  as free extent.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c

index c658397c7473ce194fc9ec8c01c054013dbef09b..3a9b8875988018bd2782f919631f54335de1e0d1 100644 (file)
@@ -2317,6 +2317,9 @@ int close_ctree(struct btrfs_root *root)
                        printk(KERN_ERR "btrfs: commit super ret %d\n", ret);
        }
 
+       fs_info->closing = 2;
+       smp_mb();
+
        if (fs_info->delalloc_bytes) {
                printk(KERN_INFO "btrfs: at unmount delalloc count %llu\n",
                       (unsigned long long)fs_info->delalloc_bytes);
index 08188f1615d9ba4fac89c8f3f77ec5b859d20f12..fadf69a2764b316828f82d31be8490c0dcf57739 100644 (file)
@@ -288,8 +288,10 @@ again:
 
        while (1) {
                smp_mb();
-               if (block_group->fs_info->closing)
+               if (block_group->fs_info->closing > 1) {
+                       last = (u64)-1;
                        break;
+               }
 
                leaf = path->nodes[0];
                slot = path->slots[0];