diff options
author | Josef Bacik <josef@redhat.com> | 2011-08-19 10:29:59 -0400 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2011-10-19 15:12:37 -0400 |
commit | 07127184efb629f1336c0592bfdacec258cab731 (patch) | |
tree | c527bfd0444cd9a589278873dd78ef185f66d2fc /fs/btrfs/inode.c | |
parent | 1b9c332b6c92e992b1971a08412c6f460a54b514 (diff) | |
download | op-kernel-dev-07127184efb629f1336c0592bfdacec258cab731.zip op-kernel-dev-07127184efb629f1336c0592bfdacec258cab731.tar.gz |
Btrfs: reduce the amount of space needed for truncates
With btrfs_truncate_inode_items we always return if we have to go to another
leaf, which makes us do our reservation again. This means we will only ever
modify one leaf at a time, so we only need 1 items worth of slack space. Also,
since we are deleting we will not be creating nodes as we go down, if anything
we'll be free'ing them as we merge them together, so make a different
calculation for truncate which will only have the worst case useage of COW'ing
the entire path down to the leaf. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 4d057c0..8316b57 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3528,7 +3528,7 @@ void btrfs_evict_inode(struct inode *inode) struct btrfs_trans_handle *trans; struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_block_rsv *rsv; - u64 min_size = btrfs_calc_trans_metadata_size(root, 2); + u64 min_size = btrfs_calc_trunc_metadata_size(root, 1); unsigned long nr; int ret; @@ -6482,7 +6482,7 @@ static int btrfs_truncate(struct inode *inode) struct btrfs_trans_handle *trans; unsigned long nr; u64 mask = root->sectorsize - 1; - u64 min_size = btrfs_calc_trans_metadata_size(root, 2); + u64 min_size = btrfs_calc_trunc_metadata_size(root, 1); ret = btrfs_truncate_page(inode->i_mapping, inode->i_size); if (ret) @@ -6532,12 +6532,12 @@ static int btrfs_truncate(struct inode *inode) return -ENOMEM; /* - * 2 for the truncate slack space + * 1 for the truncate slack space * 1 for the orphan item we're going to add * 1 for the orphan item deletion * 1 for updating the inode. */ - trans = btrfs_start_transaction(root, 5); + trans = btrfs_start_transaction(root, 4); if (IS_ERR(trans)) { err = PTR_ERR(trans); goto out; |