Patchwork ext4: avoid redundant cache finding if flags not cantian PUNCH_OUT

login
register
mail settings
Submitter Robin Dong
Date June 27, 2011, 6:33 a.m.
Message ID <1309156420-4201-1-git-send-email-sanbai@taobao.com>
Download mbox | patch
Permalink /patch/102113/
State Superseded
Headers show

Comments

Robin Dong - June 27, 2011, 6:33 a.m.
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 <sanbai@taobao.com>
---
 fs/ext4/extents.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Lukas Czerner - June 27, 2011, 10:15 a.m.
On Mon, 27 Jun 2011, Robin Dong wrote:

> 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 <sanbai@taobao.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..d583ec3 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) == 0) &&
> +		ext4_ext_in_cache(inode, map->m_lblk, &newex)) {

Hi Robin,

The patch is good thanks, but I think that this:

	if (!(flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) &&
	    ext4_ext_in_cache(inode, map->m_lblk, &newex)) {

looks better.

Thanks!
-Lukas

>  		if (!newex.ee_start_lo && !newex.ee_start_hi) {
>  			if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {
>  				/*
> 
--
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

Patch

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index eb63c7b..d583ec3 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) == 0) &&
+		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) {
 				/*