Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 274617
b: refs/heads/master
c: 0712718
h: refs/heads/master
i:
  274615: 2fdb9c6
v: v3
  • Loading branch information
Josef Bacik committed Oct 19, 2011
1 parent 39b40d7 commit 58f683b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1b9c332b6c92e992b1971a08412c6f460a54b514
refs/heads/master: 07127184efb629f1336c0592bfdacec258cab731
11 changes: 11 additions & 0 deletions trunk/fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,17 @@ static inline u64 btrfs_calc_trans_metadata_size(struct btrfs_root *root,
3 * num_items;
}

/*
* Doing a truncate won't result in new nodes or leaves, just what we need for
* COW.
*/
static inline u64 btrfs_calc_trunc_metadata_size(struct btrfs_root *root,
unsigned num_items)
{
return (root->leafsize + root->nodesize * (BTRFS_MAX_LEVEL - 1)) *
num_items;
}

void btrfs_put_block_group(struct btrfs_block_group_cache *cache);
int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
struct btrfs_root *root, unsigned long count);
Expand Down
8 changes: 4 additions & 4 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 58f683b

Please sign in to comment.