aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/inode-map.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
index 8ad529e3e67e..86935f5ae291 100644
--- a/fs/btrfs/inode-map.c
+++ b/fs/btrfs/inode-map.c
@@ -209,24 +209,14 @@ again:
209 209
210void btrfs_return_ino(struct btrfs_root *root, u64 objectid) 210void btrfs_return_ino(struct btrfs_root *root, u64 objectid)
211{ 211{
212 struct btrfs_free_space_ctl *ctl = root->free_ino_ctl;
213 struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; 212 struct btrfs_free_space_ctl *pinned = root->free_ino_pinned;
214 213
215 if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 214 if (!btrfs_test_opt(root, INODE_MAP_CACHE))
216 return; 215 return;
217
218again: 216again:
219 if (root->cached == BTRFS_CACHE_FINISHED) { 217 if (root->cached == BTRFS_CACHE_FINISHED) {
220 __btrfs_add_free_space(ctl, objectid, 1); 218 __btrfs_add_free_space(pinned, objectid, 1);
221 } else { 219 } else {
222 /*
223 * If we are in the process of caching free ino chunks,
224 * to avoid adding the same inode number to the free_ino
225 * tree twice due to cross transaction, we'll leave it
226 * in the pinned tree until a transaction is committed
227 * or the caching work is done.
228 */
229
230 down_write(&root->fs_info->commit_root_sem); 220 down_write(&root->fs_info->commit_root_sem);
231 spin_lock(&root->cache_lock); 221 spin_lock(&root->cache_lock);
232 if (root->cached == BTRFS_CACHE_FINISHED) { 222 if (root->cached == BTRFS_CACHE_FINISHED) {
@@ -238,11 +228,7 @@ again:
238 228
239 start_caching(root); 229 start_caching(root);
240 230
241 if (objectid <= root->cache_progress || 231 __btrfs_add_free_space(pinned, objectid, 1);
242 objectid >= root->highest_objectid)
243 __btrfs_add_free_space(ctl, objectid, 1);
244 else
245 __btrfs_add_free_space(pinned, objectid, 1);
246 232
247 up_write(&root->fs_info->commit_root_sem); 233 up_write(&root->fs_info->commit_root_sem);
248 } 234 }