aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/block_validity.c
diff options
context:
space:
mode:
authorCody P Schafer <cody@linux.vnet.ibm.com>2014-01-23 18:56:10 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-23 19:37:03 -0500
commitd1866bd06101eb8ab2bb9d180b47c052c04b7cee (patch)
tree0bd031db9537dfc911f22c91e8612b79d5438aab /fs/ext4/block_validity.c
parentbb25e49ff8ab0ef0b3c073c09d55cf10ef8a2aa0 (diff)
fs/ext4: use rbtree postorder iteration helper instead of opencoding
Use rbtree_postorder_for_each_entry_safe() to destroy the rbtree instead of opencoding an alternate postorder iteration that modifies the tree Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Reviewed-by: Jan Kara <jack@suse.cz> Cc: Michel Lespinasse <walken@google.com> Cc: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext4/block_validity.c')
-rw-r--r--fs/ext4/block_validity.c33
1 files changed, 4 insertions, 29 deletions
diff --git a/fs/ext4/block_validity.c b/fs/ext4/block_validity.c
index 3f11656bd72e..41eb9dcfac7e 100644
--- a/fs/ext4/block_validity.c
+++ b/fs/ext4/block_validity.c
@@ -180,37 +180,12 @@ int ext4_setup_system_zone(struct super_block *sb)
180/* Called when the filesystem is unmounted */ 180/* Called when the filesystem is unmounted */
181void ext4_release_system_zone(struct super_block *sb) 181void ext4_release_system_zone(struct super_block *sb)
182{ 182{
183 struct rb_node *n = EXT4_SB(sb)->system_blks.rb_node; 183 struct ext4_system_zone *entry, *n;
184 struct rb_node *parent;
185 struct ext4_system_zone *entry;
186 184
187 while (n) { 185 rbtree_postorder_for_each_entry_safe(entry, n,
188 /* Do the node's children first */ 186 &EXT4_SB(sb)->system_blks, node)
189 if (n->rb_left) {
190 n = n->rb_left;
191 continue;
192 }
193 if (n->rb_right) {
194 n = n->rb_right;
195 continue;
196 }
197 /*
198 * The node has no children; free it, and then zero
199 * out parent's link to it. Finally go to the
200 * beginning of the loop and try to free the parent
201 * node.
202 */
203 parent = rb_parent(n);
204 entry = rb_entry(n, struct ext4_system_zone, node);
205 kmem_cache_free(ext4_system_zone_cachep, entry); 187 kmem_cache_free(ext4_system_zone_cachep, entry);
206 if (!parent) 188
207 EXT4_SB(sb)->system_blks = RB_ROOT;
208 else if (parent->rb_left == n)
209 parent->rb_left = NULL;
210 else if (parent->rb_right == n)
211 parent->rb_right = NULL;
212 n = parent;
213 }
214 EXT4_SB(sb)->system_blks = RB_ROOT; 189 EXT4_SB(sb)->system_blks = RB_ROOT;
215} 190}
216 191