diff options
Diffstat (limited to 'fs/btrfs/inode-map.c')
-rw-r--r-- | fs/btrfs/inode-map.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index cc8ca193d830..86935f5ae291 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c | |||
@@ -176,7 +176,11 @@ static void start_caching(struct btrfs_root *root) | |||
176 | 176 | ||
177 | tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu\n", | 177 | tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu\n", |
178 | root->root_key.objectid); | 178 | root->root_key.objectid); |
179 | BUG_ON(IS_ERR(tsk)); /* -ENOMEM */ | 179 | if (IS_ERR(tsk)) { |
180 | btrfs_warn(root->fs_info, "failed to start inode caching task"); | ||
181 | btrfs_clear_and_info(root, CHANGE_INODE_CACHE, | ||
182 | "disabling inode map caching"); | ||
183 | } | ||
180 | } | 184 | } |
181 | 185 | ||
182 | int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) | 186 | int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) |
@@ -205,24 +209,14 @@ again: | |||
205 | 209 | ||
206 | void btrfs_return_ino(struct btrfs_root *root, u64 objectid) | 210 | void btrfs_return_ino(struct btrfs_root *root, u64 objectid) |
207 | { | 211 | { |
208 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | ||
209 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; | 212 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; |
210 | 213 | ||
211 | if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | 214 | if (!btrfs_test_opt(root, INODE_MAP_CACHE)) |
212 | return; | 215 | return; |
213 | |||
214 | again: | 216 | again: |
215 | if (root->cached == BTRFS_CACHE_FINISHED) { | 217 | if (root->cached == BTRFS_CACHE_FINISHED) { |
216 | __btrfs_add_free_space(ctl, objectid, 1); | 218 | __btrfs_add_free_space(pinned, objectid, 1); |
217 | } else { | 219 | } else { |
218 | /* | ||
219 | * If we are in the process of caching free ino chunks, | ||
220 | * to avoid adding the same inode number to the free_ino | ||
221 | * tree twice due to cross transaction, we'll leave it | ||
222 | * in the pinned tree until a transaction is committed | ||
223 | * or the caching work is done. | ||
224 | */ | ||
225 | |||
226 | down_write(&root->fs_info->commit_root_sem); | 220 | down_write(&root->fs_info->commit_root_sem); |
227 | spin_lock(&root->cache_lock); | 221 | spin_lock(&root->cache_lock); |
228 | if (root->cached == BTRFS_CACHE_FINISHED) { | 222 | if (root->cached == BTRFS_CACHE_FINISHED) { |
@@ -234,11 +228,7 @@ again: | |||
234 | 228 | ||
235 | start_caching(root); | 229 | start_caching(root); |
236 | 230 | ||
237 | if (objectid <= root->cache_progress || | 231 | __btrfs_add_free_space(pinned, objectid, 1); |
238 | objectid >= root->highest_objectid) | ||
239 | __btrfs_add_free_space(ctl, objectid, 1); | ||
240 | else | ||
241 | __btrfs_add_free_space(pinned, objectid, 1); | ||
242 | 232 | ||
243 | up_write(&root->fs_info->commit_root_sem); | 233 | up_write(&root->fs_info->commit_root_sem); |
244 | } | 234 | } |