aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
diff options
context:
space:
mode:
authorCody P Schafer <cody@linux.vnet.ibm.com>2014-01-23 18:56:12 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-23 19:37:03 -0500
commitb1c8047c6b474c639d923122ab84732cbfeb7225 (patch)
treeb705574cdd4fe0c9743218740e28ce3501824a4f /fs/ext3
parente8bbeeb755a077cfc0f814b07739f9225642d65c (diff)
fs/ext3: 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> Cc: Michel Lespinasse <walken@google.com> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext3')
-rw-r--r--fs/ext3/dir.c36
1 files changed, 5 insertions, 31 deletions
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
index bafdd48eefde..a331ad1c23f8 100644
--- a/fs/ext3/dir.c
+++ b/fs/ext3/dir.c
@@ -309,43 +309,17 @@ struct fname {
309 */ 309 */
310static void free_rb_tree_fname(struct rb_root *root) 310static void free_rb_tree_fname(struct rb_root *root)
311{ 311{
312 struct rb_node *n = root->rb_node; 312 struct fname *fname, *next;
313 struct rb_node *parent; 313
314 struct fname *fname; 314 rbtree_postorder_for_each_entry_safe(fname, next, root, rb_hash)
315
316 while (n) {
317 /* Do the node's children first */
318 if (n->rb_left) {
319 n = n->rb_left;
320 continue;
321 }
322 if (n->rb_right) {
323 n = n->rb_right;
324 continue;
325 }
326 /*
327 * The node has no children; free it, and then zero
328 * out parent's link to it. Finally go to the
329 * beginning of the loop and try to free the parent
330 * node.
331 */
332 parent = rb_parent(n);
333 fname = rb_entry(n, struct fname, rb_hash);
334 while (fname) { 315 while (fname) {
335 struct fname * old = fname; 316 struct fname * old = fname;
336 fname = fname->next; 317 fname = fname->next;
337 kfree (old); 318 kfree (old);
338 } 319 }
339 if (!parent)
340 *root = RB_ROOT;
341 else if (parent->rb_left == n)
342 parent->rb_left = NULL;
343 else if (parent->rb_right == n)
344 parent->rb_right = NULL;
345 n = parent;
346 }
347}
348 320
321 *root = RB_ROOT;
322}
349 323
350static struct dir_private_info *ext3_htree_create_dir_info(struct file *filp, 324static struct dir_private_info *ext3_htree_create_dir_info(struct file *filp,
351 loff_t pos) 325 loff_t pos)