All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Subject: [PATCH 3/3] btrfs: qgroup: fix a wrong parameter of no_quota.
Date: Tue, 10 Feb 2015 18:24:05 +0800	[thread overview]
Message-ID: <1423563845-9103-4-git-send-email-yangds.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <1423563845-9103-1-git-send-email-yangds.fnst@cn.fujitsu.com>

In function of __btrfs_mod_ref(), we are passing the no_quota=1
to process_func() anyway. It will make the numbers in qgroup be
wrong when deleting a subvolume. The data size in a deleted subvolume
will never be decressed from all related qgroups.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 652be74..f59809c 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3056,6 +3056,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
 	int i;
 	int level;
 	int ret = 0;
+	int no_quota = 0;
 	int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *,
 			    u64, u64, u64, u64, u64, u64, int);
 
@@ -3080,6 +3081,9 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
 	else
 		parent = 0;
 
+	if (!root->fs_info->quota_enabled || !is_fstree(ref_root))
+		no_quota = 1;
+
 	for (i = 0; i < nritems; i++) {
 		if (level == 0) {
 			btrfs_item_key_to_cpu(buf, &key, i);
@@ -3098,7 +3102,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
 			key.offset -= btrfs_file_extent_offset(buf, fi);
 			ret = process_func(trans, root, bytenr, num_bytes,
 					   parent, ref_root, key.objectid,
-					   key.offset, 1);
+					   key.offset, no_quota);
 			if (ret)
 				goto fail;
 		} else {
@@ -3106,7 +3110,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
 			num_bytes = root->nodesize;
 			ret = process_func(trans, root, bytenr, num_bytes,
 					   parent, ref_root, level - 1, 0,
-					   1);
+					   no_quota);
 			if (ret)
 				goto fail;
 		}
-- 
1.8.4.2


  parent reply	other threads:[~2015-02-10 10:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-10 10:24 [PATCH 0/3] Btrfs: qgroup: part-3: bug fixes for deleting subvolume Dongsheng Yang
2015-02-10 10:24 ` [PATCH 1/3] btrfs: qgroup: return EINVAL if level of parent is not higher than child's Dongsheng Yang
2015-02-10 10:24 ` [PATCH 2/3] btrfs: qgroup: allow to remove qgroup which has parent but no child Dongsheng Yang
2015-02-10 10:24 ` Dongsheng Yang [this message]
2015-02-10 11:24   ` [PATCH 3/3] btrfs: qgroup: fix a wrong parameter of no_quota Filipe David Manana
2015-02-11  2:51     ` Dongsheng Yang
2015-02-13  9:38   ` Dongsheng Yang
2015-02-26  6:05     ` Dongsheng Yang
2015-03-03 11:13       ` [PATCH] fstest: btrfs: add a test for quota number when deleting a subvol Dongsheng Yang
2015-03-03 11:13         ` Dongsheng Yang
2015-03-06  5:06         ` Eryu Guan
2015-03-16  5:06           ` Dongsheng Yang
2015-03-16  5:06             ` Dongsheng Yang
2015-03-16  5:33             ` Eryu Guan
2015-03-16  5:47               ` Dongsheng Yang
2015-03-16  5:47                 ` Dongsheng Yang
2015-03-16  5:58             ` [PATCH v2] " Dongsheng Yang
2015-03-16  5:58               ` Dongsheng Yang
2015-03-03 11:18       ` [PATCH 3/3] btrfs: qgroup: fix a wrong parameter of no_quota Dongsheng Yang
2015-03-03 14:00         ` Josef Bacik
2015-03-03 20:20           ` Mark Fasheh
2015-03-16  4:59             ` Dongsheng Yang
2015-03-17 15:27               ` Dongsheng Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423563845-9103-4-git-send-email-yangds.fnst@cn.fujitsu.com \
    --to=yangds.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.