aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2013-01-31 13:21:12 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-02-20 12:59:36 -0500
commitde78b51a2852bddccd6535e9e12de65f92787a1e (patch)
tree199124b0e3bf96a1edbcd184eba34e0d8bffbe24
parente4a2bcaca9643e7430207810653222fc5187f2be (diff)
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>
-rw-r--r--fs/btrfs/ctree.c65
-rw-r--r--fs/btrfs/ctree.h8
-rw-r--r--fs/btrfs/ioctl.c8
-rw-r--r--fs/btrfs/transaction.c8
-rw-r--r--fs/btrfs/transaction.h2
-rw-r--r--fs/btrfs/tree-defrag.c19
-rw-r--r--fs/btrfs/tree-log.c4
7 files changed, 32 insertions, 82 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 35444013f0cf..ecd25a1b4e51 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1442,7 +1442,7 @@ int btrfs_comp_cpu_keys(struct btrfs_key *k1, struct btrfs_key *k2)
1442 */ 1442 */
1443int btrfs_realloc_node(struct btrfs_trans_handle *trans, 1443int btrfs_realloc_node(struct btrfs_trans_handle *trans,
1444 struct btrfs_root *root, struct extent_buffer *parent, 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 struct btrfs_key *progress) 1446 struct btrfs_key *progress)
1447{ 1447{
1448 struct extent_buffer *cur; 1448 struct extent_buffer *cur;
@@ -1462,8 +1462,6 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
1462 struct btrfs_disk_key disk_key; 1462 struct btrfs_disk_key disk_key;
1463 1463
1464 parent_level = btrfs_header_level(parent); 1464 parent_level = btrfs_header_level(parent);
1465 if (cache_only && parent_level != 1)
1466 return 0;
1467 1465
1468 WARN_ON(trans->transaction != root->fs_info->running_transaction); 1466 WARN_ON(trans->transaction != root->fs_info->running_transaction);
1469 WARN_ON(trans->transid != root->fs_info->generation); 1467 WARN_ON(trans->transid != root->fs_info->generation);
@@ -1509,10 +1507,6 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
1509 else 1507 else
1510 uptodate = 0; 1508 uptodate = 0;
1511 if (!cur || !uptodate) { 1509 if (!cur || !uptodate) {
1512 if (cache_only) {
1513 free_extent_buffer(cur);
1514 continue;
1515 }
1516 if (!cur) { 1510 if (!cur) {
1517 cur = read_tree_block(root, blocknr, 1511 cur = read_tree_block(root, blocknr,
1518 blocksize, gen); 1512 blocksize, gen);
@@ -4826,8 +4820,8 @@ int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path)
4826 4820
4827/* 4821/*
4828 * A helper function to walk down the tree starting at min_key, and looking 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 4823 * for nodes or leaves that are have a minimum transaction id.
4830 * transaction id. This is used by the btree defrag code, and tree logging 4824 * This is used by the btree defrag code, and tree logging
4831 * 4825 *
4832 * This does not cow, but it does stuff the starting key it finds back 4826 * This does not cow, but it does stuff the starting key it finds back
4833 * into min_key, so you can call btrfs_search_slot with cow=1 on the 4827 * into min_key, so you can call btrfs_search_slot with cow=1 on the
@@ -4848,7 +4842,7 @@ int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path)
4848 */ 4842 */
4849int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key, 4843int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
4850 struct btrfs_key *max_key, 4844 struct btrfs_key *max_key,
4851 struct btrfs_path *path, int cache_only, 4845 struct btrfs_path *path,
4852 u64 min_trans) 4846 u64 min_trans)
4853{ 4847{
4854 struct extent_buffer *cur; 4848 struct extent_buffer *cur;
@@ -4888,15 +4882,12 @@ again:
4888 if (sret && slot > 0) 4882 if (sret && slot > 0)
4889 slot--; 4883 slot--;
4890 /* 4884 /*
4891 * check this node pointer against the cache_only and 4885 * check this node pointer against the min_trans parameters.
4892 * min_trans parameters. If it isn't in cache or is too 4886 * If it is too old, old, skip to the next one.
4893 * old, skip to the next one.
4894 */ 4887 */
4895 while (slot < nritems) { 4888 while (slot < nritems) {
4896 u64 blockptr; 4889 u64 blockptr;
4897 u64 gen; 4890 u64 gen;
4898 struct extent_buffer *tmp;
4899 struct btrfs_disk_key disk_key;
4900 4891
4901 blockptr = btrfs_node_blockptr(cur, slot); 4892 blockptr = btrfs_node_blockptr(cur, slot);
4902 gen = btrfs_node_ptr_generation(cur, slot); 4893 gen = btrfs_node_ptr_generation(cur, slot);
@@ -4904,27 +4895,7 @@ again:
4904 slot++; 4895 slot++;
4905 continue; 4896 continue;
4906 } 4897 }
4907 if (!cache_only) 4898 break;
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++;
4928 } 4899 }
4929find_next_key: 4900find_next_key:
4930 /* 4901 /*
@@ -4935,7 +4906,7 @@ find_next_key:
4935 path->slots[level] = slot; 4906 path->slots[level] = slot;
4936 btrfs_set_path_blocking(path); 4907 btrfs_set_path_blocking(path);
4937 sret = btrfs_find_next_key(root, path, min_key, level, 4908 sret = btrfs_find_next_key(root, path, min_key, level,
4938 cache_only, min_trans); 4909 min_trans);
4939 if (sret == 0) { 4910 if (sret == 0) {
4940 btrfs_release_path(path); 4911 btrfs_release_path(path);
4941 goto again; 4912 goto again;
@@ -5400,8 +5371,7 @@ out:
5400/* 5371/*
5401 * this is similar to btrfs_next_leaf, but does not try to preserve 5372 * this is similar to btrfs_next_leaf, but does not try to preserve
5402 * and fixup the path. It looks for and returns the next key in the 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 5374 * tree based on the current path and the min_trans parameters.
5404 * parameters.
5405 * 5375 *
5406 * 0 is returned if another key is found, < 0 if there are any errors 5376 * 0 is returned if another key is found, < 0 if there are any errors
5407 * and 1 is returned if there are no higher keys in the tree 5377 * and 1 is returned if there are no higher keys in the tree
@@ -5410,8 +5380,7 @@ out:
5410 * calling this function. 5380 * calling this function.
5411 */ 5381 */
5412int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, 5382int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path,
5413 struct btrfs_key *key, int level, 5383 struct btrfs_key *key, int level, u64 min_trans)
5414 int cache_only, u64 min_trans)
5415{ 5384{
5416 int slot; 5385 int slot;
5417 struct extent_buffer *c; 5386 struct extent_buffer *c;
@@ -5462,22 +5431,8 @@ next:
5462 if (level == 0) 5431 if (level == 0)
5463 btrfs_item_key_to_cpu(c, key, slot); 5432 btrfs_item_key_to_cpu(c, key, slot);
5464 else { 5433 else {
5465 u64 blockptr = btrfs_node_blockptr(c, slot);
5466 u64 gen = btrfs_node_ptr_generation(c, slot); 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 if (gen < min_trans) { 5436 if (gen < min_trans) {
5482 slot++; 5437 slot++;
5483 goto next; 5438 goto next;
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 1e3a994e1899..7e2cffd2a5d8 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3125,10 +3125,10 @@ struct extent_buffer *btrfs_root_node(struct btrfs_root *root);
3125struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root); 3125struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root);
3126int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, 3126int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path,
3127 struct btrfs_key *key, int lowest_level, 3127 struct btrfs_key *key, int lowest_level,
3128 int cache_only, u64 min_trans); 3128 u64 min_trans);
3129int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key, 3129int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key,
3130 struct btrfs_key *max_key, 3130 struct btrfs_key *max_key,
3131 struct btrfs_path *path, int cache_only, 3131 struct btrfs_path *path,
3132 u64 min_trans); 3132 u64 min_trans);
3133enum btrfs_compare_tree_result { 3133enum btrfs_compare_tree_result {
3134 BTRFS_COMPARE_TREE_NEW, 3134 BTRFS_COMPARE_TREE_NEW,
@@ -3181,7 +3181,7 @@ int btrfs_search_slot_for_read(struct btrfs_root *root,
3181 int find_higher, int return_any); 3181 int find_higher, int return_any);
3182int btrfs_realloc_node(struct btrfs_trans_handle *trans, 3182int btrfs_realloc_node(struct btrfs_trans_handle *trans,
3183 struct btrfs_root *root, struct extent_buffer *parent, 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 struct btrfs_key *progress); 3185 struct btrfs_key *progress);
3186void btrfs_release_path(struct btrfs_path *p); 3186void btrfs_release_path(struct btrfs_path *p);
3187struct btrfs_path *btrfs_alloc_path(void); 3187struct btrfs_path *btrfs_alloc_path(void);
@@ -3576,7 +3576,7 @@ int btrfs_dirty_pages(struct btrfs_root *root, struct inode *inode,
3576 3576
3577/* tree-defrag.c */ 3577/* tree-defrag.c */
3578int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, 3578int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
3579 struct btrfs_root *root, int cache_only); 3579 struct btrfs_root *root);
3580 3580
3581/* sysfs.c */ 3581/* sysfs.c */
3582int btrfs_init_sysfs(void); 3582int btrfs_init_sysfs(void);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 96ecefc1724f..daea831f3d36 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -818,7 +818,7 @@ static int find_new_extents(struct btrfs_root *root,
818 818
819 while(1) { 819 while(1) {
820 ret = btrfs_search_forward(root, &min_key, &max_key, 820 ret = btrfs_search_forward(root, &min_key, &max_key,
821 path, 0, newer_than); 821 path, newer_than);
822 if (ret != 0) 822 if (ret != 0)
823 goto none; 823 goto none;
824 if (min_key.objectid != ino) 824 if (min_key.objectid != ino)
@@ -1864,7 +1864,7 @@ static noinline int search_ioctl(struct inode *inode,
1864 path->keep_locks = 1; 1864 path->keep_locks = 1;
1865 1865
1866 while(1) { 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 sk->min_transid); 1868 sk->min_transid);
1869 if (ret != 0) { 1869 if (ret != 0) {
1870 if (ret > 0) 1870 if (ret > 0)
@@ -2212,10 +2212,10 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
2212 ret = -EPERM; 2212 ret = -EPERM;
2213 goto out; 2213 goto out;
2214 } 2214 }
2215 ret = btrfs_defrag_root(root, 0); 2215 ret = btrfs_defrag_root(root);
2216 if (ret) 2216 if (ret)
2217 goto out; 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 break; 2219 break;
2220 case S_IFREG: 2220 case S_IFREG:
2221 if (!(file->f_mode & FMODE_WRITE)) { 2221 if (!(file->f_mode & FMODE_WRITE)) {
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 5144ad19ef47..60481a53e004 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -959,10 +959,10 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans,
959} 959}
960 960
961/* 961/*
962 * defrag a given btree. If cacheonly == 1, this won't read from the disk, 962 * defrag a given btree.
963 * otherwise every leaf in the btree is read and defragged. 963 * Every leaf in the btree is read and defragged.
964 */ 964 */
965int btrfs_defrag_root(struct btrfs_root *root, int cacheonly) 965int btrfs_defrag_root(struct btrfs_root *root)
966{ 966{
967 struct btrfs_fs_info *info = root->fs_info; 967 struct btrfs_fs_info *info = root->fs_info;
968 struct btrfs_trans_handle *trans; 968 struct btrfs_trans_handle *trans;
@@ -976,7 +976,7 @@ int btrfs_defrag_root(struct btrfs_root *root, int cacheonly)
976 if (IS_ERR(trans)) 976 if (IS_ERR(trans))
977 return PTR_ERR(trans); 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 btrfs_end_transaction(trans, root); 981 btrfs_end_transaction(trans, root);
982 btrfs_btree_balance_dirty(info->tree_root); 982 btrfs_btree_balance_dirty(info->tree_root);
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 69700f7b20ac..46628210e5d8 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -117,7 +117,7 @@ int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
117 struct btrfs_root *root); 117 struct btrfs_root *root);
118 118
119int btrfs_add_dead_root(struct btrfs_root *root); 119int btrfs_add_dead_root(struct btrfs_root *root);
120int btrfs_defrag_root(struct btrfs_root *root, int cacheonly); 120int btrfs_defrag_root(struct btrfs_root *root);
121int btrfs_clean_old_snapshots(struct btrfs_root *root); 121int btrfs_clean_old_snapshots(struct btrfs_root *root);
122int btrfs_commit_transaction(struct btrfs_trans_handle *trans, 122int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
123 struct btrfs_root *root); 123 struct btrfs_root *root);
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index 3b580ee8ab1d..94e05c1f118a 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -23,13 +23,14 @@
23#include "transaction.h" 23#include "transaction.h"
24#include "locking.h" 24#include "locking.h"
25 25
26/* defrag all the leaves in a given btree. If cache_only == 1, don't read 26/*
27 * things from disk, otherwise read all the leaves and try to get key order to 27 * Defrag all the leaves in a given btree.
28 * Read all the leaves and try to get key order to
28 * better reflect disk order 29 * better reflect disk order
29 */ 30 */
30 31
31int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, 32int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
32 struct btrfs_root *root, int cache_only) 33 struct btrfs_root *root)
33{ 34{
34 struct btrfs_path *path = NULL; 35 struct btrfs_path *path = NULL;
35 struct btrfs_key key; 36 struct btrfs_key key;
@@ -41,9 +42,6 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
41 u64 last_ret = 0; 42 u64 last_ret = 0;
42 u64 min_trans = 0; 43 u64 min_trans = 0;
43 44
44 if (cache_only)
45 goto out;
46
47 if (root->fs_info->extent_root == root) { 45 if (root->fs_info->extent_root == root) {
48 /* 46 /*
49 * there's recursion here right now in the tree locking, 47 * there's recursion here right now in the tree locking,
@@ -86,11 +84,8 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
86 } 84 }
87 85
88 path->keep_locks = 1; 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, 88 ret = btrfs_search_forward(root, &key, NULL, path, min_trans);
93 cache_only, min_trans);
94 if (ret < 0) 89 if (ret < 0)
95 goto out; 90 goto out;
96 if (ret > 0) { 91 if (ret > 0) {
@@ -109,11 +104,11 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
109 goto out; 104 goto out;
110 } 105 }
111 path->slots[1] = btrfs_header_nritems(path->nodes[1]); 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 min_trans); 108 min_trans);
114 ret = btrfs_realloc_node(trans, root, 109 ret = btrfs_realloc_node(trans, root,
115 path->nodes[1], 0, 110 path->nodes[1], 0,
116 cache_only, &last_ret, 111 &last_ret,
117 &root->defrag_progress); 112 &root->defrag_progress);
118 if (ret) { 113 if (ret) {
119 WARN_ON(ret == -EAGAIN); 114 WARN_ON(ret == -EAGAIN);
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index deb7f66356bd..1a79087c4575 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2738,7 +2738,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
2738 path->keep_locks = 1; 2738 path->keep_locks = 1;
2739 2739
2740 ret = btrfs_search_forward(root, &min_key, &max_key, 2740 ret = btrfs_search_forward(root, &min_key, &max_key,
2741 path, 0, trans->transid); 2741 path, trans->transid);
2742 2742
2743 /* 2743 /*
2744 * we didn't find anything from this transaction, see if there 2744 * we didn't find anything from this transaction, see if there
@@ -3680,7 +3680,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
3680 while (1) { 3680 while (1) {
3681 ins_nr = 0; 3681 ins_nr = 0;
3682 ret = btrfs_search_forward(root, &min_key, &max_key, 3682 ret = btrfs_search_forward(root, &min_key, &max_key,
3683 path, 0, trans->transid); 3683 path, trans->transid);
3684 if (ret != 0) 3684 if (ret != 0)
3685 break; 3685 break;
3686again: 3686again: