From: Dan Carpenter <error27@gmail.com>
To: crosslonelyover <crosslonelyover@gmail.com>
Cc: linux-ext4 <linux-ext4@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
kernel-janitors <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] check name_len before down_read xattr_sem and sb_read in ext2_xattr_get
Date: Tue, 13 Jul 2010 16:56:08 +0200 [thread overview]
Message-ID: <20100713145608.GM5658@bicker> (raw)
In-Reply-To: <201007122229025316610@gmail.com>
On Mon, Jul 12, 2010 at 10:29:09PM +0800, crosslonelyover wrote:
> Hi,
> I walked through ext2_xattr_get, and felt that we can
> do some optimization on it. For name_len check, it's done
> after down xattr_sem and sb_read, both of which are time
> consuming operation compared with strlen:
> down_read(&EXT2_I(inode)->xattr_sem);
> ...
> bh = sb_bread(inode->i_sb, EXT2_I(inode)->i_file_acl);
> ...
> /* find named attribute */
> name_len = strlen(name);
>
> error = -ERANGE;
> if (name_len > 255)
> goto cleanup;
>
> Most of the case, you'll get one valid block, but if the
> name len > 255, then the xattr_sem down and sb_bread operation
> can be seen as a waste of time. So I think we'd better do
> name len check as early as possible.
> Following is my patch, and it's against 2.6.35-rc4.
> Please check it.
>
> Signed-off-by: Wang Sheng-Hui <crosslonelyover@gmail.com>
> ---
> fs/ext2/xattr.c | 12 +++++++-----
> 1 files changed, 7 insertions(+), 5 deletions(-)
For what it's worth, this change looks OK to me.
Reviewed-by: Dan Carpenter <error27@gmail.com>
regards,
dan carpenter
next prev parent reply other threads:[~2010-07-13 14:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-12 14:29 [PATCH] check name_len before down_read xattr_sem and sb_read in ext2_xattr_get crosslonelyover
2010-07-13 14:28 ` Wang Sheng-Hui
2010-07-13 14:56 ` Dan Carpenter [this message]
2010-07-21 17:44 ` Jan Kara
2010-07-22 0:03 ` shenghui
2010-07-23 8:37 ` Jan Kara
2010-07-23 12:46 ` Ted Ts'o
2010-07-25 13:12 ` shenghui
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=20100713145608.GM5658@bicker \
--to=error27@gmail.com \
--cc=crosslonelyover@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).