diff options
author | David Sterba <dsterba@suse.cz> | 2011-05-31 12:07:27 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-06-04 08:11:22 -0400 |
commit | 7841cb2898f66a73062c64d0ef5733dde7279e46 (patch) | |
tree | b7a94d96d44971845951a59e9fb7b5c2e30c46b3 | |
parent | 4b9465cb9e3859186eefa1ca3b990a5849386320 (diff) |
btrfs: add helper for fs_info->closing
wrap checking of filesystem 'closing' flag and fix a few missing memory
barriers.
Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r-- | fs/btrfs/ctree.h | 9 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 3 | ||||
-rw-r--r-- | fs/btrfs/file.c | 4 | ||||
-rw-r--r-- | fs/btrfs/free-space-cache.c | 10 | ||||
-rw-r--r-- | fs/btrfs/inode-map.c | 3 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 3 | ||||
-rw-r--r-- | fs/btrfs/scrub.c | 2 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 2 |
8 files changed, 20 insertions, 16 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 4958ef5417d6..8490ee063709 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2354,6 +2354,15 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans, | |||
2354 | struct btrfs_root *root, | 2354 | struct btrfs_root *root, |
2355 | struct extent_buffer *node, | 2355 | struct extent_buffer *node, |
2356 | struct extent_buffer *parent); | 2356 | struct extent_buffer *parent); |
2357 | static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info) | ||
2358 | { | ||
2359 | /* | ||
2360 | * Get synced with close_ctree() | ||
2361 | */ | ||
2362 | smp_mb(); | ||
2363 | return fs_info->closing; | ||
2364 | } | ||
2365 | |||
2357 | /* root-item.c */ | 2366 | /* root-item.c */ |
2358 | int btrfs_find_root_ref(struct btrfs_root *tree_root, | 2367 | int btrfs_find_root_ref(struct btrfs_root *tree_root, |
2359 | struct btrfs_path *path, | 2368 | struct btrfs_path *path, |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index c9173a7827b0..5b9b6b6df242 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -366,8 +366,7 @@ again: | |||
366 | nritems = btrfs_header_nritems(leaf); | 366 | nritems = btrfs_header_nritems(leaf); |
367 | 367 | ||
368 | while (1) { | 368 | while (1) { |
369 | smp_mb(); | 369 | if (btrfs_fs_closing(fs_info) > 1) { |
370 | if (fs_info->closing > 1) { | ||
371 | last = (u64)-1; | 370 | last = (u64)-1; |
372 | break; | 371 | break; |
373 | } | 372 | } |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 982b5ea9762f..fa4ef18b66b1 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -129,7 +129,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans, | |||
129 | if (!btrfs_test_opt(root, AUTO_DEFRAG)) | 129 | if (!btrfs_test_opt(root, AUTO_DEFRAG)) |
130 | return 0; | 130 | return 0; |
131 | 131 | ||
132 | if (root->fs_info->closing) | 132 | if (btrfs_fs_closing(root->fs_info)) |
133 | return 0; | 133 | return 0; |
134 | 134 | ||
135 | if (BTRFS_I(inode)->in_defrag) | 135 | if (BTRFS_I(inode)->in_defrag) |
@@ -229,7 +229,7 @@ int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info) | |||
229 | first_ino = defrag->ino + 1; | 229 | first_ino = defrag->ino + 1; |
230 | rb_erase(&defrag->rb_node, &fs_info->defrag_inodes); | 230 | rb_erase(&defrag->rb_node, &fs_info->defrag_inodes); |
231 | 231 | ||
232 | if (fs_info->closing) | 232 | if (btrfs_fs_closing(fs_info)) |
233 | goto next_free; | 233 | goto next_free; |
234 | 234 | ||
235 | spin_unlock(&fs_info->defrag_inodes_lock); | 235 | spin_unlock(&fs_info->defrag_inodes_lock); |
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index bffa5c4a633b..ad144736a5fd 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -98,7 +98,7 @@ struct inode *lookup_free_space_inode(struct btrfs_root *root, | |||
98 | return inode; | 98 | return inode; |
99 | 99 | ||
100 | spin_lock(&block_group->lock); | 100 | spin_lock(&block_group->lock); |
101 | if (!root->fs_info->closing) { | 101 | if (!btrfs_fs_closing(root->fs_info)) { |
102 | block_group->inode = igrab(inode); | 102 | block_group->inode = igrab(inode); |
103 | block_group->iref = 1; | 103 | block_group->iref = 1; |
104 | } | 104 | } |
@@ -493,8 +493,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info, | |||
493 | * If we're unmounting then just return, since this does a search on the | 493 | * If we're unmounting then just return, since this does a search on the |
494 | * normal root and not the commit root and we could deadlock. | 494 | * normal root and not the commit root and we could deadlock. |
495 | */ | 495 | */ |
496 | smp_mb(); | 496 | if (btrfs_fs_closing(fs_info)) |
497 | if (fs_info->closing) | ||
498 | return 0; | 497 | return 0; |
499 | 498 | ||
500 | /* | 499 | /* |
@@ -2513,7 +2512,7 @@ struct inode *lookup_free_ino_inode(struct btrfs_root *root, | |||
2513 | return inode; | 2512 | return inode; |
2514 | 2513 | ||
2515 | spin_lock(&root->cache_lock); | 2514 | spin_lock(&root->cache_lock); |
2516 | if (!root->fs_info->closing) | 2515 | if (!btrfs_fs_closing(root->fs_info)) |
2517 | root->cache_inode = igrab(inode); | 2516 | root->cache_inode = igrab(inode); |
2518 | spin_unlock(&root->cache_lock); | 2517 | spin_unlock(&root->cache_lock); |
2519 | 2518 | ||
@@ -2543,8 +2542,7 @@ int load_free_ino_cache(struct btrfs_fs_info *fs_info, struct btrfs_root *root) | |||
2543 | * If we're unmounting then just return, since this does a search on the | 2542 | * If we're unmounting then just return, since this does a search on the |
2544 | * normal root and not the commit root and we could deadlock. | 2543 | * normal root and not the commit root and we could deadlock. |
2545 | */ | 2544 | */ |
2546 | smp_mb(); | 2545 | if (btrfs_fs_closing(fs_info)) |
2547 | if (fs_info->closing) | ||
2548 | return 0; | 2546 | return 0; |
2549 | 2547 | ||
2550 | path = btrfs_alloc_path(); | 2548 | path = btrfs_alloc_path(); |
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index cb79b8975c9f..b4087e0fa871 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c | |||
@@ -62,8 +62,7 @@ again: | |||
62 | goto out; | 62 | goto out; |
63 | 63 | ||
64 | while (1) { | 64 | while (1) { |
65 | smp_mb(); | 65 | if (btrfs_fs_closing(fs_info)) |
66 | if (fs_info->closing) | ||
67 | goto out; | 66 | goto out; |
68 | 67 | ||
69 | leaf = path->nodes[0]; | 68 | leaf = path->nodes[0]; |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a83e44bf3206..02ff4a1b968b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -4266,8 +4266,7 @@ int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc) | |||
4266 | if (BTRFS_I(inode)->dummy_inode) | 4266 | if (BTRFS_I(inode)->dummy_inode) |
4267 | return 0; | 4267 | return 0; |
4268 | 4268 | ||
4269 | smp_mb(); | 4269 | if (btrfs_fs_closing(root->fs_info) && is_free_space_inode(root, inode)) |
4270 | if (root->fs_info->closing && is_free_space_inode(root, inode)) | ||
4271 | nolock = true; | 4270 | nolock = true; |
4272 | 4271 | ||
4273 | if (wbc->sync_mode == WB_SYNC_ALL) { | 4272 | if (wbc->sync_mode == WB_SYNC_ALL) { |
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 1204eab94028..df50fd1eca8f 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c | |||
@@ -1183,7 +1183,7 @@ int btrfs_scrub_dev(struct btrfs_root *root, u64 devid, u64 start, u64 end, | |||
1183 | int ret; | 1183 | int ret; |
1184 | struct btrfs_device *dev; | 1184 | struct btrfs_device *dev; |
1185 | 1185 | ||
1186 | if (root->fs_info->closing) | 1186 | if (btrfs_fs_closing(root->fs_info)) |
1187 | return -EINVAL; | 1187 | return -EINVAL; |
1188 | 1188 | ||
1189 | /* | 1189 | /* |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 2d5c6d2aa4e4..dd719662340e 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -817,7 +817,7 @@ int btrfs_defrag_root(struct btrfs_root *root, int cacheonly) | |||
817 | btrfs_btree_balance_dirty(info->tree_root, nr); | 817 | btrfs_btree_balance_dirty(info->tree_root, nr); |
818 | cond_resched(); | 818 | cond_resched(); |
819 | 819 | ||
820 | if (root->fs_info->closing || ret != -EAGAIN) | 820 | if (btrfs_fs_closing(root->fs_info) || ret != -EAGAIN) |
821 | break; | 821 | break; |
822 | } | 822 | } |
823 | root->defrag_running = 0; | 823 | root->defrag_running = 0; |