Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 243149
b: refs/heads/master
c: f0cd846
h: refs/heads/master
i:
  243147: 8f6c8d4
v: v3
  • Loading branch information
Josef Bacik committed Mar 17, 2011
1 parent 09693cc commit 3e5bf18
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 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: ded5db9de78f963979e1605f859de67626f54693
refs/heads/master: f0cd846e9221811d87047f1428cf5226e7236efe
45 changes: 18 additions & 27 deletions trunk/fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3649,22 +3649,6 @@ static int btrfs_setsize(struct inode *inode, loff_t newsize)
if (newsize == oldsize)
return 0;

trans = btrfs_start_transaction(root, 5);
if (IS_ERR(trans))
return PTR_ERR(trans);

btrfs_set_trans_block_group(trans, inode);

ret = btrfs_orphan_add(trans, inode);
if (ret) {
btrfs_end_transaction(trans, root);
return ret;
}

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

if (newsize > oldsize) {
i_size_write(inode, newsize);
btrfs_ordered_update_i_size(inode, i_size_read(inode), NULL);
Expand All @@ -3675,25 +3659,15 @@ static int btrfs_setsize(struct inode *inode, loff_t newsize)
return ret;
}

trans = btrfs_start_transaction(root, 0);
trans = btrfs_start_transaction(root, 1);
if (IS_ERR(trans))
return PTR_ERR(trans);

btrfs_set_trans_block_group(trans, inode);
trans->block_rsv = root->orphan_block_rsv;
BUG_ON(!trans->block_rsv);

/*
* If this fails just leave the orphan item so that it can get
* cleaned up next time we mount.
*/
ret = btrfs_update_inode(trans, root, inode);
if (ret) {
btrfs_end_transaction(trans, root);
return ret;
}
if (inode->i_nlink > 0)
ret = btrfs_orphan_del(trans, inode);
nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr);
Expand Down Expand Up @@ -6517,6 +6491,23 @@ static int btrfs_truncate(struct inode *inode)
btrfs_wait_ordered_range(inode, inode->i_size & (~mask), (u64)-1);
btrfs_ordered_update_i_size(inode, inode->i_size, NULL);

trans = btrfs_start_transaction(root, 5);
if (IS_ERR(trans))
return PTR_ERR(trans);

btrfs_set_trans_block_group(trans, inode);

ret = btrfs_orphan_add(trans, inode);
if (ret) {
btrfs_end_transaction(trans, root);
return ret;
}

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

/* Now start a transaction for the truncate */
trans = btrfs_start_transaction(root, 0);
if (IS_ERR(trans))
return PTR_ERR(trans);
Expand Down

0 comments on commit 3e5bf18

Please sign in to comment.