diff options
author | Yan, Zheng <zheng.yan@oracle.com> | 2010-05-16 10:49:58 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-05-25 10:34:52 -0400 |
commit | d68fc57b7e3245cfacf2e3b47acfed1946a11786 (patch) | |
tree | c2572fcd935017440c8370c8a12ceb49a7fc4f1f /fs/btrfs/root-tree.c | |
parent | 8929ecfa50f266163832eeacfbc3642ed5eb83b6 (diff) |
Btrfs: Metadata reservation for orphan inodes
reserve metadata space for handling orphan inodes
Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/root-tree.c')
-rw-r--r-- | fs/btrfs/root-tree.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index 67fa2d29d663..b91ccd972644 100644 --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c | |||
@@ -259,6 +259,8 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root) | |||
259 | struct extent_buffer *leaf; | 259 | struct extent_buffer *leaf; |
260 | struct btrfs_path *path; | 260 | struct btrfs_path *path; |
261 | struct btrfs_key key; | 261 | struct btrfs_key key; |
262 | struct btrfs_key root_key; | ||
263 | struct btrfs_root *root; | ||
262 | int err = 0; | 264 | int err = 0; |
263 | int ret; | 265 | int ret; |
264 | 266 | ||
@@ -270,6 +272,9 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root) | |||
270 | key.type = BTRFS_ORPHAN_ITEM_KEY; | 272 | key.type = BTRFS_ORPHAN_ITEM_KEY; |
271 | key.offset = 0; | 273 | key.offset = 0; |
272 | 274 | ||
275 | root_key.type = BTRFS_ROOT_ITEM_KEY; | ||
276 | root_key.offset = (u64)-1; | ||
277 | |||
273 | while (1) { | 278 | while (1) { |
274 | ret = btrfs_search_slot(NULL, tree_root, &key, path, 0, 0); | 279 | ret = btrfs_search_slot(NULL, tree_root, &key, path, 0, 0); |
275 | if (ret < 0) { | 280 | if (ret < 0) { |
@@ -294,13 +299,25 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root) | |||
294 | key.type != BTRFS_ORPHAN_ITEM_KEY) | 299 | key.type != BTRFS_ORPHAN_ITEM_KEY) |
295 | break; | 300 | break; |
296 | 301 | ||
297 | ret = btrfs_find_dead_roots(tree_root, key.offset); | 302 | root_key.objectid = key.offset; |
298 | if (ret) { | 303 | key.offset++; |
304 | |||
305 | root = btrfs_read_fs_root_no_name(tree_root->fs_info, | ||
306 | &root_key); | ||
307 | if (!IS_ERR(root)) | ||
308 | continue; | ||
309 | |||
310 | ret = PTR_ERR(root); | ||
311 | if (ret != -ENOENT) { | ||
299 | err = ret; | 312 | err = ret; |
300 | break; | 313 | break; |
301 | } | 314 | } |
302 | 315 | ||
303 | key.offset++; | 316 | ret = btrfs_find_dead_roots(tree_root, root_key.objectid); |
317 | if (ret) { | ||
318 | err = ret; | ||
319 | break; | ||
320 | } | ||
304 | } | 321 | } |
305 | 322 | ||
306 | btrfs_free_path(path); | 323 | btrfs_free_path(path); |