aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-10 16:58:11 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-10 16:58:11 -0400
commit2619ba1f0ff9540a9d84683310a1e350b5efde3d (patch)
treeb027c1c51630d215fd40be34a72f7bc308b34652 /fs/btrfs/disk-io.c
parent2932f3ec94ff0212313b8187064f93bcb76ce411 (diff)
Btrfs: subvolumes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 760fdc9a766..ff69162829b 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -301,6 +301,12 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
int ret = 0;
printk("read_fs_root looking for %Lu %Lu %u\n", location->objectid, location->offset, location->flags);
+ root = radix_tree_lookup(&fs_info->fs_roots_radix,
+ (unsigned long)location->objectid);
+ if (root) {
+printk("found %p in cache\n", root);
+ return root;
+ }
root = kmalloc(sizeof(*root), GFP_NOFS);
if (!root) {
printk("failed1\n");
@@ -349,7 +355,8 @@ out:
insert:
printk("inserting %p\n", root);
root->ref_cows = 1;
- ret = radix_tree_insert(&fs_info->fs_roots_radix, (unsigned long)root,
+ ret = radix_tree_insert(&fs_info->fs_roots_radix,
+ (unsigned long)root->root_key.objectid,
root);
if (ret) {
printk("radix_tree_insert gives us %d\n", ret);
@@ -460,6 +467,20 @@ int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root
return 0;
}
+static int free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root)
+{
+ radix_tree_delete(&fs_info->fs_roots_radix,
+ (unsigned long)root->root_key.objectid);
+ if (root->inode)
+ iput(root->inode);
+ if (root->node)
+ brelse(root->node);
+ if (root->commit_root)
+ brelse(root->commit_root);
+ kfree(root);
+ return 0;
+}
+
int del_fs_roots(struct btrfs_fs_info *fs_info)
{
int ret;
@@ -472,19 +493,8 @@ int del_fs_roots(struct btrfs_fs_info *fs_info)
ARRAY_SIZE(gang));
if (!ret)
break;
- for (i = 0; i < ret; i++) {
- radix_tree_delete(&fs_info->fs_roots_radix,
- (unsigned long)gang[i]);
- if (gang[i]->inode)
- iput(gang[i]->inode);
- else
- printk("no inode for root %p\n", gang[i]);
- if (gang[i]->node)
- brelse(gang[i]->node);
- if (gang[i]->commit_root)
- brelse(gang[i]->commit_root);
- kfree(gang[i]);
- }
+ for (i = 0; i < ret; i++)
+ free_fs_root(fs_info, gang[i]);
}
return 0;
}