* [PATCH] btrfs: use rb_entry()
@ 2016-12-19 14:53 Geliang Tang
[not found] ` <e7f25691fb620d01df75e3526897c7fb0e0ef6f8.1482158996.git.geliangtang@gmail. com>
0 siblings, 1 reply; 3+ messages in thread
From: Geliang Tang @ 2016-12-19 14:53 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba
Cc: Geliang Tang, linux-btrfs, linux-kernel
To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
fs/btrfs/ctree.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index a426dc8..146b2dc 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -426,7 +426,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
tm_root = &fs_info->tree_mod_log;
for (node = rb_first(tm_root); node; node = next) {
next = rb_next(node);
- tm = container_of(node, struct tree_mod_elem, node);
+ tm = rb_entry(node, struct tree_mod_elem, node);
if (tm->seq > min_seq)
continue;
rb_erase(node, tm_root);
@@ -460,7 +460,7 @@ __tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm)
tm_root = &fs_info->tree_mod_log;
new = &tm_root->rb_node;
while (*new) {
- cur = container_of(*new, struct tree_mod_elem, node);
+ cur = rb_entry(*new, struct tree_mod_elem, node);
parent = *new;
if (cur->logical < tm->logical)
new = &((*new)->rb_left);
@@ -746,7 +746,7 @@ __tree_mod_log_search(struct btrfs_fs_info *fs_info, u64 start, u64 min_seq,
tm_root = &fs_info->tree_mod_log;
node = tm_root->rb_node;
while (node) {
- cur = container_of(node, struct tree_mod_elem, node);
+ cur = rb_entry(node, struct tree_mod_elem, node);
if (cur->logical < start) {
node = node->rb_left;
} else if (cur->logical > start) {
@@ -1326,7 +1326,7 @@ __tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb,
next = rb_next(&tm->node);
if (!next)
break;
- tm = container_of(next, struct tree_mod_elem, node);
+ tm = rb_entry(next, struct tree_mod_elem, node);
if (tm->logical != first_tm->logical)
break;
}
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: use rb_entry()
[not found] ` <e7f25691fb620d01df75e3526897c7fb0e0ef6f8.1482158996.git.geliangtang@gmail. com>
@ 2016-12-19 16:46 ` Josef Bacik
2016-12-20 15:32 ` David Sterba
0 siblings, 1 reply; 3+ messages in thread
From: Josef Bacik @ 2016-12-19 16:46 UTC (permalink / raw)
To: Geliang Tang; +Cc: Chris Mason, David Sterba, linux-btrfs, linux-kernel
On Mon, Dec 19, 2016 at 9:53 AM, Geliang Tang <geliangtang@gmail.com>
wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Thanks,
Josef
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: use rb_entry()
2016-12-19 16:46 ` Josef Bacik
@ 2016-12-20 15:32 ` David Sterba
0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2016-12-20 15:32 UTC (permalink / raw)
To: Josef Bacik
Cc: Geliang Tang, Chris Mason, David Sterba, linux-btrfs, linux-kernel
On Mon, Dec 19, 2016 at 11:46:23AM -0500, Josef Bacik wrote:
> On Mon, Dec 19, 2016 at 9:53 AM, Geliang Tang <geliangtang@gmail.com>
> wrote:
> > To make the code clearer, use rb_entry() instead of container_of() to
> > deal with rbtree.
> >
> > Signed-off-by: Geliang Tang <geliangtang@gmail.com>
>
> Reviewed-by: Josef Bacik <jbacik@fb.com>
Added to cleanups branch.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-20 15:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-19 14:53 [PATCH] btrfs: use rb_entry() Geliang Tang
[not found] ` <e7f25691fb620d01df75e3526897c7fb0e0ef6f8.1482158996.git.geliangtang@gmail. com>
2016-12-19 16:46 ` Josef Bacik
2016-12-20 15:32 ` David Sterba
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).