aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorYan, Zheng <zheng.yan@oracle.com>2010-05-16 10:49:58 -0400
committerChris Mason <chris.mason@oracle.com>2010-05-25 10:34:52 -0400
commitd68fc57b7e3245cfacf2e3b47acfed1946a11786 (patch)
treec2572fcd935017440c8370c8a12ceb49a7fc4f1f /fs/btrfs/extent-tree.c
parent8929ecfa50f266163832eeacfbc3642ed5eb83b6 (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/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index cb814a71800d..a713f69f0c7a 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3626,6 +3626,34 @@ void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
3626 trans->bytes_reserved = 0; 3626 trans->bytes_reserved = 0;
3627} 3627}
3628 3628
3629int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans,
3630 struct inode *inode)
3631{
3632 struct btrfs_root *root = BTRFS_I(inode)->root;
3633 struct btrfs_block_rsv *src_rsv = get_block_rsv(trans, root);
3634 struct btrfs_block_rsv *dst_rsv = root->orphan_block_rsv;
3635
3636 /*
3637 * one for deleting orphan item, one for updating inode and
3638 * two for calling btrfs_truncate_inode_items.
3639 *
3640 * btrfs_truncate_inode_items is a delete operation, it frees
3641 * more space than it uses in most cases. So two units of
3642 * metadata space should be enough for calling it many times.
3643 * If all of the metadata space is used, we can commit
3644 * transaction and use space it freed.
3645 */
3646 u64 num_bytes = calc_trans_metadata_size(root, 4);
3647 return block_rsv_migrate_bytes(src_rsv, dst_rsv, num_bytes);
3648}
3649
3650void btrfs_orphan_release_metadata(struct inode *inode)
3651{
3652 struct btrfs_root *root = BTRFS_I(inode)->root;
3653 u64 num_bytes = calc_trans_metadata_size(root, 4);
3654 btrfs_block_rsv_release(root, root->orphan_block_rsv, num_bytes);
3655}
3656
3629int btrfs_snap_reserve_metadata(struct btrfs_trans_handle *trans, 3657int btrfs_snap_reserve_metadata(struct btrfs_trans_handle *trans,
3630 struct btrfs_pending_snapshot *pending) 3658 struct btrfs_pending_snapshot *pending)
3631{ 3659{