* [PATCH 1/2] ext4: remove redundant goto tag "repeat"
@ 2011-06-30 8:03 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
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Robin Dong @ 2011-06-30 8:03 UTC (permalink / raw)
To: linux-ext4; +Cc: Robin Dong
If eh->eh_entries is smaller than eh->eh_max, the routine will
go to the "repeat" and then go to "has_space" directlly ,
since argument "depth" and "eh" are not even changed.
Therefore, goto "has_space" directly and remove redundant "repeat" tag.
Signed-off-by: Robin Dong <sanbai@taobao.com>
---
fs/ext4/extents.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index eb63c7b..dc5ef91 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -1758,7 +1758,6 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
goto merge;
}
-repeat:
depth = ext_depth(inode);
eh = path[depth].p_hdr;
if (le16_to_cpu(eh->eh_entries) < le16_to_cpu(eh->eh_max))
@@ -1780,7 +1779,7 @@ repeat:
ext_debug("next leaf isn't full(%d)\n",
le16_to_cpu(eh->eh_entries));
path = npath;
- goto repeat;
+ 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));
--
1.7.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] ext4: avoid finding next leaf if newext->ee_block smaller than fex->ee_block
2011-06-30 8:03 [PATCH 1/2] ext4: remove redundant goto tag "repeat" Robin Dong
@ 2011-06-30 8:03 ` Robin Dong
2011-06-30 8:42 ` Yongqiang Yang
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
2 siblings, 2 replies; 8+ messages in thread
From: Robin Dong @ 2011-06-30 8:03 UTC (permalink / raw)
To: linux-ext4; +Cc: Robin Dong
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) {
- 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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ext4: avoid finding next leaf if newext->ee_block smaller than fex->ee_block
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
2011-07-11 19:52 ` Ted Ts'o
2011-07-11 17:07 ` Ted Ts'o
1 sibling, 1 reply; 8+ messages in thread
From: Yongqiang Yang @ 2011-06-30 8:42 UTC (permalink / raw)
To: Robin Dong; +Cc: linux-ext4, Robin Dong
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] ext4: remove redundant goto tag "repeat"
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 11:56 ` Lukas Czerner
2011-07-11 15:45 ` Ted Ts'o
2 siblings, 0 replies; 8+ messages in thread
From: Lukas Czerner @ 2011-06-30 11:56 UTC (permalink / raw)
To: Robin Dong; +Cc: linux-ext4, Robin Dong
On Thu, 30 Jun 2011, Robin Dong wrote:
> If eh->eh_entries is smaller than eh->eh_max, the routine will
> go to the "repeat" and then go to "has_space" directlly ,
> since argument "depth" and "eh" are not even changed.
>
> Therefore, goto "has_space" directly and remove redundant "repeat" tag.
The patch looks good. Thanks!
-Lukas
>
> Signed-off-by: Robin Dong <sanbai@taobao.com>
> ---
> fs/ext4/extents.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index eb63c7b..dc5ef91 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -1758,7 +1758,6 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
> goto merge;
> }
>
> -repeat:
> depth = ext_depth(inode);
> eh = path[depth].p_hdr;
> if (le16_to_cpu(eh->eh_entries) < le16_to_cpu(eh->eh_max))
> @@ -1780,7 +1779,7 @@ repeat:
> ext_debug("next leaf isn't full(%d)\n",
> le16_to_cpu(eh->eh_entries));
> path = npath;
> - goto repeat;
> + 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));
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] ext4: remove redundant goto tag "repeat"
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 11:56 ` [PATCH 1/2] ext4: remove redundant goto tag "repeat" Lukas Czerner
@ 2011-07-11 15:45 ` Ted Ts'o
2 siblings, 0 replies; 8+ messages in thread
From: Ted Ts'o @ 2011-07-11 15:45 UTC (permalink / raw)
To: Robin Dong; +Cc: linux-ext4, Robin Dong
On Thu, Jun 30, 2011 at 04:03:33PM +0800, Robin Dong wrote:
> If eh->eh_entries is smaller than eh->eh_max, the routine will
> go to the "repeat" and then go to "has_space" directlly ,
> since argument "depth" and "eh" are not even changed.
>
> Therefore, goto "has_space" directly and remove redundant "repeat" tag.
>
> Signed-off-by: Robin Dong <sanbai@taobao.com>
Thanks, added to the ext4 tree.
- Ted
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ext4: avoid finding next leaf if newext->ee_block smaller than fex->ee_block
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
@ 2011-07-11 17:07 ` Ted Ts'o
1 sibling, 0 replies; 8+ messages in thread
From: Ted Ts'o @ 2011-07-11 17:07 UTC (permalink / raw)
To: Robin Dong; +Cc: linux-ext4, Robin Dong
On Thu, Jun 30, 2011 at 04:03:34PM +0800, Robin Dong 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>
Added to the ext4 tree, but I cleaned up the one-line summary of the
patch:
ext4: remove redundant goto in ext4_ext_insert_extent()
It's important that the one-line summary be much more "big picture" so
that people who are looking through the git history can understand
what the commit does. Also, I added an explicit
From: Robin Dong <sanbai@taobao.com>
.... so that the attribution was the same as what was in your
Signed-off-by (instead of your hao.bigrat address). If that wasn't
your intent, let me know and I'll fix it before I lock it into the
master branch.
In the future, if you are sending the patch from a different e-mail
address, it would be useful if you explicitly add a "From: " line in
the body so it's clear. I made the assumption in this case based on
the general practice of other taobao engineers, but as I said, let me
know if you would want something else.
Thanks!!
- Ted
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ext4: avoid finding next leaf if newext->ee_block smaller than fex->ee_block
2011-06-30 8:42 ` Yongqiang Yang
@ 2011-07-11 19:52 ` Ted Ts'o
2011-07-12 1:33 ` Robin Dong
0 siblings, 1 reply; 8+ messages in thread
From: Ted Ts'o @ 2011-07-11 19:52 UTC (permalink / raw)
To: Yongqiang Yang; +Cc: Robin Dong, linux-ext4, Robin Dong
On Thu, Jun 30, 2011 at 04:42:31PM +0800, Yongqiang Yang wrote:
> 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) {
Agreed, that's a better way of doing things. Also, Robin, please
compare and contrast your description with mine. The commit
description shouldn't just be a textual description of the change. It
should give the larger context of the change and why it's important.
- Ted
commit 2a3f7e0e0e55f8817fbe92d111ef2a06e6b8ef18
Author: Robin Dong <sanbai@taobao.com>
Date: Mon Jul 11 15:43:38 2011 -0400
ext4: avoid unneeded ext4_ext_next_leaf_block() while inserting extents
Optimize ext4_exT_insert_extent() by avoiding
ext4_ext_next_leaf_block() when the result is not used/needed.
Signed-off-by: Robin Dong <sanbai@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 9cbdcb2..f1c538e 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -1730,9 +1730,10 @@ 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) {
+ 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) {
ext_debug("next leaf block - %d\n", next);
BUG_ON(npath != NULL);
npath = ext4_ext_find_extent(inode, next, NULL);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ext4: avoid finding next leaf if newext->ee_block smaller than fex->ee_block
2011-07-11 19:52 ` Ted Ts'o
@ 2011-07-12 1:33 ` Robin Dong
0 siblings, 0 replies; 8+ messages in thread
From: Robin Dong @ 2011-07-12 1:33 UTC (permalink / raw)
To: Ted Ts'o; +Cc: Yongqiang Yang, linux-ext4
2011/7/12 Ted Ts'o <tytso@mit.edu>:
> On Thu, Jun 30, 2011 at 04:42:31PM +0800, Yongqiang Yang wrote:
>> 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) {
>
> Agreed, that's a better way of doing things. Also, Robin, please
> compare and contrast your description with mine. The commit
> description shouldn't just be a textual description of the change. It
> should give the larger context of the change and why it's important.
>
> - Ted
>
> commit 2a3f7e0e0e55f8817fbe92d111ef2a06e6b8ef18
> Author: Robin Dong <sanbai@taobao.com>
> Date: Mon Jul 11 15:43:38 2011 -0400
>
> ext4: avoid unneeded ext4_ext_next_leaf_block() while inserting extents
>
> Optimize ext4_exT_insert_extent() by avoiding
> ext4_ext_next_leaf_block() when the result is not used/needed.
>
> Signed-off-by: Robin Dong <sanbai@taobao.com>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index 9cbdcb2..f1c538e 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -1730,9 +1730,10 @@ 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) {
> + 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) {
> ext_debug("next leaf block - %d\n", next);
> BUG_ON(npath != NULL);
> npath = ext4_ext_find_extent(inode, next, NULL);
>
It seems much better than my description. Thanks!
--
--
Best Regard
Robin Dong
--
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
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-07-12 1:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.