Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332525
b: refs/heads/master
c: ca7e70f
h: refs/heads/master
i:
  332523: 6314b6e
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Oct 1, 2012
1 parent 8be29bf commit 6efde4a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 37 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: 06d3d22b456c2f87aeb1eb4517eeabb47e21fcc9
refs/heads/master: ca7e70f59078046db28501519308c2061b0e7a6f
1 change: 1 addition & 0 deletions trunk/fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ struct btrfs_block_rsv {
struct btrfs_space_info *space_info;
spinlock_t lock;
unsigned int full;
unsigned int failfast;
};

/*
Expand Down
2 changes: 1 addition & 1 deletion trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -6308,7 +6308,7 @@ use_block_rsv(struct btrfs_trans_handle *trans,
ret = block_rsv_use_bytes(block_rsv, blocksize);
if (!ret)
return block_rsv;
if (ret) {
if (ret && !block_rsv->failfast) {
static DEFINE_RATELIMIT_STATE(_rs,
DEFAULT_RATELIMIT_INTERVAL,
/*DEFAULT_RATELIMIT_BURST*/ 2);
Expand Down
53 changes: 18 additions & 35 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3448,12 +3448,6 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,

if (path->slots[0] == 0 ||
path->slots[0] != pending_del_slot) {
if (root->ref_cows &&
BTRFS_I(inode)->location.objectid !=
BTRFS_FREE_INO_OBJECTID) {
err = -EAGAIN;
goto out;
}
if (pending_del_nr) {
ret = btrfs_del_items(trans, root, path,
pending_del_slot,
Expand Down Expand Up @@ -3826,6 +3820,7 @@ void btrfs_evict_inode(struct inode *inode)
goto no_delete;
}
rsv->size = min_size;
rsv->failfast = 1;
global_rsv = &root->fs_info->global_block_rsv;

btrfs_i_size_write(inode, 0);
Expand Down Expand Up @@ -3870,7 +3865,7 @@ void btrfs_evict_inode(struct inode *inode)
trans->block_rsv = rsv;

ret = btrfs_truncate_inode_items(trans, root, inode, 0, 0);
if (ret != -EAGAIN)
if (ret != -ENOSPC)
break;

nr = trans->blocks_used;
Expand Down Expand Up @@ -6852,6 +6847,7 @@ static int btrfs_truncate(struct inode *inode)
if (!rsv)
return -ENOMEM;
rsv->size = min_size;
rsv->failfast = 1;

/*
* 1 for the truncate slack space
Expand Down Expand Up @@ -6905,37 +6901,13 @@ static int btrfs_truncate(struct inode *inode)
* safe.
*/
set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &BTRFS_I(inode)->runtime_flags);
trans->block_rsv = rsv;

while (1) {
ret = btrfs_block_rsv_refill(root, rsv, min_size);
if (ret) {
/*
* This can only happen with the original transaction we
* started above, every other time we shouldn't have a
* transaction started yet.
*/
if (ret == -EAGAIN)
goto end_trans;
err = ret;
break;
}

if (!trans) {
/* Just need the 1 for updating the inode */
trans = btrfs_start_transaction(root, 1);
if (IS_ERR(trans)) {
ret = err = PTR_ERR(trans);
trans = NULL;
break;
}
}

trans->block_rsv = rsv;

ret = btrfs_truncate_inode_items(trans, root, inode,
inode->i_size,
BTRFS_EXTENT_DATA_KEY);
if (ret != -EAGAIN) {
if (ret != -ENOSPC) {
err = ret;
break;
}
Expand All @@ -6946,11 +6918,22 @@ static int btrfs_truncate(struct inode *inode)
err = ret;
break;
}
end_trans:

nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
trans = NULL;
btrfs_btree_balance_dirty(root, nr);

trans = btrfs_start_transaction(root, 2);
if (IS_ERR(trans)) {
ret = err = PTR_ERR(trans);
trans = NULL;
break;
}

ret = btrfs_block_rsv_migrate(&root->fs_info->trans_block_rsv,
rsv, min_size);
BUG_ON(ret); /* shouldn't happen */
trans->block_rsv = rsv;
}

if (ret == 0 && inode->i_nlink > 0) {
Expand Down

0 comments on commit 6efde4a

Please sign in to comment.