Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332553
b: refs/heads/master
c: 8407aa4
h: refs/heads/master
i:
  332551: 1542b35
v: v3
  • Loading branch information
Miao Xie authored and Chris Mason committed Oct 1, 2012
1 parent 0061669 commit 449913e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 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: 837e197283199de640857192ca32767cb6e24fe8
refs/heads/master: 8407aa464331556e4f6784f974030b83fc7585ed
19 changes: 9 additions & 10 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3834,15 +3834,10 @@ void btrfs_evict_inode(struct inode *inode)
btrfs_i_size_write(inode, 0);

/*
* This is a bit simpler than btrfs_truncate since
*
* 1) We've already reserved our space for our orphan item in the
* unlink.
* 2) We're going to delete the inode item, so we don't need to update
* it at all.
*
* So we just need to reserve some slack space in case we add bytes when
* doing the truncate.
* This is a bit simpler than btrfs_truncate since we've already
* reserved our space for our orphan item in the unlink, so we just
* need to reserve some slack space in case we add bytes and update
* inode item when doing the truncate.
*/
while (1) {
ret = btrfs_block_rsv_refill_noflush(root, rsv, min_size);
Expand All @@ -3863,7 +3858,7 @@ void btrfs_evict_inode(struct inode *inode)
goto no_delete;
}

trans = btrfs_start_transaction(root, 0);
trans = btrfs_start_transaction_noflush(root, 1);
if (IS_ERR(trans)) {
btrfs_orphan_del(NULL, inode);
btrfs_free_block_rsv(root, rsv);
Expand All @@ -3876,6 +3871,10 @@ void btrfs_evict_inode(struct inode *inode)
if (ret != -ENOSPC)
break;

trans->block_rsv = &root->fs_info->trans_block_rsv;
ret = btrfs_update_inode(trans, root, inode);
BUG_ON(ret);

nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
trans = NULL;
Expand Down
29 changes: 21 additions & 8 deletions trunk/fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ static int may_wait_transaction(struct btrfs_root *root, int type)
}

static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
u64 num_items, int type)
u64 num_items, int type,
int noflush)
{
struct btrfs_trans_handle *h;
struct btrfs_transaction *cur_trans;
Expand Down Expand Up @@ -324,9 +325,14 @@ static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
}

num_bytes = btrfs_calc_trans_metadata_size(root, num_items);
ret = btrfs_block_rsv_add(root,
&root->fs_info->trans_block_rsv,
num_bytes);
if (noflush)
ret = btrfs_block_rsv_add_noflush(root,
&root->fs_info->trans_block_rsv,
num_bytes);
else
ret = btrfs_block_rsv_add(root,
&root->fs_info->trans_block_rsv,
num_bytes);
if (ret)
return ERR_PTR(ret);
}
Expand Down Expand Up @@ -393,21 +399,28 @@ static struct btrfs_trans_handle *start_transaction(struct btrfs_root *root,
struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
int num_items)
{
return start_transaction(root, num_items, TRANS_START);
return start_transaction(root, num_items, TRANS_START, 0);
}

struct btrfs_trans_handle *btrfs_start_transaction_noflush(
struct btrfs_root *root, int num_items)
{
return start_transaction(root, num_items, TRANS_START, 1);
}

struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root)
{
return start_transaction(root, 0, TRANS_JOIN);
return start_transaction(root, 0, TRANS_JOIN, 0);
}

struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root)
{
return start_transaction(root, 0, TRANS_JOIN_NOLOCK);
return start_transaction(root, 0, TRANS_JOIN_NOLOCK, 0);
}

struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root)
{
return start_transaction(root, 0, TRANS_USERSPACE);
return start_transaction(root, 0, TRANS_USERSPACE, 0);
}

/* wait for a transaction commit to be fully complete */
Expand Down
2 changes: 2 additions & 0 deletions trunk/fs/btrfs/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ int btrfs_end_transaction_nolock(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root,
int num_items);
struct btrfs_trans_handle *btrfs_start_transaction_noflush(
struct btrfs_root *root, int num_items);
struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root);
struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root);
Expand Down

0 comments on commit 449913e

Please sign in to comment.