linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] ext4: avoid wasted extent cache lookup if !PUNCH_OUT_EXT
@ 2011-06-29  0:57 Robin Dong
  2011-06-29  1:30 ` Steven Liu
  2011-07-18  3:28 ` Ted Ts'o
  0 siblings, 2 replies; 3+ messages in thread
From: Robin Dong @ 2011-06-29  0:57 UTC (permalink / raw)
  To: linux-ext4; +Cc: Robin Dong

This patch avoids an extraneous lookup of the extent cache
in ext4_ext_map_blocks() when the flag
EXT4_GET_BLOCKS_PUNCH_OUT_EXT is absent.

The existing logic was performing the lookup but not making
use of the result. The patch simply reverses the order of evaluation
in the condition.

Since ext4_ext_in_cache() does not initialize newex on misses, bypassing
its invocation does not introduce any new issue in this regard.

Signed-off-by: Robin Dong <sanbai@taobao.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Gouriou <egouriou@google.com>
---
 fs/ext4/extents.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index eb63c7b..fed2633 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3358,8 +3358,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 	trace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags);
 
 	/* check in cache */
-	if (ext4_ext_in_cache(inode, map->m_lblk, &newex) &&
-		((flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) == 0)) {
+	if (!(flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) &&
+		ext4_ext_in_cache(inode, map->m_lblk, &newex)) {
 		if (!newex.ee_start_lo && !newex.ee_start_hi) {
 			if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {
 				/*
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] ext4: avoid wasted extent cache lookup if !PUNCH_OUT_EXT
  2011-06-29  0:57 [PATCH v3] ext4: avoid wasted extent cache lookup if !PUNCH_OUT_EXT Robin Dong
@ 2011-06-29  1:30 ` Steven Liu
  2011-07-18  3:28 ` Ted Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Liu @ 2011-06-29  1:30 UTC (permalink / raw)
  To: Robin Dong; +Cc: linux-ext4, Robin Dong

2011/6/29 Robin Dong <hao.bigrat@gmail.com>:
> This patch avoids an extraneous lookup of the extent cache
> in ext4_ext_map_blocks() when the flag
> EXT4_GET_BLOCKS_PUNCH_OUT_EXT is absent.
>
> The existing logic was performing the lookup but not making
> use of the result. The patch simply reverses the order of evaluation
> in the condition.
>
> Since ext4_ext_in_cache() does not initialize newex on misses, bypassing
> its invocation does not introduce any new issue in this regard.
>
> Signed-off-by: Robin Dong <sanbai@taobao.com>
> Reviewed-by: Lukas Czerner <lczerner@redhat.com>
> Reviewed-by: Eric Gouriou <egouriou@google.com>
> ---
>  fs/ext4/extents.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index eb63c7b..fed2633 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -3358,8 +3358,8 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
>        trace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags);
>
>        /* check in cache */
> -       if (ext4_ext_in_cache(inode, map->m_lblk, &newex) &&
> -               ((flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) == 0)) {
> +       if (!(flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) &&
> +               ext4_ext_in_cache(inode, map->m_lblk, &newex)) {
>                if (!newex.ee_start_lo && !newex.ee_start_hi) {
>                        if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {

Ronbin Dong,
  why donnot do this line?
 if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {
TO
 if (!(flags & EXT4_GET_BLOCKS_CREATE) ) {
?
Acked-by:   LiuQi <lingjiujianke@gmail.com>

>                                /*
> --
> 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
>
--
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] 3+ messages in thread

* Re: [PATCH v3] ext4: avoid wasted extent cache lookup if !PUNCH_OUT_EXT
  2011-06-29  0:57 [PATCH v3] ext4: avoid wasted extent cache lookup if !PUNCH_OUT_EXT Robin Dong
  2011-06-29  1:30 ` Steven Liu
@ 2011-07-18  3:28 ` Ted Ts'o
  1 sibling, 0 replies; 3+ messages in thread
From: Ted Ts'o @ 2011-07-18  3:28 UTC (permalink / raw)
  To: Robin Dong; +Cc: linux-ext4, Robin Dong

On Wed, Jun 29, 2011 at 08:57:51AM +0800, Robin Dong wrote:
> This patch avoids an extraneous lookup of the extent cache
> in ext4_ext_map_blocks() when the flag
> EXT4_GET_BLOCKS_PUNCH_OUT_EXT is absent.
> 
> The existing logic was performing the lookup but not making
> use of the result. The patch simply reverses the order of evaluation
> in the condition.
> 
> Since ext4_ext_in_cache() does not initialize newex on misses, bypassing
> its invocation does not introduce any new issue in this regard.
> 
> Signed-off-by: Robin Dong <sanbai@taobao.com>
> Reviewed-by: Lukas Czerner <lczerner@redhat.com>
> Reviewed-by: Eric Gouriou <egouriou@google.com>

Thanks added to the ext4 tree.

						- Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-18  3:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-29  0:57 [PATCH v3] ext4: avoid wasted extent cache lookup if !PUNCH_OUT_EXT Robin Dong
2011-06-29  1:30 ` Steven Liu
2011-07-18  3:28 ` Ted Ts'o

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).