linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] ext4: Make ext4_ext_find_extent fills ext_path completely
@ 2008-06-11  5:55 Shen Feng
  2008-06-11 11:43 ` Aneesh Kumar K.V
  2008-06-12 22:27 ` Mingming Cao
  0 siblings, 2 replies; 6+ messages in thread
From: Shen Feng @ 2008-06-11  5:55 UTC (permalink / raw)
  To: linux-ext4, Theodore Tso, Mingming Cao, Andrew Morton

When pos=0 or depth, the fields of ext4_ext_path is not
completely filled.
This patch also removes some unnecessary code.

Signed-off-by: Shen Feng <shen@cn.fujitsu.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 d4f76d7..ff609df 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -524,6 +524,7 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
 		alloc = 1;
 	}
 	path[0].p_hdr = eh;
+	path[0].p_bh = NULL;
 
 	i = depth;
 	/* walk through the tree */
@@ -552,12 +553,11 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
 	}
 
 	path[ppos].p_depth = i;
-	path[ppos].p_hdr = eh;
-	path[ppos].p_ext = NULL;
 	path[ppos].p_idx = NULL;
 
 	/* find extent */
 	ext4_ext_binsearch(inode, path + ppos, block);
+	path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext);
 
 	ext4_ext_show_path(inode, path);
 
-- 
1.5.4.5


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

* Re: [PATCH 2/2] ext4: Make ext4_ext_find_extent fills ext_path completely
  2008-06-11  5:55 [PATCH 2/2] ext4: Make ext4_ext_find_extent fills ext_path completely Shen Feng
@ 2008-06-11 11:43 ` Aneesh Kumar K.V
  2008-06-12  0:28   ` Shen Feng
  2008-06-12 22:27 ` Mingming Cao
  1 sibling, 1 reply; 6+ messages in thread
From: Aneesh Kumar K.V @ 2008-06-11 11:43 UTC (permalink / raw)
  To: Shen Feng; +Cc: linux-ext4, Theodore Tso, Mingming Cao, Andrew Morton

On Wed, Jun 11, 2008 at 01:55:10PM +0800, Shen Feng wrote:
> When pos=0 or depth, the fields of ext4_ext_path is not
> completely filled.
> This patch also removes some unnecessary code.
> 
> Signed-off-by: Shen Feng <shen@cn.fujitsu.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 d4f76d7..ff609df 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -524,6 +524,7 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
>  		alloc = 1;
>  	}
>  	path[0].p_hdr = eh;
> +	path[0].p_bh = NULL;


We did a kzalloc before. So do we need this ?



> 
>  	i = depth;
>  	/* walk through the tree */
> @@ -552,12 +553,11 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
>  	}
> 
>  	path[ppos].p_depth = i;
> -	path[ppos].p_hdr = eh;


This is needed. Because we look at extent_header  in ext_binsearch.



> -	path[ppos].p_ext = NULL;
>  	path[ppos].p_idx = NULL;
> 
>  	/* find extent */
>  	ext4_ext_binsearch(inode, path + ppos, block);
> +	path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext);
> 
>  	ext4_ext_show_path(inode, path);
> 

-aneesh

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

* Re: [PATCH 2/2] ext4: Make ext4_ext_find_extent fills ext_path completely
  2008-06-11 11:43 ` Aneesh Kumar K.V
@ 2008-06-12  0:28   ` Shen Feng
  0 siblings, 0 replies; 6+ messages in thread
From: Shen Feng @ 2008-06-12  0:28 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: linux-ext4, Theodore Tso, Mingming Cao, Andrew Morton



Aneesh Kumar K.V Wrote:
> On Wed, Jun 11, 2008 at 01:55:10PM +0800, Shen Feng wrote:
>> When pos=0 or depth, the fields of ext4_ext_path is not
>> completely filled.
>> This patch also removes some unnecessary code.
>>
>> Signed-off-by: Shen Feng <shen@cn.fujitsu.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 d4f76d7..ff609df 100644
>> --- a/fs/ext4/extents.c
>> +++ b/fs/ext4/extents.c
>> @@ -524,6 +524,7 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
>>  		alloc = 1;
>>  	}
>>  	path[0].p_hdr = eh;
>> +	path[0].p_bh = NULL;
> 
> 
> We did a kzalloc before. So do we need this ?

If the path is not allocated by kzalloc, we need this.

> 
> 
> 
>>  	i = depth;
>>  	/* walk through the tree */
>> @@ -552,12 +553,11 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
>>  	}
>>
>>  	path[ppos].p_depth = i;
>> -	path[ppos].p_hdr = eh;
> 
> 
> This is needed. Because we look at extent_header  in ext_binsearch.

This has been done in the last while loop.

> 
> 
> 
>> -	path[ppos].p_ext = NULL;
>>  	path[ppos].p_idx = NULL;
>>
>>  	/* find extent */
>>  	ext4_ext_binsearch(inode, path + ppos, block);
>> +	path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext);
>>
>>  	ext4_ext_show_path(inode, path);
>>
> 
> -aneesh
> 
> 



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

* Re: [PATCH 2/2] ext4: Make ext4_ext_find_extent fills ext_path completely
  2008-06-11  5:55 [PATCH 2/2] ext4: Make ext4_ext_find_extent fills ext_path completely Shen Feng
  2008-06-11 11:43 ` Aneesh Kumar K.V
@ 2008-06-12 22:27 ` Mingming Cao
  2008-06-13  5:40   ` Shen Feng
  1 sibling, 1 reply; 6+ messages in thread
From: Mingming Cao @ 2008-06-12 22:27 UTC (permalink / raw)
  To: Shen Feng; +Cc: linux-ext4, Theodore Tso, Andrew Morton

On Wed, 2008-06-11 at 13:55 +0800, Shen Feng wrote:
> When pos=0 or depth, the fields of ext4_ext_path is not
> completely filled.
> This patch also removes some unnecessary code.
> 

I added this patch to the patch queue, unless somebody disagree.

Mingming
> Signed-off-by: Shen Feng <shen@cn.fujitsu.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 d4f76d7..ff609df 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -524,6 +524,7 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
>  		alloc = 1;
>  	}
>  	path[0].p_hdr = eh;
> +	path[0].p_bh = NULL;
> 
>  	i = depth;
>  	/* walk through the tree */
> @@ -552,12 +553,11 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
>  	}
> 
>  	path[ppos].p_depth = i;
> -	path[ppos].p_hdr = eh;
> -	path[ppos].p_ext = NULL;
>  	path[ppos].p_idx = NULL;
> 
>  	/* find extent */
>  	ext4_ext_binsearch(inode, path + ppos, block);
> +	path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext);
> 
>  	ext4_ext_show_path(inode, path);
> 


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

* Re: [PATCH 2/2] ext4: Make ext4_ext_find_extent fills ext_path completely
  2008-06-12 22:27 ` Mingming Cao
@ 2008-06-13  5:40   ` Shen Feng
  2008-06-13  6:47     ` Shen Feng
  0 siblings, 1 reply; 6+ messages in thread
From: Shen Feng @ 2008-06-13  5:40 UTC (permalink / raw)
  To: cmm; +Cc: linux-ext4, Theodore Tso, Andrew Morton



Mingming Cao Wrote:
> On Wed, 2008-06-11 at 13:55 +0800, Shen Feng wrote:
>> When pos=0 or depth, the fields of ext4_ext_path is not
>> completely filled.
>> This patch also removes some unnecessary code.
>>
> 
> I added this patch to the patch queue, unless somebody disagree.
> 
> Mingming
>> Signed-off-by: Shen Feng <shen@cn.fujitsu.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 d4f76d7..ff609df 100644
>> --- a/fs/ext4/extents.c
>> +++ b/fs/ext4/extents.c
>> @@ -524,6 +524,7 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
>>  		alloc = 1;
>>  	}
>>  	path[0].p_hdr = eh;
>> +	path[0].p_bh = NULL;
>>
>>  	i = depth;
>>  	/* walk through the tree */
>> @@ -552,12 +553,11 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
>>  	}
>>
>>  	path[ppos].p_depth = i;
>> -	path[ppos].p_hdr = eh;
>> -	path[ppos].p_ext = NULL;
>>  	path[ppos].p_idx = NULL;
>>
>>  	/* find extent */
>>  	ext4_ext_binsearch(inode, path + ppos, block);
>> +	path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext);

Today I tested the patch with bonnie++ and found that sometimes
path[ppos].p_ext may be NULL. This may cause kernel oops.

This is because ext4_ext_binsearch return directly when the leaf is empty.



>>
>>  	ext4_ext_show_path(inode, path);
>>
> 
> 
> 


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

* Re: [PATCH 2/2] ext4: Make ext4_ext_find_extent fills ext_path completely
  2008-06-13  5:40   ` Shen Feng
@ 2008-06-13  6:47     ` Shen Feng
  0 siblings, 0 replies; 6+ messages in thread
From: Shen Feng @ 2008-06-13  6:47 UTC (permalink / raw)
  To: cmm; +Cc: linux-ext4, Theodore Tso, Andrew Morton



Shen Feng Wrote:
> 
> Mingming Cao Wrote:
>> On Wed, 2008-06-11 at 13:55 +0800, Shen Feng wrote:
>>> When pos=0 or depth, the fields of ext4_ext_path is not
>>> completely filled.
>>> This patch also removes some unnecessary code.
>>>
>> I added this patch to the patch queue, unless somebody disagree.
>>
>> Mingming
>>> Signed-off-by: Shen Feng <shen@cn.fujitsu.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 d4f76d7..ff609df 100644
>>> --- a/fs/ext4/extents.c
>>> +++ b/fs/ext4/extents.c
>>> @@ -524,6 +524,7 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
>>>  		alloc = 1;
>>>  	}
>>>  	path[0].p_hdr = eh;
>>> +	path[0].p_bh = NULL;
>>>
>>>  	i = depth;
>>>  	/* walk through the tree */
>>> @@ -552,12 +553,11 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
>>>  	}
>>>
>>>  	path[ppos].p_depth = i;
>>> -	path[ppos].p_hdr = eh;
>>> -	path[ppos].p_ext = NULL;
>>>  	path[ppos].p_idx = NULL;
>>>
>>>  	/* find extent */
>>>  	ext4_ext_binsearch(inode, path + ppos, block);
>>> +	path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext);
> 
> Today I tested the patch with bonnie++ and found that sometimes
> path[ppos].p_ext may be NULL. This may cause kernel oops.
> 
> This is because ext4_ext_binsearch return directly when the leaf is empty.
> 
I updated the patch as following.
This patch is tested by bonnie++ and ltp fs test.
This patch is also rebased from the 2.6.26-RC5 and has no dependency to 
ext4: add ext4_ prefix for ext_block and idx_pblock patch.

Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
---
 fs/ext4/extents.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 47929c4..1d636cb 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -524,6 +524,7 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
 		alloc = 1;
 	}
 	path[0].p_hdr = eh;
+	path[0].p_bh = NULL;
 
 	i = depth;
 	/* walk through the tree */
@@ -552,12 +553,14 @@ ext4_ext_find_extent(struct inode *inode, ext4_lblk_t block,
 	}
 
 	path[ppos].p_depth = i;
-	path[ppos].p_hdr = eh;
 	path[ppos].p_ext = NULL;
 	path[ppos].p_idx = NULL;
 
 	/* find extent */
 	ext4_ext_binsearch(inode, path + ppos, block);
+	/* if not an empty leaf */
+	if (path[ppos].p_ext)
+		path[ppos].p_block = ext_pblock(path[ppos].p_ext);
 
 	ext4_ext_show_path(inode, path);
 
-- 1.5.5.1 

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

end of thread, other threads:[~2008-06-13  6:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-11  5:55 [PATCH 2/2] ext4: Make ext4_ext_find_extent fills ext_path completely Shen Feng
2008-06-11 11:43 ` Aneesh Kumar K.V
2008-06-12  0:28   ` Shen Feng
2008-06-12 22:27 ` Mingming Cao
2008-06-13  5:40   ` Shen Feng
2008-06-13  6:47     ` Shen Feng

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