From: Mingming Cao <cmm@us.ibm.com>
To: Shen Feng <shen@cn.fujitsu.com>
Cc: linux-ext4@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Theodore Tso <tytso@MIT.EDU>
Subject: Re: [PATCH] ext4: improve some code in rb tree part of dir.c
Date: Tue, 20 May 2008 11:46:36 -0700 [thread overview]
Message-ID: <1211309196.3644.0.camel@localhost.localdomain> (raw)
In-Reply-To: <48324E96.5050705@cn.fujitsu.com>
On Tue, 2008-05-20 at 12:07 +0800, Shen Feng wrote:
> *remove unnecessary code in free_rb_tree_fname
> *rename free_rb_tree_fname to ext4_htree_create_dir_info
> since it and ext4_htree_free_dir_info are a pair
> *replace kmalloc with kzalloc in ext4_htree_free_dir_info
>
> All these make the code more readable and simple.
> PS: this patch is also suitable for ext3.
>
Reviewed-by: Mingming Cao <cmm@us.ibm.com>
> Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
> ---
> fs/ext4/dir.c | 14 ++++----------
> 1 files changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
> index 2bf0331..5ed5108 100644
> --- a/fs/ext4/dir.c
> +++ b/fs/ext4/dir.c
> @@ -272,7 +272,7 @@ static void free_rb_tree_fname(struct rb_root *root)
>
> while (n) {
> /* Do the node's children first */
> - if ((n)->rb_left) {
> + if (n->rb_left) {
> n = n->rb_left;
> continue;
> }
> @@ -301,24 +301,18 @@ static void free_rb_tree_fname(struct rb_root *root)
> parent->rb_right = NULL;
> n = parent;
> }
> - root->rb_node = NULL;
> }
>
>
> -static struct dir_private_info *create_dir_info(loff_t pos)
> +static struct dir_private_info *ext4_htree_create_dir_info(loff_t pos)
> {
> 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)
> 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_minor_hash = pos2min_hash(pos);
> - p->next_hash = 0;
> return p;
> }
>
> @@ -433,7 +427,7 @@ static int ext4_dx_readdir(struct file * filp,
> int ret;
>
> if (!info) {
> - info = create_dir_info(filp->f_pos);
> + info = ext4_htree_create_dir_info(filp->f_pos);
> if (!info)
> return -ENOMEM;
> filp->private_data = info;
prev parent reply other threads:[~2008-05-20 18:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-20 4:07 [PATCH] ext4: improve some code in rb tree part of dir.c Shen Feng
2008-05-20 18:46 ` Mingming Cao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1211309196.3644.0.camel@localhost.localdomain \
--to=cmm@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-ext4@vger.kernel.org \
--cc=shen@cn.fujitsu.com \
--cc=tytso@MIT.EDU \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox