From: damenly.su@gmail.com
To: linux-btrfs@vger.kernel.org
Cc: Su Yue <Damenly_Su@gmx.com>
Subject: [PATCH V2 04/10] btrfs-progs: reform the function block_group_cache_tree_search()
Date: Wed, 18 Dec 2019 13:18:43 +0800 [thread overview]
Message-ID: <20191218051849.2587-5-Damenly_Su@gmx.com> (raw)
In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com>
From: Su Yue <Damenly_Su@gmx.com>
Change @cotnains to @next of block_group_cache_tree_search().
Now, the function will try to search the block group containing
the @bytenr. If not found, return NULL if @next is zero. Or
It will return the next block group.
Will be used in the later commit.
Signed-off-by: Su Yue <Damenly_Su@gmx.com>
---
extent-tree.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/extent-tree.c b/extent-tree.c
index ab576f8732a2..fdfa29a2409f 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -196,11 +196,15 @@ static int btrfs_add_block_group_cache(struct btrfs_fs_info *info,
}
/*
- * This will return the block group at or after bytenr if contains is 0, else
- * it will return the block group that contains the bytenr
+ * This will return the block group which contains @bytenr if it exists.
+ * If found nothing, the return depends on @next.
+ *
+ * @next:
+ * if 0, return NULL if there's no block group containing the bytenr.
+ * if 1, return the block group which starts after @bytenr.
*/
static struct btrfs_block_group_cache *block_group_cache_tree_search(
- struct btrfs_fs_info *info, u64 bytenr, int contains)
+ struct btrfs_fs_info *info, u64 bytenr, int next)
{
struct btrfs_block_group_cache *cache, *ret = NULL;
struct rb_node *n;
@@ -215,11 +219,11 @@ static struct btrfs_block_group_cache *block_group_cache_tree_search(
start = cache->key.objectid;
if (bytenr < start) {
- if (!contains && (!ret || start < ret->key.objectid))
+ if (next && (!ret || start < ret->key.objectid))
ret = cache;
n = n->rb_left;
} else if (bytenr > start) {
- if (contains && bytenr <= end) {
+ if (bytenr <= end) {
ret = cache;
break;
}
@@ -229,6 +233,7 @@ static struct btrfs_block_group_cache *block_group_cache_tree_search(
break;
}
}
+
return ret;
}
--
2.21.0 (Apple Git-122.2)
next prev parent reply other threads:[~2019-12-18 5:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-18 5:18 [PATCH V2 00/10] unify origanization structure of block group cache damenly.su
2019-12-18 5:18 ` [PATCH V2 01/10] btrfs-progs: handle error if btrfs_write_one_block_group() failed damenly.su
2019-12-18 5:18 ` [PATCH V2 02/10] btrfs-progs: block_group: add rb tree related memebers damenly.su
2019-12-18 5:18 ` [PATCH V2 03/10] btrfs-progs: port block group cache tree insertion and lookup functions damenly.su
2019-12-18 5:18 ` damenly.su [this message]
2019-12-18 9:51 ` [PATCH V2 04/10] btrfs-progs: reform the function block_group_cache_tree_search() Qu Wenruo
2019-12-18 5:18 ` [PATCH V2 05/10] btrfs-progs: adjust ported block group lookup functions in kernel version damenly.su
2019-12-18 9:52 ` Qu Wenruo
2019-12-18 11:01 ` Su Yue
2019-12-18 5:18 ` [PATCH V2 06/10] btrfs-progs: abstract function btrfs_add_block_group_cache() damenly.su
2019-12-18 5:18 ` [PATCH V2 07/10] block-progs: block_group: add dirty_bgs list related memebers damenly.su
2019-12-18 5:18 ` [PATCH V2 08/10] btrfs-progs: pass @trans to functions touch dirty block groups damenly.su
2019-12-18 5:18 ` [PATCH V2 09/10] btrfs-progs: reform block groups caches structure damenly.su
2019-12-18 5:18 ` [PATCH V2 10/10] btrfs-progs: cleanups after block group cache reform damenly.su
2020-01-22 17:52 ` [PATCH V2 00/10] unify origanization structure of block group cache David Sterba
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=20191218051849.2587-5-Damenly_Su@gmx.com \
--to=damenly.su@gmail.com \
--cc=Damenly_Su@gmx.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