diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-04-10 16:58:11 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-04-10 16:58:11 -0400 |
commit | 2619ba1f0ff9540a9d84683310a1e350b5efde3d (patch) | |
tree | b027c1c51630d215fd40be34a72f7bc308b34652 /fs/btrfs/disk-io.c | |
parent | 2932f3ec94ff0212313b8187064f93bcb76ce411 (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.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 760fdc9a7664..ff69162829b3 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, | |||
301 | int ret = 0; | 301 | int ret = 0; |
302 | 302 | ||
303 | printk("read_fs_root looking for %Lu %Lu %u\n", location->objectid, location->offset, location->flags); | 303 | printk("read_fs_root looking for %Lu %Lu %u\n", location->objectid, location->offset, location->flags); |
304 | root = radix_tree_lookup(&fs_info->fs_roots_radix, | ||
305 | (unsigned long)location->objectid); | ||
306 | if (root) { | ||
307 | printk("found %p in cache\n", root); | ||
308 | return root; | ||
309 | } | ||
304 | root = kmalloc(sizeof(*root), GFP_NOFS); | 310 | root = kmalloc(sizeof(*root), GFP_NOFS); |
305 | if (!root) { | 311 | if (!root) { |
306 | printk("failed1\n"); | 312 | printk("failed1\n"); |
@@ -349,7 +355,8 @@ out: | |||
349 | insert: | 355 | insert: |
350 | printk("inserting %p\n", root); | 356 | printk("inserting %p\n", root); |
351 | root->ref_cows = 1; | 357 | root->ref_cows = 1; |
352 | ret = radix_tree_insert(&fs_info->fs_roots_radix, (unsigned long)root, | 358 | ret = radix_tree_insert(&fs_info->fs_roots_radix, |
359 | (unsigned long)root->root_key.objectid, | ||
353 | root); | 360 | root); |
354 | if (ret) { | 361 | if (ret) { |
355 | printk("radix_tree_insert gives us %d\n", ret); | 362 | 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 | |||
460 | return 0; | 467 | return 0; |
461 | } | 468 | } |
462 | 469 | ||
470 | static int free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root) | ||
471 | { | ||
472 | radix_tree_delete(&fs_info->fs_roots_radix, | ||
473 | (unsigned long)root->root_key.objectid); | ||
474 | if (root->inode) | ||
475 | iput(root->inode); | ||
476 | if (root->node) | ||
477 | brelse(root->node); | ||
478 | if (root->commit_root) | ||
479 | brelse(root->commit_root); | ||
480 | kfree(root); | ||
481 | return 0; | ||
482 | } | ||
483 | |||
463 | int del_fs_roots(struct btrfs_fs_info *fs_info) | 484 | int del_fs_roots(struct btrfs_fs_info *fs_info) |
464 | { | 485 | { |
465 | int ret; | 486 | int ret; |
@@ -472,19 +493,8 @@ int del_fs_roots(struct btrfs_fs_info *fs_info) | |||
472 | ARRAY_SIZE(gang)); | 493 | ARRAY_SIZE(gang)); |
473 | if (!ret) | 494 | if (!ret) |
474 | break; | 495 | break; |
475 | for (i = 0; i < ret; i++) { | 496 | for (i = 0; i < ret; i++) |
476 | radix_tree_delete(&fs_info->fs_roots_radix, | 497 | free_fs_root(fs_info, gang[i]); |
477 | (unsigned long)gang[i]); | ||
478 | if (gang[i]->inode) | ||
479 | iput(gang[i]->inode); | ||
480 | else | ||
481 | printk("no inode for root %p\n", gang[i]); | ||
482 | if (gang[i]->node) | ||
483 | brelse(gang[i]->node); | ||
484 | if (gang[i]->commit_root) | ||
485 | brelse(gang[i]->commit_root); | ||
486 | kfree(gang[i]); | ||
487 | } | ||
488 | } | 498 | } |
489 | return 0; | 499 | return 0; |
490 | } | 500 | } |