Commit 6b4df8b6 authored by Geliang Tang's avatar Geliang Tang Committed by David Sterba

btrfs: use rb_entry() instead of container_of

To make the code clearer, use rb_entry() instead of container_of() to
deal with rbtree.
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Reviewed-by: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent f74670f7
...@@ -426,7 +426,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info, ...@@ -426,7 +426,7 @@ void btrfs_put_tree_mod_seq(struct btrfs_fs_info *fs_info,
tm_root = &fs_info->tree_mod_log; tm_root = &fs_info->tree_mod_log;
for (node = rb_first(tm_root); node; node = next) { for (node = rb_first(tm_root); node; node = next) {
next = rb_next(node); 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) if (tm->seq > min_seq)
continue; continue;
rb_erase(node, tm_root); rb_erase(node, tm_root);
...@@ -460,7 +460,7 @@ __tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm) ...@@ -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; tm_root = &fs_info->tree_mod_log;
new = &tm_root->rb_node; new = &tm_root->rb_node;
while (*new) { while (*new) {
cur = container_of(*new, struct tree_mod_elem, node); cur = rb_entry(*new, struct tree_mod_elem, node);
parent = *new; parent = *new;
if (cur->logical < tm->logical) if (cur->logical < tm->logical)
new = &((*new)->rb_left); new = &((*new)->rb_left);
...@@ -746,7 +746,7 @@ __tree_mod_log_search(struct btrfs_fs_info *fs_info, u64 start, u64 min_seq, ...@@ -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; tm_root = &fs_info->tree_mod_log;
node = tm_root->rb_node; node = tm_root->rb_node;
while (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) { if (cur->logical < start) {
node = node->rb_left; node = node->rb_left;
} else if (cur->logical > start) { } else if (cur->logical > start) {
...@@ -1326,7 +1326,7 @@ __tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb, ...@@ -1326,7 +1326,7 @@ __tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb,
next = rb_next(&tm->node); next = rb_next(&tm->node);
if (!next) if (!next)
break; 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) if (tm->logical != first_tm->logical)
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment