Commit ed0b5620 authored by Geliang Tang's avatar Geliang Tang Committed by Jaegeuk Kim

f2fs: use rb_entry_safe

Use rb_entry_safe() instead of open-coding it.
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 746e2403
...@@ -311,28 +311,24 @@ static struct extent_node *__lookup_extent_tree_ret(struct extent_tree *et, ...@@ -311,28 +311,24 @@ static struct extent_node *__lookup_extent_tree_ret(struct extent_tree *et,
tmp_node = parent; tmp_node = parent;
if (parent && fofs > en->ei.fofs) if (parent && fofs > en->ei.fofs)
tmp_node = rb_next(parent); tmp_node = rb_next(parent);
*next_ex = tmp_node ? *next_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
tmp_node = parent; tmp_node = parent;
if (parent && fofs < en->ei.fofs) if (parent && fofs < en->ei.fofs)
tmp_node = rb_prev(parent); tmp_node = rb_prev(parent);
*prev_ex = tmp_node ? *prev_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
return NULL; return NULL;
lookup_neighbors: lookup_neighbors:
if (fofs == en->ei.fofs) { if (fofs == en->ei.fofs) {
/* lookup prev node for merging backward later */ /* lookup prev node for merging backward later */
tmp_node = rb_prev(&en->rb_node); tmp_node = rb_prev(&en->rb_node);
*prev_ex = tmp_node ? *prev_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
} }
if (fofs == en->ei.fofs + en->ei.len - 1) { if (fofs == en->ei.fofs + en->ei.len - 1) {
/* lookup next node for merging frontward later */ /* lookup next node for merging frontward later */
tmp_node = rb_next(&en->rb_node); tmp_node = rb_next(&en->rb_node);
*next_ex = tmp_node ? *next_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
} }
return en; return en;
} }
...@@ -493,9 +489,8 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode, ...@@ -493,9 +489,8 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
if (!next_en) { if (!next_en) {
struct rb_node *node = rb_next(&en->rb_node); struct rb_node *node = rb_next(&en->rb_node);
next_en = node ? next_en = rb_entry_safe(node, struct extent_node,
rb_entry(node, struct extent_node, rb_node) rb_node);
: NULL;
} }
if (parts) if (parts)
......
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