Commit de78b51a2852bddccd6535e9e12de65f92787a1e
Committed by
Josef Bacik
1 parent
e4a2bcaca9
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
btrfs: remove cache only arguments from defrag path
The entry point at the defrag ioctl always sets "cache only" to 0; the codepaths haven't run for a long time as far as I can tell. Chris says they're dead code, so remove them. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Showing 7 changed files with 32 additions and 82 deletions Side-by-side Diff
fs/btrfs/ctree.c
... | ... | @@ -1442,7 +1442,7 @@ |
1442 | 1442 | */ |
1443 | 1443 | int btrfs_realloc_node(struct btrfs_trans_handle *trans, |
1444 | 1444 | struct btrfs_root *root, struct extent_buffer *parent, |
1445 | - int start_slot, int cache_only, u64 *last_ret, | |
1445 | + int start_slot, u64 *last_ret, | |
1446 | 1446 | struct btrfs_key *progress) |
1447 | 1447 | { |
1448 | 1448 | struct extent_buffer *cur; |
... | ... | @@ -1462,8 +1462,6 @@ |
1462 | 1462 | struct btrfs_disk_key disk_key; |
1463 | 1463 | |
1464 | 1464 | parent_level = btrfs_header_level(parent); |
1465 | - if (cache_only && parent_level != 1) | |
1466 | - return 0; | |
1467 | 1465 | |
1468 | 1466 | WARN_ON(trans->transaction != root->fs_info->running_transaction); |
1469 | 1467 | WARN_ON(trans->transid != root->fs_info->generation); |
... | ... | @@ -1509,10 +1507,6 @@ |
1509 | 1507 | else |
1510 | 1508 | uptodate = 0; |
1511 | 1509 | if (!cur || !uptodate) { |
1512 | - if (cache_only) { | |
1513 | - free_extent_buffer(cur); | |
1514 | - continue; | |
1515 | - } | |
1516 | 1510 | if (!cur) { |
1517 | 1511 | cur = read_tree_block(root, blocknr, |
1518 | 1512 | blocksize, gen); |
... | ... | @@ -4826,8 +4820,8 @@ |
4826 | 4820 | |
4827 | 4821 | /* |
4828 | 4822 | * A helper function to walk down the tree starting at min_key, and looking |
4829 | - * for nodes or leaves that are either in cache or have a minimum | |
4830 | - * transaction id. This is used by the btree defrag code, and tree logging | |
4823 | + * for nodes or leaves that are have a minimum transaction id. | |
4824 | + * This is used by the btree defrag code, and tree logging | |
4831 | 4825 | * |
4832 | 4826 | * This does not cow, but it does stuff the starting key it finds back |
4833 | 4827 | * into min_key, so you can call btrfs_search_slot with cow=1 on the |
... | ... | @@ -4848,7 +4842,7 @@ |
4848 | 4842 | */ |
4849 | 4843 | int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key, |
4850 | 4844 | struct btrfs_key *max_key, |
4851 | - struct btrfs_path *path, int cache_only, | |
4845 | + struct btrfs_path *path, | |
4852 | 4846 | u64 min_trans) |
4853 | 4847 | { |
4854 | 4848 | struct extent_buffer *cur; |
4855 | 4849 | |
... | ... | @@ -4888,15 +4882,12 @@ |
4888 | 4882 | if (sret && slot > 0) |
4889 | 4883 | slot--; |
4890 | 4884 | /* |
4891 | - * check this node pointer against the cache_only and | |
4892 | - * min_trans parameters. If it isn't in cache or is too | |
4893 | - * old, skip to the next one. | |
4885 | + * check this node pointer against the min_trans parameters. | |
4886 | + * If it is too old, old, skip to the next one. | |
4894 | 4887 | */ |
4895 | 4888 | while (slot < nritems) { |
4896 | 4889 | u64 blockptr; |
4897 | 4890 | u64 gen; |
4898 | - struct extent_buffer *tmp; | |
4899 | - struct btrfs_disk_key disk_key; | |
4900 | 4891 | |
4901 | 4892 | blockptr = btrfs_node_blockptr(cur, slot); |
4902 | 4893 | gen = btrfs_node_ptr_generation(cur, slot); |
... | ... | @@ -4904,27 +4895,7 @@ |
4904 | 4895 | slot++; |
4905 | 4896 | continue; |
4906 | 4897 | } |
4907 | - if (!cache_only) | |
4908 | - break; | |
4909 | - | |
4910 | - if (max_key) { | |
4911 | - btrfs_node_key(cur, &disk_key, slot); | |
4912 | - if (comp_keys(&disk_key, max_key) >= 0) { | |
4913 | - ret = 1; | |
4914 | - goto out; | |
4915 | - } | |
4916 | - } | |
4917 | - | |
4918 | - tmp = btrfs_find_tree_block(root, blockptr, | |
4919 | - btrfs_level_size(root, level - 1)); | |
4920 | - | |
4921 | - if (tmp && btrfs_buffer_uptodate(tmp, gen, 1) > 0) { | |
4922 | - free_extent_buffer(tmp); | |
4923 | - break; | |
4924 | - } | |
4925 | - if (tmp) | |
4926 | - free_extent_buffer(tmp); | |
4927 | - slot++; | |
4898 | + break; | |
4928 | 4899 | } |
4929 | 4900 | find_next_key: |
4930 | 4901 | /* |
... | ... | @@ -4935,7 +4906,7 @@ |
4935 | 4906 | path->slots[level] = slot; |
4936 | 4907 | btrfs_set_path_blocking(path); |
4937 | 4908 | sret = btrfs_find_next_key(root, path, min_key, level, |
4938 | - cache_only, min_trans); | |
4909 | + min_trans); | |
4939 | 4910 | if (sret == 0) { |
4940 | 4911 | btrfs_release_path(path); |
4941 | 4912 | goto again; |
... | ... | @@ -5400,8 +5371,7 @@ |
5400 | 5371 | /* |
5401 | 5372 | * this is similar to btrfs_next_leaf, but does not try to preserve |
5402 | 5373 | * and fixup the path. It looks for and returns the next key in the |
5403 | - * tree based on the current path and the cache_only and min_trans | |
5404 | - * parameters. | |
5374 | + * tree based on the current path and the min_trans parameters. | |
5405 | 5375 | * |
5406 | 5376 | * 0 is returned if another key is found, < 0 if there are any errors |
5407 | 5377 | * and 1 is returned if there are no higher keys in the tree |
... | ... | @@ -5410,8 +5380,7 @@ |
5410 | 5380 | * calling this function. |
5411 | 5381 | */ |
5412 | 5382 | int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, |
5413 | - struct btrfs_key *key, int level, | |
5414 | - int cache_only, u64 min_trans) | |
5383 | + struct btrfs_key *key, int level, u64 min_trans) | |
5415 | 5384 | { |
5416 | 5385 | int slot; |
5417 | 5386 | struct extent_buffer *c; |
5418 | 5387 | |
... | ... | @@ -5462,22 +5431,8 @@ |
5462 | 5431 | if (level == 0) |
5463 | 5432 | btrfs_item_key_to_cpu(c, key, slot); |
5464 | 5433 | else { |
5465 | - u64 blockptr = btrfs_node_blockptr(c, slot); | |
5466 | 5434 | u64 gen = btrfs_node_ptr_generation(c, slot); |
5467 | 5435 | |
5468 | - if (cache_only) { | |
5469 | - struct extent_buffer *cur; | |
5470 | - cur = btrfs_find_tree_block(root, blockptr, | |
5471 | - btrfs_level_size(root, level - 1)); | |
5472 | - if (!cur || | |
5473 | - btrfs_buffer_uptodate(cur, gen, 1) <= 0) { | |
5474 | - slot++; | |
5475 | - if (cur) | |
5476 | - free_extent_buffer(cur); | |
5477 | - goto next; | |
5478 | - } | |
5479 | - free_extent_buffer(cur); | |
5480 | - } | |
5481 | 5436 | if (gen < min_trans) { |
5482 | 5437 | slot++; |
5483 | 5438 | goto next; |
fs/btrfs/ctree.h
... | ... | @@ -3125,10 +3125,10 @@ |
3125 | 3125 | struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root); |
3126 | 3126 | int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, |
3127 | 3127 | struct btrfs_key *key, int lowest_level, |
3128 | - int cache_only, u64 min_trans); | |
3128 | + u64 min_trans); | |
3129 | 3129 | int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key, |
3130 | 3130 | struct btrfs_key *max_key, |
3131 | - struct btrfs_path *path, int cache_only, | |
3131 | + struct btrfs_path *path, | |
3132 | 3132 | u64 min_trans); |
3133 | 3133 | enum btrfs_compare_tree_result { |
3134 | 3134 | BTRFS_COMPARE_TREE_NEW, |
... | ... | @@ -3181,7 +3181,7 @@ |
3181 | 3181 | int find_higher, int return_any); |
3182 | 3182 | int btrfs_realloc_node(struct btrfs_trans_handle *trans, |
3183 | 3183 | struct btrfs_root *root, struct extent_buffer *parent, |
3184 | - int start_slot, int cache_only, u64 *last_ret, | |
3184 | + int start_slot, u64 *last_ret, | |
3185 | 3185 | struct btrfs_key *progress); |
3186 | 3186 | void btrfs_release_path(struct btrfs_path *p); |
3187 | 3187 | struct btrfs_path *btrfs_alloc_path(void); |
... | ... | @@ -3576,7 +3576,7 @@ |
3576 | 3576 | |
3577 | 3577 | /* tree-defrag.c */ |
3578 | 3578 | int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, |
3579 | - struct btrfs_root *root, int cache_only); | |
3579 | + struct btrfs_root *root); | |
3580 | 3580 | |
3581 | 3581 | /* sysfs.c */ |
3582 | 3582 | int btrfs_init_sysfs(void); |
fs/btrfs/ioctl.c
... | ... | @@ -818,7 +818,7 @@ |
818 | 818 | |
819 | 819 | while(1) { |
820 | 820 | ret = btrfs_search_forward(root, &min_key, &max_key, |
821 | - path, 0, newer_than); | |
821 | + path, newer_than); | |
822 | 822 | if (ret != 0) |
823 | 823 | goto none; |
824 | 824 | if (min_key.objectid != ino) |
... | ... | @@ -1864,7 +1864,7 @@ |
1864 | 1864 | path->keep_locks = 1; |
1865 | 1865 | |
1866 | 1866 | while(1) { |
1867 | - ret = btrfs_search_forward(root, &key, &max_key, path, 0, | |
1867 | + ret = btrfs_search_forward(root, &key, &max_key, path, | |
1868 | 1868 | sk->min_transid); |
1869 | 1869 | if (ret != 0) { |
1870 | 1870 | if (ret > 0) |
1871 | 1871 | |
... | ... | @@ -2212,10 +2212,10 @@ |
2212 | 2212 | ret = -EPERM; |
2213 | 2213 | goto out; |
2214 | 2214 | } |
2215 | - ret = btrfs_defrag_root(root, 0); | |
2215 | + ret = btrfs_defrag_root(root); | |
2216 | 2216 | if (ret) |
2217 | 2217 | goto out; |
2218 | - ret = btrfs_defrag_root(root->fs_info->extent_root, 0); | |
2218 | + ret = btrfs_defrag_root(root->fs_info->extent_root); | |
2219 | 2219 | break; |
2220 | 2220 | case S_IFREG: |
2221 | 2221 | if (!(file->f_mode & FMODE_WRITE)) { |
fs/btrfs/transaction.c
... | ... | @@ -959,10 +959,10 @@ |
959 | 959 | } |
960 | 960 | |
961 | 961 | /* |
962 | - * defrag a given btree. If cacheonly == 1, this won't read from the disk, | |
963 | - * otherwise every leaf in the btree is read and defragged. | |
962 | + * defrag a given btree. | |
963 | + * Every leaf in the btree is read and defragged. | |
964 | 964 | */ |
965 | -int btrfs_defrag_root(struct btrfs_root *root, int cacheonly) | |
965 | +int btrfs_defrag_root(struct btrfs_root *root) | |
966 | 966 | { |
967 | 967 | struct btrfs_fs_info *info = root->fs_info; |
968 | 968 | struct btrfs_trans_handle *trans; |
... | ... | @@ -976,7 +976,7 @@ |
976 | 976 | if (IS_ERR(trans)) |
977 | 977 | return PTR_ERR(trans); |
978 | 978 | |
979 | - ret = btrfs_defrag_leaves(trans, root, cacheonly); | |
979 | + ret = btrfs_defrag_leaves(trans, root); | |
980 | 980 | |
981 | 981 | btrfs_end_transaction(trans, root); |
982 | 982 | btrfs_btree_balance_dirty(info->tree_root); |
fs/btrfs/transaction.h
... | ... | @@ -117,7 +117,7 @@ |
117 | 117 | struct btrfs_root *root); |
118 | 118 | |
119 | 119 | int btrfs_add_dead_root(struct btrfs_root *root); |
120 | -int btrfs_defrag_root(struct btrfs_root *root, int cacheonly); | |
120 | +int btrfs_defrag_root(struct btrfs_root *root); | |
121 | 121 | int btrfs_clean_old_snapshots(struct btrfs_root *root); |
122 | 122 | int btrfs_commit_transaction(struct btrfs_trans_handle *trans, |
123 | 123 | struct btrfs_root *root); |
fs/btrfs/tree-defrag.c
... | ... | @@ -23,13 +23,14 @@ |
23 | 23 | #include "transaction.h" |
24 | 24 | #include "locking.h" |
25 | 25 | |
26 | -/* defrag all the leaves in a given btree. If cache_only == 1, don't read | |
27 | - * things from disk, otherwise read all the leaves and try to get key order to | |
26 | +/* | |
27 | + * Defrag all the leaves in a given btree. | |
28 | + * Read all the leaves and try to get key order to | |
28 | 29 | * better reflect disk order |
29 | 30 | */ |
30 | 31 | |
31 | 32 | int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, |
32 | - struct btrfs_root *root, int cache_only) | |
33 | + struct btrfs_root *root) | |
33 | 34 | { |
34 | 35 | struct btrfs_path *path = NULL; |
35 | 36 | struct btrfs_key key; |
... | ... | @@ -41,9 +42,6 @@ |
41 | 42 | u64 last_ret = 0; |
42 | 43 | u64 min_trans = 0; |
43 | 44 | |
44 | - if (cache_only) | |
45 | - goto out; | |
46 | - | |
47 | 45 | if (root->fs_info->extent_root == root) { |
48 | 46 | /* |
49 | 47 | * there's recursion here right now in the tree locking, |
50 | 48 | |
... | ... | @@ -86,11 +84,8 @@ |
86 | 84 | } |
87 | 85 | |
88 | 86 | path->keep_locks = 1; |
89 | - if (cache_only) | |
90 | - min_trans = root->defrag_trans_start; | |
91 | 87 | |
92 | - ret = btrfs_search_forward(root, &key, NULL, path, | |
93 | - cache_only, min_trans); | |
88 | + ret = btrfs_search_forward(root, &key, NULL, path, min_trans); | |
94 | 89 | if (ret < 0) |
95 | 90 | goto out; |
96 | 91 | if (ret > 0) { |
97 | 92 | |
... | ... | @@ -109,11 +104,11 @@ |
109 | 104 | goto out; |
110 | 105 | } |
111 | 106 | path->slots[1] = btrfs_header_nritems(path->nodes[1]); |
112 | - next_key_ret = btrfs_find_next_key(root, path, &key, 1, cache_only, | |
107 | + next_key_ret = btrfs_find_next_key(root, path, &key, 1, | |
113 | 108 | min_trans); |
114 | 109 | ret = btrfs_realloc_node(trans, root, |
115 | 110 | path->nodes[1], 0, |
116 | - cache_only, &last_ret, | |
111 | + &last_ret, | |
117 | 112 | &root->defrag_progress); |
118 | 113 | if (ret) { |
119 | 114 | WARN_ON(ret == -EAGAIN); |
fs/btrfs/tree-log.c
... | ... | @@ -2738,7 +2738,7 @@ |
2738 | 2738 | path->keep_locks = 1; |
2739 | 2739 | |
2740 | 2740 | ret = btrfs_search_forward(root, &min_key, &max_key, |
2741 | - path, 0, trans->transid); | |
2741 | + path, trans->transid); | |
2742 | 2742 | |
2743 | 2743 | /* |
2744 | 2744 | * we didn't find anything from this transaction, see if there |
... | ... | @@ -3680,7 +3680,7 @@ |
3680 | 3680 | while (1) { |
3681 | 3681 | ins_nr = 0; |
3682 | 3682 | ret = btrfs_search_forward(root, &min_key, &max_key, |
3683 | - path, 0, trans->transid); | |
3683 | + path, trans->transid); | |
3684 | 3684 | if (ret != 0) |
3685 | 3685 | break; |
3686 | 3686 | again: |