2011-06-27 10:45:27

by Robin Dong

[permalink] [raw]
Subject: [PATCH v2] ext4: avoid redundant cache finding if flags not cantian PUNCH_OUT

In old code, ext4 will find extent in cache first even flags does
not contian PUNCH_OUT, that may waste some time.

Signed-off-by: Robin Dong <[email protected]>
Reviewed-by: Lukas Czerner <[email protected]>
---
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



2011-06-27 13:45:26

by Steven Liu

[permalink] [raw]
Subject: Re: [PATCH v2] ext4: avoid redundant cache finding if flags not cantian PUNCH_OUT

Hi Robin Dong

Why don't modify this line?
?if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {
if(!(flags & EXT4_GET_BLOCKS_CREATE))


2011/6/27 Robin Dong <[email protected]>:
> In old code, ext4 will find extent in cache first even flags does
> not contian PUNCH_OUT, that may waste some time.
>
> Signed-off-by: Robin Dong <[email protected]>
> Reviewed-by: Lukas Czerner <[email protected]>
> ---
> ?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
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
>

Best Regards

2011-06-27 19:59:56

by djwong

[permalink] [raw]
Subject: Re: [PATCH v2] ext4: avoid redundant cache finding if flags not cantian PUNCH_OUT

On Mon, Jun 27, 2011 at 06:45:13PM +0800, Robin Dong wrote:
> Subject: [PATCH v2] ext4: avoid redundant cache finding if flags not cantian

I suspect you mean "contain" as opposed to "cantian".

> In old code, ext4 will find extent in cache first even flags does
> not contian PUNCH_OUT, that may waste some time.

Same here ("contian").

--D
>
> Signed-off-by: Robin Dong <[email protected]>
> Reviewed-by: Lukas Czerner <[email protected]>
> ---
> 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
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2011-06-28 00:45:02

by Eric Gouriou

[permalink] [raw]
Subject: Re: [PATCH v2] ext4: avoid redundant cache finding if flags not cantian PUNCH_OUT

On Mon, Jun 27, 2011 at 12:59, Darrick J. Wong <[email protected]> wrote:
> On Mon, Jun 27, 2011 at 06:45:13PM +0800, Robin Dong wrote:
>> Subject: [PATCH v2] ext4: avoid redundant cache finding if flags not cantian
>
> I suspect you mean "contain" as opposed to "cantian".

The patch summary line could also use some shortening.

>> In old code, ext4 will find extent in cache first even flags does
>> not contian PUNCH_OUT, that may waste some time.
>
> Same here ("contian").

How about something along the lines of:
---------
ext4: avoid wasted extent cache lookup if !PUNCH_OUT_EXT

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

Regards - Eric

>
> --D
>>
>> Signed-off-by: Robin Dong <[email protected]>
>> Reviewed-by: Lukas Czerner <[email protected]>
>> ---
>>  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
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>> the body of a message to [email protected]
>> 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 [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>