Commit 4b9465cb9e3859186eefa1ca3b990a5849386320
1 parent
e7786c3ae5
Exists in
master
and in
7 other branches
Btrfs: add mount -o inode_cache
This makes the inode map cache default to off until we fix the overflow problem when the free space crcs don't fit inside a single page. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Showing 4 changed files with 34 additions and 1 deletions Side-by-side Diff
fs/btrfs/ctree.h
... | ... | @@ -1340,6 +1340,7 @@ |
1340 | 1340 | #define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14) |
1341 | 1341 | #define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15) |
1342 | 1342 | #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16) |
1343 | +#define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17) | |
1343 | 1344 | |
1344 | 1345 | #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) |
1345 | 1346 | #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) |
fs/btrfs/free-space-cache.c
... | ... | @@ -2536,6 +2536,9 @@ |
2536 | 2536 | int ret = 0; |
2537 | 2537 | u64 root_gen = btrfs_root_generation(&root->root_item); |
2538 | 2538 | |
2539 | + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | |
2540 | + return 0; | |
2541 | + | |
2539 | 2542 | /* |
2540 | 2543 | * If we're unmounting then just return, since this does a search on the |
2541 | 2544 | * normal root and not the commit root and we could deadlock. |
... | ... | @@ -2574,6 +2577,9 @@ |
2574 | 2577 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; |
2575 | 2578 | struct inode *inode; |
2576 | 2579 | int ret; |
2580 | + | |
2581 | + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | |
2582 | + return 0; | |
2577 | 2583 | |
2578 | 2584 | inode = lookup_free_ino_inode(root, path); |
2579 | 2585 | if (IS_ERR(inode)) |
fs/btrfs/inode-map.c
... | ... | @@ -38,6 +38,9 @@ |
38 | 38 | int slot; |
39 | 39 | int ret; |
40 | 40 | |
41 | + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | |
42 | + return 0; | |
43 | + | |
41 | 44 | path = btrfs_alloc_path(); |
42 | 45 | if (!path) |
43 | 46 | return -ENOMEM; |
... | ... | @@ -141,6 +144,9 @@ |
141 | 144 | int ret; |
142 | 145 | u64 objectid; |
143 | 146 | |
147 | + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | |
148 | + return; | |
149 | + | |
144 | 150 | spin_lock(&root->cache_lock); |
145 | 151 | if (root->cached != BTRFS_CACHE_NO) { |
146 | 152 | spin_unlock(&root->cache_lock); |
... | ... | @@ -178,6 +184,9 @@ |
178 | 184 | |
179 | 185 | int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) |
180 | 186 | { |
187 | + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | |
188 | + return btrfs_find_free_objectid(root, objectid); | |
189 | + | |
181 | 190 | again: |
182 | 191 | *objectid = btrfs_find_ino_for_alloc(root); |
183 | 192 | |
... | ... | @@ -201,6 +210,10 @@ |
201 | 210 | { |
202 | 211 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; |
203 | 212 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; |
213 | + | |
214 | + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | |
215 | + return; | |
216 | + | |
204 | 217 | again: |
205 | 218 | if (root->cached == BTRFS_CACHE_FINISHED) { |
206 | 219 | __btrfs_add_free_space(ctl, objectid, 1); |
... | ... | @@ -250,6 +263,9 @@ |
250 | 263 | struct rb_node *n; |
251 | 264 | u64 count; |
252 | 265 | |
266 | + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | |
267 | + return; | |
268 | + | |
253 | 269 | while (1) { |
254 | 270 | n = rb_first(rbroot); |
255 | 271 | if (!n) |
256 | 272 | |
... | ... | @@ -399,9 +415,13 @@ |
399 | 415 | root != root->fs_info->tree_root) |
400 | 416 | return 0; |
401 | 417 | |
418 | + if (!btrfs_test_opt(root, INODE_MAP_CACHE)) | |
419 | + return 0; | |
420 | + | |
402 | 421 | path = btrfs_alloc_path(); |
403 | 422 | if (!path) |
404 | 423 | return -ENOMEM; |
424 | + | |
405 | 425 | again: |
406 | 426 | inode = lookup_free_ino_inode(root, path); |
407 | 427 | if (IS_ERR(inode) && PTR_ERR(inode) != -ENOENT) { |
fs/btrfs/super.c
... | ... | @@ -160,7 +160,8 @@ |
160 | 160 | Opt_compress_type, Opt_compress_force, Opt_compress_force_type, |
161 | 161 | Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard, |
162 | 162 | Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed, |
163 | - Opt_enospc_debug, Opt_subvolrootid, Opt_defrag, Opt_err, | |
163 | + Opt_enospc_debug, Opt_subvolrootid, Opt_defrag, | |
164 | + Opt_inode_cache, Opt_err, | |
164 | 165 | }; |
165 | 166 | |
166 | 167 | static match_table_t tokens = { |
... | ... | @@ -192,6 +193,7 @@ |
192 | 193 | {Opt_enospc_debug, "enospc_debug"}, |
193 | 194 | {Opt_subvolrootid, "subvolrootid=%d"}, |
194 | 195 | {Opt_defrag, "autodefrag"}, |
196 | + {Opt_inode_cache, "inode_cache"}, | |
195 | 197 | {Opt_err, NULL}, |
196 | 198 | }; |
197 | 199 | |
... | ... | @@ -359,6 +361,10 @@ |
359 | 361 | case Opt_space_cache: |
360 | 362 | printk(KERN_INFO "btrfs: enabling disk space caching\n"); |
361 | 363 | btrfs_set_opt(info->mount_opt, SPACE_CACHE); |
364 | + break; | |
365 | + case Opt_inode_cache: | |
366 | + printk(KERN_INFO "btrfs: enabling inode map caching\n"); | |
367 | + btrfs_set_opt(info->mount_opt, INODE_MAP_CACHE); | |
362 | 368 | break; |
363 | 369 | case Opt_clear_cache: |
364 | 370 | printk(KERN_INFO "btrfs: force clearing of disk cache\n"); |