From: Yongqiang Yang <xiaoqiangnk@gmail.com>
To: Robin Dong <hao.bigrat@gmail.com>
Cc: linux-ext4@vger.kernel.org, Robin Dong <sanbai@taobao.com>
Subject: Re: [PATCH 2/2] ext4: avoid finding next leaf if newext->ee_block smaller than fex->ee_block
Date: Thu, 30 Jun 2011 16:42:31 +0800 [thread overview]
Message-ID: <BANLkTikeMA72P2-6eSv=2cqOtvEaHRbsZA@mail.gmail.com> (raw)
In-Reply-To: <1309421014-6148-2-git-send-email-sanbai@taobao.com>
On Thu, Jun 30, 2011 at 4:03 PM, Robin Dong <hao.bigrat@gmail.com> wrote:
> If newext->ee_block is smaller than (or equal to) fex->ee_block, the call of
> ext4_ext_next_leaf_block will be useless. We need to call it only after
> newext->ee_block is greater than fex->ee_block.
>
> Signed-off-by: Robin Dong <sanbai@taobao.com>
> ---
> fs/ext4/extents.c | 37 ++++++++++++++++++++-----------------
> 1 files changed, 20 insertions(+), 17 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index dc5ef91..0ee475a 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -1765,24 +1765,27 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
>
> /* probably next leaf has space for us? */
> fex = EXT_LAST_EXTENT(eh);
> - next = ext4_ext_next_leaf_block(inode, path);
> - if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
> - && next != EXT_MAX_BLOCKS) {
How about:
next = EXT_MAX_BLOCKS;
if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
next = ext4_ext_next_leaf_block(inode, path);
if (next != EXT_MAX_BLOCKS) {
Code above can reduce an indent.
Yongqiang.
> - ext_debug("next leaf block - %d\n", next);
> - BUG_ON(npath != NULL);
> - npath = ext4_ext_find_extent(inode, next, NULL);
> - if (IS_ERR(npath))
> - return PTR_ERR(npath);
> - BUG_ON(npath->p_depth != path->p_depth);
> - eh = npath[depth].p_hdr;
> - if (le16_to_cpu(eh->eh_entries) < le16_to_cpu(eh->eh_max)) {
> - ext_debug("next leaf isn't full(%d)\n",
> - le16_to_cpu(eh->eh_entries));
> - path = npath;
> - goto has_space;
> + if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)) {
> + next = ext4_ext_next_leaf_block(inode, path);
> + if (next != EXT_MAX_BLOCKS) {
> + ext_debug("next leaf block - %d\n", next);
> + BUG_ON(npath != NULL);
> + npath = ext4_ext_find_extent(inode, next, NULL);
> + if (IS_ERR(npath))
> + return PTR_ERR(npath);
> + BUG_ON(npath->p_depth != path->p_depth);
> + eh = npath[depth].p_hdr;
> + if (le16_to_cpu(eh->eh_entries) <
> + le16_to_cpu(eh->eh_max)) {
> + ext_debug("next leaf isn't full(%d)\n",
> + le16_to_cpu(eh->eh_entries));
> + path = npath;
> + goto has_space;
> + }
> + ext_debug("next leaf has no free space(%d,%d)\n",
> + le16_to_cpu(eh->eh_entries),
> + le16_to_cpu(eh->eh_max));
> }
> - ext_debug("next leaf has no free space(%d,%d)\n",
> - le16_to_cpu(eh->eh_entries), le16_to_cpu(eh->eh_max));
> }
>
> /*
> --
> 1.7.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Best Wishes
Yongqiang Yang
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-06-30 8:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-30 8:03 [PATCH 1/2] ext4: remove redundant goto tag "repeat" Robin Dong
2011-06-30 8:03 ` [PATCH 2/2] ext4: avoid finding next leaf if newext->ee_block smaller than fex->ee_block Robin Dong
2011-06-30 8:42 ` Yongqiang Yang [this message]
2011-07-11 19:52 ` Ted Ts'o
2011-07-12 1:33 ` Robin Dong
2011-07-11 17:07 ` Ted Ts'o
2011-06-30 11:56 ` [PATCH 1/2] ext4: remove redundant goto tag "repeat" Lukas Czerner
2011-07-11 15:45 ` Ted Ts'o
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='BANLkTikeMA72P2-6eSv=2cqOtvEaHRbsZA@mail.gmail.com' \
--to=xiaoqiangnk@gmail.com \
--cc=hao.bigrat@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sanbai@taobao.com \
/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).