diff options
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 28 |
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 | ||
3629 | int 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 | |||
3650 | void 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 | |||
3629 | int btrfs_snap_reserve_metadata(struct btrfs_trans_handle *trans, | 3657 | int btrfs_snap_reserve_metadata(struct btrfs_trans_handle *trans, |
3630 | struct btrfs_pending_snapshot *pending) | 3658 | struct btrfs_pending_snapshot *pending) |
3631 | { | 3659 | { |