summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-08-07 15:52:22 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-08-07 15:52:22 -0400
commit3c69faecb8d83cb2ef085a98b196a3fecea67725 (patch)
treed764502dd93bcd767c2130518d0c1fe00a7e96ff /fs/btrfs/inode.c
parent9f3a742736cecda5a8778be70faa2f779458839f (diff)
downloadtalos-op-linux-3c69faecb8d83cb2ef085a98b196a3fecea67725.tar.gz
talos-op-linux-3c69faecb8d83cb2ef085a98b196a3fecea67725.zip
Btrfs: Fold some btree readahead routines into something more generic.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c69
1 files changed, 2 insertions, 67 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index fa9c531c86b7..3889032fc449 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -375,40 +375,6 @@ static int btrfs_free_inode(struct btrfs_trans_handle *trans,
}
/*
- * truncates go from a high offset to a low offset. So, walk
- * from hi to lo in the node and issue readas. Stop when you find
- * keys from a different objectid
- */
-static void reada_truncate(struct btrfs_root *root, struct btrfs_path *path,
- u64 objectid)
-{
- struct btrfs_node *node;
- int i;
- int nritems;
- u64 item_objectid;
- u64 blocknr;
- int slot;
- int ret;
-
- if (!path->nodes[1])
- return;
- node = btrfs_buffer_node(path->nodes[1]);
- slot = path->slots[1];
- if (slot == 0)
- return;
- nritems = btrfs_header_nritems(&node->header);
- for (i = slot - 1; i >= 0; i--) {
- item_objectid = btrfs_disk_key_objectid(&node->ptrs[i].key);
- if (item_objectid != objectid)
- break;
- blocknr = btrfs_node_blockptr(node, i);
- ret = readahead_tree_block(root, blocknr);
- if (ret)
- break;
- }
-}
-
-/*
* this can truncate away extent items, csum items and directory items.
* It starts at a high offset and removes keys until it can't find
* any higher than i_size.
@@ -434,6 +400,7 @@ static int btrfs_truncate_in_trans(struct btrfs_trans_handle *trans,
int del_item;
path = btrfs_alloc_path();
+ path->reada = -1;
BUG_ON(!path);
/* FIXME, add redo link to tree so we don't leak on crash */
key.objectid = inode->i_ino;
@@ -450,7 +417,6 @@ static int btrfs_truncate_in_trans(struct btrfs_trans_handle *trans,
BUG_ON(path->slots[0] == 0);
path->slots[0]--;
}
- reada_truncate(root, path, inode->i_ino);
leaf = btrfs_buffer_leaf(path->nodes[0]);
found_key = &leaf->items[path->slots[0]].key;
found_type = btrfs_disk_key_type(found_key);
@@ -827,36 +793,6 @@ static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry,
return d_splice_alias(inode, dentry);
}
-/*
- * readahead one full node of leaves as long as their keys include
- * the objectid supplied
- */
-static void reada_leaves(struct btrfs_root *root, struct btrfs_path *path,
- u64 objectid)
-{
- struct btrfs_node *node;
- int i;
- u32 nritems;
- u64 item_objectid;
- u64 blocknr;
- int slot;
- int ret;
-
- if (!path->nodes[1])
- return;
- node = btrfs_buffer_node(path->nodes[1]);
- slot = path->slots[1];
- nritems = btrfs_header_nritems(&node->header);
- for (i = slot + 1; i < nritems; i++) {
- item_objectid = btrfs_disk_key_objectid(&node->ptrs[i].key);
- if (item_objectid != objectid)
- break;
- blocknr = btrfs_node_blockptr(node, i);
- ret = readahead_tree_block(root, blocknr);
- if (ret)
- break;
- }
-}
static unsigned char btrfs_filetype_table[] = {
DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
};
@@ -890,18 +826,17 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
btrfs_set_key_type(&key, key_type);
key.offset = filp->f_pos;
path = btrfs_alloc_path();
+ path->reada = 1;
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0)
goto err;
advance = 0;
- reada_leaves(root, path, inode->i_ino);
while(1) {
leaf = btrfs_buffer_leaf(path->nodes[0]);
nritems = btrfs_header_nritems(&leaf->header);
slot = path->slots[0];
if (advance || slot >= nritems) {
if (slot >= nritems -1) {
- reada_leaves(root, path, inode->i_ino);
ret = btrfs_next_leaf(root, path);
if (ret)
break;
OpenPOWER on IntegriCloud