diff options
Diffstat (limited to 'fs/btrfs/inode-map.c')
-rw-r--r-- | fs/btrfs/inode-map.c | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index 359ee861b5a4..d27014b8bf72 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c | |||
@@ -104,7 +104,7 @@ again: | |||
104 | break; | 104 | break; |
105 | 105 | ||
106 | if (last != (u64)-1 && last + 1 != key.objectid) { | 106 | if (last != (u64)-1 && last + 1 != key.objectid) { |
107 | __btrfs_add_free_space(ctl, last + 1, | 107 | __btrfs_add_free_space(fs_info, ctl, last + 1, |
108 | key.objectid - last - 1); | 108 | key.objectid - last - 1); |
109 | wake_up(&root->ino_cache_wait); | 109 | wake_up(&root->ino_cache_wait); |
110 | } | 110 | } |
@@ -115,7 +115,7 @@ next: | |||
115 | } | 115 | } |
116 | 116 | ||
117 | if (last < root->highest_objectid - 1) { | 117 | if (last < root->highest_objectid - 1) { |
118 | __btrfs_add_free_space(ctl, last + 1, | 118 | __btrfs_add_free_space(fs_info, ctl, last + 1, |
119 | root->highest_objectid - last - 1); | 119 | root->highest_objectid - last - 1); |
120 | } | 120 | } |
121 | 121 | ||
@@ -136,12 +136,13 @@ out: | |||
136 | 136 | ||
137 | static void start_caching(struct btrfs_root *root) | 137 | static void start_caching(struct btrfs_root *root) |
138 | { | 138 | { |
139 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
139 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | 140 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; |
140 | struct task_struct *tsk; | 141 | struct task_struct *tsk; |
141 | int ret; | 142 | int ret; |
142 | u64 objectid; | 143 | u64 objectid; |
143 | 144 | ||
144 | if (!btrfs_test_opt(root->fs_info, INODE_MAP_CACHE)) | 145 | if (!btrfs_test_opt(fs_info, INODE_MAP_CACHE)) |
145 | return; | 146 | return; |
146 | 147 | ||
147 | spin_lock(&root->ino_cache_lock); | 148 | spin_lock(&root->ino_cache_lock); |
@@ -153,7 +154,7 @@ static void start_caching(struct btrfs_root *root) | |||
153 | root->ino_cache_state = BTRFS_CACHE_STARTED; | 154 | root->ino_cache_state = BTRFS_CACHE_STARTED; |
154 | spin_unlock(&root->ino_cache_lock); | 155 | spin_unlock(&root->ino_cache_lock); |
155 | 156 | ||
156 | ret = load_free_ino_cache(root->fs_info, root); | 157 | ret = load_free_ino_cache(fs_info, root); |
157 | if (ret == 1) { | 158 | if (ret == 1) { |
158 | spin_lock(&root->ino_cache_lock); | 159 | spin_lock(&root->ino_cache_lock); |
159 | root->ino_cache_state = BTRFS_CACHE_FINISHED; | 160 | root->ino_cache_state = BTRFS_CACHE_FINISHED; |
@@ -170,15 +171,15 @@ static void start_caching(struct btrfs_root *root) | |||
170 | */ | 171 | */ |
171 | ret = btrfs_find_free_objectid(root, &objectid); | 172 | ret = btrfs_find_free_objectid(root, &objectid); |
172 | if (!ret && objectid <= BTRFS_LAST_FREE_OBJECTID) { | 173 | if (!ret && objectid <= BTRFS_LAST_FREE_OBJECTID) { |
173 | __btrfs_add_free_space(ctl, objectid, | 174 | __btrfs_add_free_space(fs_info, ctl, objectid, |
174 | BTRFS_LAST_FREE_OBJECTID - objectid + 1); | 175 | BTRFS_LAST_FREE_OBJECTID - objectid + 1); |
175 | } | 176 | } |
176 | 177 | ||
177 | tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu", | 178 | tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu", |
178 | root->root_key.objectid); | 179 | root->root_key.objectid); |
179 | if (IS_ERR(tsk)) { | 180 | if (IS_ERR(tsk)) { |
180 | btrfs_warn(root->fs_info, "failed to start inode caching task"); | 181 | btrfs_warn(fs_info, "failed to start inode caching task"); |
181 | btrfs_clear_pending_and_info(root->fs_info, INODE_MAP_CACHE, | 182 | btrfs_clear_pending_and_info(fs_info, INODE_MAP_CACHE, |
182 | "disabling inode map caching"); | 183 | "disabling inode map caching"); |
183 | } | 184 | } |
184 | } | 185 | } |
@@ -209,28 +210,29 @@ again: | |||
209 | 210 | ||
210 | void btrfs_return_ino(struct btrfs_root *root, u64 objectid) | 211 | void btrfs_return_ino(struct btrfs_root *root, u64 objectid) |
211 | { | 212 | { |
213 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
212 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; | 214 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; |
213 | 215 | ||
214 | if (!btrfs_test_opt(root->fs_info, INODE_MAP_CACHE)) | 216 | if (!btrfs_test_opt(fs_info, INODE_MAP_CACHE)) |
215 | return; | 217 | return; |
216 | again: | 218 | again: |
217 | if (root->ino_cache_state == BTRFS_CACHE_FINISHED) { | 219 | if (root->ino_cache_state == BTRFS_CACHE_FINISHED) { |
218 | __btrfs_add_free_space(pinned, objectid, 1); | 220 | __btrfs_add_free_space(fs_info, pinned, objectid, 1); |
219 | } else { | 221 | } else { |
220 | down_write(&root->fs_info->commit_root_sem); | 222 | down_write(&fs_info->commit_root_sem); |
221 | spin_lock(&root->ino_cache_lock); | 223 | spin_lock(&root->ino_cache_lock); |
222 | if (root->ino_cache_state == BTRFS_CACHE_FINISHED) { | 224 | if (root->ino_cache_state == BTRFS_CACHE_FINISHED) { |
223 | spin_unlock(&root->ino_cache_lock); | 225 | spin_unlock(&root->ino_cache_lock); |
224 | up_write(&root->fs_info->commit_root_sem); | 226 | up_write(&fs_info->commit_root_sem); |
225 | goto again; | 227 | goto again; |
226 | } | 228 | } |
227 | spin_unlock(&root->ino_cache_lock); | 229 | spin_unlock(&root->ino_cache_lock); |
228 | 230 | ||
229 | start_caching(root); | 231 | start_caching(root); |
230 | 232 | ||
231 | __btrfs_add_free_space(pinned, objectid, 1); | 233 | __btrfs_add_free_space(fs_info, pinned, objectid, 1); |
232 | 234 | ||
233 | up_write(&root->fs_info->commit_root_sem); | 235 | up_write(&fs_info->commit_root_sem); |
234 | } | 236 | } |
235 | } | 237 | } |
236 | 238 | ||
@@ -277,7 +279,8 @@ void btrfs_unpin_free_ino(struct btrfs_root *root) | |||
277 | rb_erase(&info->offset_index, rbroot); | 279 | rb_erase(&info->offset_index, rbroot); |
278 | spin_unlock(rbroot_lock); | 280 | spin_unlock(rbroot_lock); |
279 | if (add_to_ctl) | 281 | if (add_to_ctl) |
280 | __btrfs_add_free_space(ctl, info->offset, count); | 282 | __btrfs_add_free_space(root->fs_info, ctl, |
283 | info->offset, count); | ||
281 | kmem_cache_free(btrfs_free_space_cachep, info); | 284 | kmem_cache_free(btrfs_free_space_cachep, info); |
282 | } | 285 | } |
283 | } | 286 | } |