btrfs: cleanup, use enum values for btrfs_path reada
Replace the integers by enums for better readability. The value 2 does
not have any meaning since a717531942
"Btrfs: do less aggressive btree readahead" (2009-01-22).
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
4d4ab6d6bc
commit
e4058b54d1
|
@ -2248,7 +2248,6 @@ static void reada_for_search(struct btrfs_root *root,
|
||||||
u64 target;
|
u64 target;
|
||||||
u64 nread = 0;
|
u64 nread = 0;
|
||||||
u64 gen;
|
u64 gen;
|
||||||
int direction = path->reada;
|
|
||||||
struct extent_buffer *eb;
|
struct extent_buffer *eb;
|
||||||
u32 nr;
|
u32 nr;
|
||||||
u32 blocksize;
|
u32 blocksize;
|
||||||
|
@ -2276,16 +2275,16 @@ static void reada_for_search(struct btrfs_root *root,
|
||||||
nr = slot;
|
nr = slot;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (direction < 0) {
|
if (path->reada == READA_BACK) {
|
||||||
if (nr == 0)
|
if (nr == 0)
|
||||||
break;
|
break;
|
||||||
nr--;
|
nr--;
|
||||||
} else if (direction > 0) {
|
} else if (path->reada == READA_FORWARD) {
|
||||||
nr++;
|
nr++;
|
||||||
if (nr >= nritems)
|
if (nr >= nritems)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (path->reada < 0 && objectid) {
|
if (path->reada == READA_BACK && objectid) {
|
||||||
btrfs_node_key(node, &disk_key, nr);
|
btrfs_node_key(node, &disk_key, nr);
|
||||||
if (btrfs_disk_key_objectid(&disk_key) != objectid)
|
if (btrfs_disk_key_objectid(&disk_key) != objectid)
|
||||||
break;
|
break;
|
||||||
|
@ -2493,7 +2492,7 @@ read_block_for_search(struct btrfs_trans_handle *trans,
|
||||||
btrfs_set_path_blocking(p);
|
btrfs_set_path_blocking(p);
|
||||||
|
|
||||||
free_extent_buffer(tmp);
|
free_extent_buffer(tmp);
|
||||||
if (p->reada)
|
if (p->reada != READA_NONE)
|
||||||
reada_for_search(root, p, level, slot, key->objectid);
|
reada_for_search(root, p, level, slot, key->objectid);
|
||||||
|
|
||||||
btrfs_release_path(p);
|
btrfs_release_path(p);
|
||||||
|
|
|
@ -590,6 +590,7 @@ struct btrfs_node {
|
||||||
* The slots array records the index of the item or block pointer
|
* The slots array records the index of the item or block pointer
|
||||||
* used while walking the tree.
|
* used while walking the tree.
|
||||||
*/
|
*/
|
||||||
|
enum { READA_NONE = 0, READA_BACK, READA_FORWARD };
|
||||||
struct btrfs_path {
|
struct btrfs_path {
|
||||||
struct extent_buffer *nodes[BTRFS_MAX_LEVEL];
|
struct extent_buffer *nodes[BTRFS_MAX_LEVEL];
|
||||||
int slots[BTRFS_MAX_LEVEL];
|
int slots[BTRFS_MAX_LEVEL];
|
||||||
|
|
|
@ -438,7 +438,7 @@ static noinline void caching_thread(struct btrfs_work *work)
|
||||||
*/
|
*/
|
||||||
path->skip_locking = 1;
|
path->skip_locking = 1;
|
||||||
path->search_commit_root = 1;
|
path->search_commit_root = 1;
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
key.objectid = last;
|
key.objectid = last;
|
||||||
key.offset = 0;
|
key.offset = 0;
|
||||||
|
@ -2115,7 +2115,7 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
path->leave_spinning = 1;
|
path->leave_spinning = 1;
|
||||||
/* this will setup the path even if it fails to insert the back ref */
|
/* this will setup the path even if it fails to insert the back ref */
|
||||||
ret = insert_inline_extent_backref(trans, fs_info->extent_root, path,
|
ret = insert_inline_extent_backref(trans, fs_info->extent_root, path,
|
||||||
|
@ -2141,7 +2141,7 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
|
||||||
btrfs_mark_buffer_dirty(leaf);
|
btrfs_mark_buffer_dirty(leaf);
|
||||||
btrfs_release_path(path);
|
btrfs_release_path(path);
|
||||||
|
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
path->leave_spinning = 1;
|
path->leave_spinning = 1;
|
||||||
/* now insert the actual backref */
|
/* now insert the actual backref */
|
||||||
ret = insert_extent_backref(trans, root->fs_info->extent_root,
|
ret = insert_extent_backref(trans, root->fs_info->extent_root,
|
||||||
|
@ -2254,7 +2254,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
|
||||||
}
|
}
|
||||||
|
|
||||||
again:
|
again:
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
path->leave_spinning = 1;
|
path->leave_spinning = 1;
|
||||||
ret = btrfs_search_slot(trans, root->fs_info->extent_root, &key,
|
ret = btrfs_search_slot(trans, root->fs_info->extent_root, &key,
|
||||||
path, 0, 1);
|
path, 0, 1);
|
||||||
|
@ -6438,7 +6438,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
path->leave_spinning = 1;
|
path->leave_spinning = 1;
|
||||||
|
|
||||||
is_data = owner_objectid >= BTRFS_FIRST_FREE_OBJECTID;
|
is_data = owner_objectid >= BTRFS_FIRST_FREE_OBJECTID;
|
||||||
|
@ -9688,7 +9688,7 @@ int btrfs_read_block_groups(struct btrfs_root *root)
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy);
|
cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy);
|
||||||
if (btrfs_test_opt(root, SPACE_CACHE) &&
|
if (btrfs_test_opt(root, SPACE_CACHE) &&
|
||||||
|
|
|
@ -202,7 +202,7 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bio->bi_iter.bi_size > PAGE_CACHE_SIZE * 8)
|
if (bio->bi_iter.bi_size > PAGE_CACHE_SIZE * 8)
|
||||||
path->reada = 2;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
WARN_ON(bio->bi_vcnt <= 0);
|
WARN_ON(bio->bi_vcnt <= 0);
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end,
|
||||||
|
|
||||||
if (search_commit) {
|
if (search_commit) {
|
||||||
path->skip_locking = 1;
|
path->skip_locking = 1;
|
||||||
path->reada = 2;
|
path->reada = READA_FORWARD;
|
||||||
path->search_commit_root = 1;
|
path->search_commit_root = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ static int caching_kthread(void *data)
|
||||||
/* Since the commit root is read-only, we can safely skip locking. */
|
/* Since the commit root is read-only, we can safely skip locking. */
|
||||||
path->skip_locking = 1;
|
path->skip_locking = 1;
|
||||||
path->search_commit_root = 1;
|
path->search_commit_root = 1;
|
||||||
path->reada = 2;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
key.objectid = BTRFS_FIRST_FREE_OBJECTID;
|
key.objectid = BTRFS_FIRST_FREE_OBJECTID;
|
||||||
key.offset = 0;
|
key.offset = 0;
|
||||||
|
|
|
@ -3342,7 +3342,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
path->reada = -1;
|
path->reada = READA_BACK;
|
||||||
|
|
||||||
key.objectid = BTRFS_ORPHAN_OBJECTID;
|
key.objectid = BTRFS_ORPHAN_OBJECTID;
|
||||||
key.type = BTRFS_ORPHAN_ITEM_KEY;
|
key.type = BTRFS_ORPHAN_ITEM_KEY;
|
||||||
|
@ -4308,7 +4308,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
path->reada = -1;
|
path->reada = READA_BACK;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We want to drop from the next block forward in case this new size is
|
* We want to drop from the next block forward in case this new size is
|
||||||
|
@ -5744,7 +5744,7 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
if (key_type == BTRFS_DIR_INDEX_KEY) {
|
if (key_type == BTRFS_DIR_INDEX_KEY) {
|
||||||
INIT_LIST_HEAD(&ins_list);
|
INIT_LIST_HEAD(&ins_list);
|
||||||
|
@ -6775,7 +6775,7 @@ again:
|
||||||
* Chances are we'll be called again, so go ahead and do
|
* Chances are we'll be called again, so go ahead and do
|
||||||
* readahead
|
* readahead
|
||||||
*/
|
*/
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = btrfs_lookup_file_extent(trans, root, path,
|
ret = btrfs_lookup_file_extent(trans, root, path,
|
||||||
|
|
|
@ -3478,7 +3478,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
path->reada = 2;
|
path->reada = READA_FORWARD;
|
||||||
/* clone data */
|
/* clone data */
|
||||||
key.objectid = btrfs_ino(src);
|
key.objectid = btrfs_ino(src);
|
||||||
key.type = BTRFS_EXTENT_DATA_KEY;
|
key.type = BTRFS_EXTENT_DATA_KEY;
|
||||||
|
|
|
@ -708,8 +708,8 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
path1->reada = 1;
|
path1->reada = READA_FORWARD;
|
||||||
path2->reada = 2;
|
path2->reada = READA_FORWARD;
|
||||||
|
|
||||||
node = alloc_backref_node(cache);
|
node = alloc_backref_node(cache);
|
||||||
if (!node) {
|
if (!node) {
|
||||||
|
@ -2130,7 +2130,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
reloc_root = root->reloc_root;
|
reloc_root = root->reloc_root;
|
||||||
root_item = &reloc_root->root_item;
|
root_item = &reloc_root->root_item;
|
||||||
|
@ -3527,7 +3527,7 @@ static int find_data_references(struct reloc_control *rc,
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
root = read_fs_root(rc->extent_root->fs_info, ref_root);
|
root = read_fs_root(rc->extent_root->fs_info, ref_root);
|
||||||
if (IS_ERR(root)) {
|
if (IS_ERR(root)) {
|
||||||
|
@ -3917,7 +3917,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
path->reada = 1;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
ret = prepare_to_relocate(rc);
|
ret = prepare_to_relocate(rc);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -4343,7 +4343,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
path->reada = -1;
|
path->reada = READA_BACK;
|
||||||
|
|
||||||
key.objectid = BTRFS_TREE_RELOC_OBJECTID;
|
key.objectid = BTRFS_TREE_RELOC_OBJECTID;
|
||||||
key.type = BTRFS_ROOT_ITEM_KEY;
|
key.type = BTRFS_ROOT_ITEM_KEY;
|
||||||
|
|
|
@ -3507,7 +3507,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
path->reada = 2;
|
path->reada = READA_FORWARD;
|
||||||
path->search_commit_root = 1;
|
path->search_commit_root = 1;
|
||||||
path->skip_locking = 1;
|
path->skip_locking = 1;
|
||||||
|
|
||||||
|
|
|
@ -1102,7 +1102,7 @@ int btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start,
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
path->reada = 2;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
key.objectid = device->devid;
|
key.objectid = device->devid;
|
||||||
key.offset = start;
|
key.offset = start;
|
||||||
|
@ -1271,7 +1271,7 @@ again:
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
path->reada = 2;
|
path->reada = READA_FORWARD;
|
||||||
path->search_commit_root = 1;
|
path->search_commit_root = 1;
|
||||||
path->skip_locking = 1;
|
path->skip_locking = 1;
|
||||||
|
|
||||||
|
@ -4260,7 +4260,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
path->reada = 2;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
lock_chunks(root);
|
lock_chunks(root);
|
||||||
|
|
||||||
|
|
|
@ -283,7 +283,7 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size)
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
if (!path)
|
if (!path)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
path->reada = 2;
|
path->reada = READA_FORWARD;
|
||||||
|
|
||||||
/* search for our xattrs */
|
/* search for our xattrs */
|
||||||
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
|
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
|
||||||
|
|
Loading…
Reference in New Issue