From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [RFC PATCH 10/11] btrfs: qgroup-tests: Add old_roots ulist to allow qgroup test pass.
Date: Mon, 23 Mar 2015 16:08:36 +0800 [thread overview]
Message-ID: <1427098117-25152-11-git-send-email-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <1427098117-25152-1-git-send-email-quwenruo@cn.fujitsu.com>
Since new qgroup design need to get old_roots before calling
btrfs_qgroup_record_ref(), modify qgroup test to follow the new routine.
And of course, without this modification, it won't pass the qgroup
multi-ref test.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
fs/btrfs/backref.c | 10 ++++++++++
fs/btrfs/tests/qgroup-tests.c | 32 +++++++++++++++++++++++++++-----
2 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index e33a003..58d87ab 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -1017,7 +1017,17 @@ again:
if (ret)
goto out;
+ /*
+ * For sanity tests, all parents are 0, causing different roots
+ * referring to one extent merged into one root.
+ * So skip such search in sanity tests
+ */
+#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
+ if (!trans || (trans && likely(trans->type != __TRANS_DUMMY)))
+ __merge_refs(&prefs, 2);
+#else
__merge_refs(&prefs, 2);
+#endif
while (!list_empty(&prefs)) {
ref = list_first_entry(&prefs, struct __prelim_ref, list);
diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c
index c97c5f8..967a185 100644
--- a/fs/btrfs/tests/qgroup-tests.c
+++ b/fs/btrfs/tests/qgroup-tests.c
@@ -21,6 +21,7 @@
#include "../transaction.h"
#include "../disk-io.h"
#include "../qgroup.h"
+#include "../backref.h"
static void init_dummy_trans(struct btrfs_trans_handle *trans)
{
@@ -294,6 +295,7 @@ static int test_multiple_refs(struct btrfs_root *root)
{
struct btrfs_trans_handle trans;
struct btrfs_fs_info *fs_info = root->fs_info;
+ struct ulist *old_roots = NULL;
int ret;
init_dummy_trans(&trans);
@@ -329,16 +331,27 @@ static int test_multiple_refs(struct btrfs_root *root)
return -EINVAL;
}
+ /* Get correct old ref counts before writing tree backref */
+ ret = btrfs_find_all_roots(&trans, fs_info, NULL, 4096, 0, &old_roots, 1);
+ if (ret < 0) {
+ ulist_free(old_roots);
+ return ret;
+ }
+
ret = add_tree_ref(root, 4096, 4096, 0, 256);
- if (ret)
+ if (ret) {
+ ulist_free(old_roots);
return ret;
+ }
- ret = btrfs_qgroup_record_ref(&trans, fs_info, NULL, 256, 4096, 4096, 0,
- BTRFS_QGROUP_OPER_ADD_SHARED, 0);
+ ret = btrfs_qgroup_record_ref(&trans, fs_info, old_roots, 256, 4096,
+ 4096, 0, BTRFS_QGROUP_OPER_ADD_SHARED, 0);
if (ret) {
test_msg("Qgroup record ref failed %d\n", ret);
+ ulist_free(old_roots);
return ret;
}
+ old_roots = NULL;
ret = btrfs_delayed_qgroup_accounting(&trans, fs_info);
if (ret) {
@@ -356,16 +369,25 @@ static int test_multiple_refs(struct btrfs_root *root)
return -EINVAL;
}
+ /* Get correct old ref counts before writing tree backref */
+ ret = btrfs_find_all_roots(&trans, fs_info, NULL, 4096, 0, &old_roots, 1);
+ if (ret < 0) {
+ ulist_free(old_roots);
+ return ret;
+ }
+
ret = remove_extent_ref(root, 4096, 4096, 0, 256);
if (ret)
return ret;
- ret = btrfs_qgroup_record_ref(&trans, fs_info, NULL, 256, 4096, 4096, 0,
- BTRFS_QGROUP_OPER_SUB_SHARED, 0);
+ ret = btrfs_qgroup_record_ref(&trans, fs_info, old_roots, 256, 4096,
+ 4096, 0, BTRFS_QGROUP_OPER_SUB_SHARED, 0);
if (ret) {
+ ulist_free(old_roots);
test_msg("Qgroup record ref failed %d\n", ret);
return ret;
}
+ old_roots = NULL;
ret = btrfs_delayed_qgroup_accounting(&trans, fs_info);
if (ret) {
--
2.3.3
next prev parent reply other threads:[~2015-03-23 8:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-23 8:08 [RFC PATCH 00/11] Qgroup: new record/write/record infrastructure to record correct old/new_roots Qu Wenruo
2015-03-23 8:08 ` [PATCH v2 RESEND 01/11] btrfs: qgroup: Cleanup open-coded old/new_refcnt update and read Qu Wenruo
2015-03-23 8:08 ` [RFC PATCH 02/11] btrfs: extent-tree: Use ref_node to replace unneeded parameters in __inc_extent_ref() and __free_extent() Qu Wenruo
2015-03-23 8:08 ` [RFC PATCH 03/11] btrfs: backref: Add nolock option for btrfs_find_all_roots() Qu Wenruo
2015-03-23 8:08 ` [RFC PATCH 04/11] btrfs: backref: Allow find_parent_nodes() to skip given ref_node Qu Wenruo
2015-03-23 8:08 ` [RFC PATCH 05/11] btrfs: backref: Allow btrfs_find_all_roots() " Qu Wenruo
2015-03-23 8:08 ` [RFC PATCH 06/11] btrfs: qgroup: Add needed parameter and member for qgroup Qu Wenruo
2015-03-23 8:08 ` [RFC PATCH 07/11] btrfs: qgroup: save and pass old_roots ulist to btrfs_qgroup_record_ref() Qu Wenruo
2015-03-23 8:08 ` [RFC PATCH 08/11] btrfs: qgroup: Record current referenced roots at qgroup_record_ref() Qu Wenruo
2015-03-23 8:08 ` [RFC PATCH 09/11] btrfs: qgroup: Use oper->old/new_roots to update refcnt Qu Wenruo
2015-03-23 8:08 ` Qu Wenruo [this message]
2015-03-23 8:08 ` [RFC PATCH 11/11] btrfs: qgroup: Cleanup the unneeded codes Qu Wenruo
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=1427098117-25152-11-git-send-email-quwenruo@cn.fujitsu.com \
--to=quwenruo@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).