aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorWang Shilong <wangsl-fnst@cn.fujitsu.com>2013-03-01 06:33:01 -0500
committerJosef Bacik <jbacik@fusionio.com>2013-03-01 10:13:04 -0500
commita9870c0e031527fbfa382019f30d2e9b98124a0d (patch)
tree5c59752af695a18db6b8c421199424423364b73b /fs
parent235fdb8ef2a313749cf3a42e70156c618263a388 (diff)
Btrfs: don't call btrfs_qgroup_free if just btrfs_qgroup_reserve fails
commit eb6b88d92c6df083dd09a8c471011e3788dfd7c6 leads into another bug. If it is just because qgroup_reserve fails, the function btrfs_qgroup_free should not be called, otherwise, it will cause the wrong quota accounting. Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/extent-tree.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 7cb9d734f6e5..075854e7a044 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4772,9 +4772,14 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
4772 * ret != 0 here means the qgroup reservation failed, we go straight to 4772 * ret != 0 here means the qgroup reservation failed, we go straight to
4773 * the shared error handling then. 4773 * the shared error handling then.
4774 */ 4774 */
4775 if (ret == 0) 4775 if (ret == 0) {
4776 ret = reserve_metadata_bytes(root, block_rsv, 4776 ret = reserve_metadata_bytes(root, block_rsv,
4777 to_reserve, flush); 4777 to_reserve, flush);
4778 if (ret && root->fs_info->quota_enabled) {
4779 btrfs_qgroup_free(root, num_bytes +
4780 nr_extents * root->leafsize);
4781 }
4782 }
4778 4783
4779 if (ret) { 4784 if (ret) {
4780 u64 to_free = 0; 4785 u64 to_free = 0;
@@ -4805,10 +4810,6 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
4805 btrfs_ino(inode), 4810 btrfs_ino(inode),
4806 to_free, 0); 4811 to_free, 0);
4807 } 4812 }
4808 if (root->fs_info->quota_enabled) {
4809 btrfs_qgroup_free(root, num_bytes +
4810 nr_extents * root->leafsize);
4811 }
4812 if (delalloc_lock) 4813 if (delalloc_lock)
4813 mutex_unlock(&BTRFS_I(inode)->delalloc_mutex); 4814 mutex_unlock(&BTRFS_I(inode)->delalloc_mutex);
4814 return ret; 4815 return ret;