mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 16:37:50 +00:00
ext3: improve some code in rb tree part of dir.c
- remove unnecessary code in free_rb_tree_fname - rename free_rb_tree_fname to ext3_htree_create_dir_info since it and ext3_htree_free_dir_info are a pair - replace kmalloc with kzalloc in ext3_htree_free_dir_info Signed-off-by: Shen Feng <shen@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
1984bb763c
commit
9ebfbe9f92
1 changed files with 4 additions and 10 deletions
|
@ -272,7 +272,7 @@ static void free_rb_tree_fname(struct rb_root *root)
|
||||||
|
|
||||||
while (n) {
|
while (n) {
|
||||||
/* Do the node's children first */
|
/* Do the node's children first */
|
||||||
if ((n)->rb_left) {
|
if (n->rb_left) {
|
||||||
n = n->rb_left;
|
n = n->rb_left;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -301,24 +301,18 @@ static void free_rb_tree_fname(struct rb_root *root)
|
||||||
parent->rb_right = NULL;
|
parent->rb_right = NULL;
|
||||||
n = parent;
|
n = parent;
|
||||||
}
|
}
|
||||||
root->rb_node = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct dir_private_info *create_dir_info(loff_t pos)
|
static struct dir_private_info *ext3_htree_create_dir_info(loff_t pos)
|
||||||
{
|
{
|
||||||
struct dir_private_info *p;
|
struct dir_private_info *p;
|
||||||
|
|
||||||
p = kmalloc(sizeof(struct dir_private_info), GFP_KERNEL);
|
p = kzalloc(sizeof(struct dir_private_info), GFP_KERNEL);
|
||||||
if (!p)
|
if (!p)
|
||||||
return NULL;
|
return NULL;
|
||||||
p->root.rb_node = NULL;
|
|
||||||
p->curr_node = NULL;
|
|
||||||
p->extra_fname = NULL;
|
|
||||||
p->last_pos = 0;
|
|
||||||
p->curr_hash = pos2maj_hash(pos);
|
p->curr_hash = pos2maj_hash(pos);
|
||||||
p->curr_minor_hash = pos2min_hash(pos);
|
p->curr_minor_hash = pos2min_hash(pos);
|
||||||
p->next_hash = 0;
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +427,7 @@ static int ext3_dx_readdir(struct file * filp,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!info) {
|
if (!info) {
|
||||||
info = create_dir_info(filp->f_pos);
|
info = ext3_htree_create_dir_info(filp->f_pos);
|
||||||
if (!info)
|
if (!info)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
filp->private_data = info;
|
filp->private_data = info;
|
||||||
|
|
Loading…
Reference in a new issue