diff options
author | Filipe Manana <fdmanana@suse.com> | 2016-05-05 05:26:26 -0400 |
---|---|---|
committer | Filipe Manana <fdmanana@suse.com> | 2016-05-12 20:59:30 -0400 |
commit | 5062af35c3c6e49110ab1ec99295339259298a3d (patch) | |
tree | 21cbe4d6bc5a8b887a17d989e8ceb95ade8887f8 | |
parent | 376e5a57bf7f1466031a957d04bf8b8f6801ee6d (diff) |
Btrfs: fix number of transaction units for renames with whiteout
When we do a rename with the whiteout flag, we need to create the whiteout
inode, which in the worst case requires 5 transaction units (1 inode item,
1 inode ref, 2 dir items and 1 xattr if selinux is enabled). So bump the
number of transaction units from 11 to 16 if the whiteout flag is set.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
-rw-r--r-- | fs/btrfs/inode.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index a7db3ed6ac88..0921d2b07f1d 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -9668,6 +9668,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
9668 | unsigned int flags) | 9668 | unsigned int flags) |
9669 | { | 9669 | { |
9670 | struct btrfs_trans_handle *trans; | 9670 | struct btrfs_trans_handle *trans; |
9671 | unsigned int trans_num_items; | ||
9671 | struct btrfs_root *root = BTRFS_I(old_dir)->root; | 9672 | struct btrfs_root *root = BTRFS_I(old_dir)->root; |
9672 | struct btrfs_root *dest = BTRFS_I(new_dir)->root; | 9673 | struct btrfs_root *dest = BTRFS_I(new_dir)->root; |
9673 | struct inode *new_inode = d_inode(new_dentry); | 9674 | struct inode *new_inode = d_inode(new_dentry); |
@@ -9730,8 +9731,14 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
9730 | * would require 5 item modifications, so we'll assume they are normal | 9731 | * would require 5 item modifications, so we'll assume they are normal |
9731 | * inodes. So 5 * 2 is 10, plus 1 for the new link, so 11 total items | 9732 | * inodes. So 5 * 2 is 10, plus 1 for the new link, so 11 total items |
9732 | * should cover the worst case number of items we'll modify. | 9733 | * should cover the worst case number of items we'll modify. |
9734 | * If our rename has the whiteout flag, we need more 5 units for the | ||
9735 | * new inode (1 inode item, 1 inode ref, 2 dir items and 1 xattr item | ||
9736 | * when selinux is enabled). | ||
9733 | */ | 9737 | */ |
9734 | trans = btrfs_start_transaction(root, 11); | 9738 | trans_num_items = 11; |
9739 | if (flags & RENAME_WHITEOUT) | ||
9740 | trans_num_items += 5; | ||
9741 | trans = btrfs_start_transaction(root, trans_num_items); | ||
9735 | if (IS_ERR(trans)) { | 9742 | if (IS_ERR(trans)) { |
9736 | ret = PTR_ERR(trans); | 9743 | ret = PTR_ERR(trans); |
9737 | goto out_notrans; | 9744 | goto out_notrans; |