linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, fadvise: don't return -EINVAL when filesystem has no optimization way
@ 2012-06-15 20:36 kosaki.motohiro
  2012-06-20  5:01 ` KOSAKI Motohiro
  2012-06-20  6:31 ` Wanlong Gao
  0 siblings, 2 replies; 5+ messages in thread
From: kosaki.motohiro @ 2012-06-15 20:36 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, KOSAKI Motohiro, Hugh Dickins, Andrew Morton,
	Hillf Danton, Eric Wong

From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>

Eric Wong reported his test suite was fail when /tmp is tmpfs.

https://lkml.org/lkml/2012/2/24/479

Current,input check of POSIX_FADV_WILLNEED has two problems.

1) require a_ops->readpage.
   But in fact, force_page_cache_readahead() only require
   a target filesystem has either ->readpage or ->readpages.
2) return -EINVAL when filesystem don't have ->readpage.
   But, posix says, it should be retrieved a hint. Thus fadvise()
   should return 0 if filesystem has no optimization way.
   Especially, userland application don't know a filesystem type
   of TMPDIR directory as Eric pointed out. Then, userland can't
   avoid this error. We shouldn't encourage to ignore syscall
   return value.

Thus, this patch change a return value to 0 when filesytem don't
support readahead.

Cc: linux-mm@kvack.org
Cc: Hugh Dickins <hughd@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Hillf Danton <dhillf@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Tested-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
 mm/fadvise.c |   18 +++++++-----------
 1 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/mm/fadvise.c b/mm/fadvise.c
index 469491e..33e6baf 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -93,11 +93,6 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
 		spin_unlock(&file->f_lock);
 		break;
 	case POSIX_FADV_WILLNEED:
-		if (!mapping->a_ops->readpage) {
-			ret = -EINVAL;
-			break;
-		}
-
 		/* First and last PARTIAL page! */
 		start_index = offset >> PAGE_CACHE_SHIFT;
 		end_index = endbyte >> PAGE_CACHE_SHIFT;
@@ -106,12 +101,13 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
 		nrpages = end_index - start_index + 1;
 		if (!nrpages)
 			nrpages = ~0UL;
-		
-		ret = force_page_cache_readahead(mapping, file,
-				start_index,
-				nrpages);
-		if (ret > 0)
-			ret = 0;
+
+		/*
+		 * Ignore return value because fadvise() shall return 
+		 * success even if filesystem can't retrieve a hint,
+		 */		
+		force_page_cache_readahead(mapping, file, start_index,
+					   nrpages);
 		break;
 	case POSIX_FADV_NOREUSE:
 		break;
-- 
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm, fadvise: don't return -EINVAL when filesystem has no optimization way
  2012-06-15 20:36 [PATCH] mm, fadvise: don't return -EINVAL when filesystem has no optimization way kosaki.motohiro
@ 2012-06-20  5:01 ` KOSAKI Motohiro
  2012-06-20  6:31 ` Wanlong Gao
  1 sibling, 0 replies; 5+ messages in thread
From: KOSAKI Motohiro @ 2012-06-20  5:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-mm, KOSAKI Motohiro, Hugh Dickins, Andrew Morton,
	Hillf Danton, Eric Wong

On Fri, Jun 15, 2012 at 4:36 PM,  <kosaki.motohiro@gmail.com> wrote:
> From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>
> Eric Wong reported his test suite was fail when /tmp is tmpfs.
>
> https://lkml.org/lkml/2012/2/24/479
>
> Current,input check of POSIX_FADV_WILLNEED has two problems.
>
> 1) require a_ops->readpage.
>   But in fact, force_page_cache_readahead() only require
>   a target filesystem has either ->readpage or ->readpages.
> 2) return -EINVAL when filesystem don't have ->readpage.
>   But, posix says, it should be retrieved a hint. Thus fadvise()
>   should return 0 if filesystem has no optimization way.
>   Especially, userland application don't know a filesystem type
>   of TMPDIR directory as Eric pointed out. Then, userland can't
>   avoid this error. We shouldn't encourage to ignore syscall
>   return value.
>
> Thus, this patch change a return value to 0 when filesytem don't
> support readahead.
>
> Cc: linux-mm@kvack.org
> Cc: Hugh Dickins <hughd@google.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Hillf Danton <dhillf@gmail.com>
> Signed-off-by: Eric Wong <normalperson@yhbt.net>
> Tested-by: Eric Wong <normalperson@yhbt.net>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> ---

no objection?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm, fadvise: don't return -EINVAL when filesystem has no optimization way
  2012-06-15 20:36 [PATCH] mm, fadvise: don't return -EINVAL when filesystem has no optimization way kosaki.motohiro
  2012-06-20  5:01 ` KOSAKI Motohiro
@ 2012-06-20  6:31 ` Wanlong Gao
  2012-06-20  6:33   ` KOSAKI Motohiro
  1 sibling, 1 reply; 5+ messages in thread
From: Wanlong Gao @ 2012-06-20  6:31 UTC (permalink / raw)
  To: kosaki.motohiro
  Cc: linux-kernel, linux-mm, KOSAKI Motohiro, Hugh Dickins,
	Andrew Morton, Hillf Danton, Eric Wong

On 06/16/2012 04:36 AM, kosaki.motohiro@gmail.com wrote:
> From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> 
> Eric Wong reported his test suite was fail when /tmp is tmpfs.
> 
> https://lkml.org/lkml/2012/2/24/479
> 
> Current,input check of POSIX_FADV_WILLNEED has two problems.
> 
> 1) require a_ops->readpage.
>    But in fact, force_page_cache_readahead() only require
>    a target filesystem has either ->readpage or ->readpages.
> 2) return -EINVAL when filesystem don't have ->readpage.
>    But, posix says, it should be retrieved a hint. Thus fadvise()
>    should return 0 if filesystem has no optimization way.
>    Especially, userland application don't know a filesystem type
>    of TMPDIR directory as Eric pointed out. Then, userland can't
>    avoid this error. We shouldn't encourage to ignore syscall
>    return value.
> 
> Thus, this patch change a return value to 0 when filesytem don't
> support readahead.
> 
> Cc: linux-mm@kvack.org
> Cc: Hugh Dickins <hughd@google.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Hillf Danton <dhillf@gmail.com>
> Signed-off-by: Eric Wong <normalperson@yhbt.net>
> Tested-by: Eric Wong <normalperson@yhbt.net>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> ---
>  mm/fadvise.c |   18 +++++++-----------
>  1 files changed, 7 insertions(+), 11 deletions(-)
> 
> diff --git a/mm/fadvise.c b/mm/fadvise.c
> index 469491e..33e6baf 100644
> --- a/mm/fadvise.c
> +++ b/mm/fadvise.c
> @@ -93,11 +93,6 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
>  		spin_unlock(&file->f_lock);
>  		break;
>  	case POSIX_FADV_WILLNEED:
> -		if (!mapping->a_ops->readpage) {
> -			ret = -EINVAL;
> -			break;
> -		}

Why not check both readpage and readpages, if they are not here,
just beak and no following force_page_cache_readahead ?

Thanks,
Wanlong Gao

> -
>  		/* First and last PARTIAL page! */
>  		start_index = offset >> PAGE_CACHE_SHIFT;
>  		end_index = endbyte >> PAGE_CACHE_SHIFT;
> @@ -106,12 +101,13 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
>  		nrpages = end_index - start_index + 1;
>  		if (!nrpages)
>  			nrpages = ~0UL;
> -		
> -		ret = force_page_cache_readahead(mapping, file,
> -				start_index,
> -				nrpages);
> -		if (ret > 0)
> -			ret = 0;
> +
> +		/*
> +		 * Ignore return value because fadvise() shall return 
> +		 * success even if filesystem can't retrieve a hint,
> +		 */		
> +		force_page_cache_readahead(mapping, file, start_index,
> +					   nrpages);
>  		break;
>  	case POSIX_FADV_NOREUSE:
>  		break;
> 


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm, fadvise: don't return -EINVAL when filesystem has no optimization way
  2012-06-20  6:31 ` Wanlong Gao
@ 2012-06-20  6:33   ` KOSAKI Motohiro
  2012-06-20  6:37     ` Wanlong Gao
  0 siblings, 1 reply; 5+ messages in thread
From: KOSAKI Motohiro @ 2012-06-20  6:33 UTC (permalink / raw)
  To: gaowanlong
  Cc: kosaki.motohiro, linux-kernel, linux-mm, KOSAKI Motohiro,
	Hugh Dickins, Andrew Morton, Hillf Danton, Eric Wong

(6/20/12 2:31 AM), Wanlong Gao wrote:
> On 06/16/2012 04:36 AM, kosaki.motohiro@gmail.com wrote:
>> From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>>
>> Eric Wong reported his test suite was fail when /tmp is tmpfs.
>>
>> https://lkml.org/lkml/2012/2/24/479
>>
>> Current,input check of POSIX_FADV_WILLNEED has two problems.
>>
>> 1) require a_ops->readpage.
>>    But in fact, force_page_cache_readahead() only require
>>    a target filesystem has either ->readpage or ->readpages.
>> 2) return -EINVAL when filesystem don't have ->readpage.
>>    But, posix says, it should be retrieved a hint. Thus fadvise()
>>    should return 0 if filesystem has no optimization way.
>>    Especially, userland application don't know a filesystem type
>>    of TMPDIR directory as Eric pointed out. Then, userland can't
>>    avoid this error. We shouldn't encourage to ignore syscall
>>    return value.
>>
>> Thus, this patch change a return value to 0 when filesytem don't
>> support readahead.
>>
>> Cc: linux-mm@kvack.org
>> Cc: Hugh Dickins <hughd@google.com>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Cc: Hillf Danton <dhillf@gmail.com>
>> Signed-off-by: Eric Wong <normalperson@yhbt.net>
>> Tested-by: Eric Wong <normalperson@yhbt.net>
>> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>> ---
>>  mm/fadvise.c |   18 +++++++-----------
>>  1 files changed, 7 insertions(+), 11 deletions(-)
>>
>> diff --git a/mm/fadvise.c b/mm/fadvise.c
>> index 469491e..33e6baf 100644
>> --- a/mm/fadvise.c
>> +++ b/mm/fadvise.c
>> @@ -93,11 +93,6 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
>>  		spin_unlock(&file->f_lock);
>>  		break;
>>  	case POSIX_FADV_WILLNEED:
>> -		if (!mapping->a_ops->readpage) {
>> -			ret = -EINVAL;
>> -			break;
>> -		}
> 
> Why not check both readpage and readpages, if they are not here,
> just beak and no following force_page_cache_readahead ?

They are checked in force_page_cache_readahead.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] mm, fadvise: don't return -EINVAL when filesystem has no optimization way
  2012-06-20  6:33   ` KOSAKI Motohiro
@ 2012-06-20  6:37     ` Wanlong Gao
  0 siblings, 0 replies; 5+ messages in thread
From: Wanlong Gao @ 2012-06-20  6:37 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: linux-kernel, linux-mm, KOSAKI Motohiro, Hugh Dickins,
	Andrew Morton, Hillf Danton, Eric Wong

On 06/20/2012 02:33 PM, KOSAKI Motohiro wrote:
> (6/20/12 2:31 AM), Wanlong Gao wrote:
>> On 06/16/2012 04:36 AM, kosaki.motohiro@gmail.com wrote:
>>> From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>>>
>>> Eric Wong reported his test suite was fail when /tmp is tmpfs.
>>>
>>> https://lkml.org/lkml/2012/2/24/479
>>>
>>> Current,input check of POSIX_FADV_WILLNEED has two problems.
>>>
>>> 1) require a_ops->readpage.
>>>    But in fact, force_page_cache_readahead() only require
>>>    a target filesystem has either ->readpage or ->readpages.
>>> 2) return -EINVAL when filesystem don't have ->readpage.
>>>    But, posix says, it should be retrieved a hint. Thus fadvise()
>>>    should return 0 if filesystem has no optimization way.
>>>    Especially, userland application don't know a filesystem type
>>>    of TMPDIR directory as Eric pointed out. Then, userland can't
>>>    avoid this error. We shouldn't encourage to ignore syscall
>>>    return value.
>>>
>>> Thus, this patch change a return value to 0 when filesytem don't
>>> support readahead.
>>>
>>> Cc: linux-mm@kvack.org
>>> Cc: Hugh Dickins <hughd@google.com>
>>> Cc: Andrew Morton <akpm@linux-foundation.org>
>>> Cc: Hillf Danton <dhillf@gmail.com>
>>> Signed-off-by: Eric Wong <normalperson@yhbt.net>
>>> Tested-by: Eric Wong <normalperson@yhbt.net>
>>> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>>> ---
>>>  mm/fadvise.c |   18 +++++++-----------
>>>  1 files changed, 7 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/mm/fadvise.c b/mm/fadvise.c
>>> index 469491e..33e6baf 100644
>>> --- a/mm/fadvise.c
>>> +++ b/mm/fadvise.c
>>> @@ -93,11 +93,6 @@ SYSCALL_DEFINE(fadvise64_64)(int fd, loff_t offset, loff_t len, int advice)
>>>  		spin_unlock(&file->f_lock);
>>>  		break;
>>>  	case POSIX_FADV_WILLNEED:
>>> -		if (!mapping->a_ops->readpage) {
>>> -			ret = -EINVAL;
>>> -			break;
>>> -		}
>>
>> Why not check both readpage and readpages, if they are not here,
>> just beak and no following force_page_cache_readahead ?
> 
> They are checked in force_page_cache_readahead.

I see, thank you.

Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>


> 
> 


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2012-06-20  6:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-15 20:36 [PATCH] mm, fadvise: don't return -EINVAL when filesystem has no optimization way kosaki.motohiro
2012-06-20  5:01 ` KOSAKI Motohiro
2012-06-20  6:31 ` Wanlong Gao
2012-06-20  6:33   ` KOSAKI Motohiro
2012-06-20  6:37     ` Wanlong Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox