All of lore.kernel.org
 help / color / mirror / Atom feed
* nfs regression 2.6.35+
@ 2010-08-16  7:06 Shaohua Li
  2010-08-16 10:09 ` Takashi Iwai
  2010-08-16 22:47 ` Trond Myklebust
  0 siblings, 2 replies; 7+ messages in thread
From: Shaohua Li @ 2010-08-16  7:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: rjw, Trond.Myklebust

NFS client runs latest git. At client side, use vim to edit a file located at
NFS server. If I save the file, vim always reports 'E667: Fsync failed'. If I
revert f7fa16506bf9b6323e862a61e14c20555152bb3, vim works. No kernel errors
reported.

Thanks,
Shaohua

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

* Re: nfs regression 2.6.35+
  2010-08-16  7:06 nfs regression 2.6.35+ Shaohua Li
@ 2010-08-16 10:09 ` Takashi Iwai
  2010-08-16 10:40   ` Takashi Iwai
  2010-08-16 22:47 ` Trond Myklebust
  1 sibling, 1 reply; 7+ messages in thread
From: Takashi Iwai @ 2010-08-16 10:09 UTC (permalink / raw)
  To: Shaohua Li; +Cc: Trond.Myklebust, rjw, linux-kernel, linux-nfs

[Added linux-nfs to Cc]

At Mon, 16 Aug 2010 15:06:26 +0800,
Shaohua Li wrote:
> 
> NFS client runs latest git. At client side, use vim to edit a file located at
> NFS server. If I save the file, vim always reports 'E667: Fsync failed'. If I
> revert f7fa16506bf9b6323e862a61e14c20555152bb3, vim works. No kernel errors
> reported.

This hits me, too.  Reverting it cures the problem.
(BTW, the correct commit id of the affecting patch is
 af7fa16506bf9b6323e862a61e14c20555152bb3
 "NFS: Fix up the fsync code")

Reproduced on 2.6.36-rc1.

Looking at strace output, 

  open("afo", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
  write(4, "#!/bin\n", 7)                 = 7
  fsync(4)                                = 1
  stat("afo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0
  close(4)                                = 0

So, fsync() returns 1 wrongly.


thanks,

Takashi

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

* Re: nfs regression 2.6.35+
  2010-08-16 10:09 ` Takashi Iwai
@ 2010-08-16 10:40   ` Takashi Iwai
  2010-08-16 16:35       ` Bill Davidsen
  2010-08-16 18:17     ` Nick Bowler
  0 siblings, 2 replies; 7+ messages in thread
From: Takashi Iwai @ 2010-08-16 10:40 UTC (permalink / raw)
  To: Shaohua Li; +Cc: Trond.Myklebust, rjw, linux-kernel, linux-nfs

At Mon, 16 Aug 2010 12:09:12 +0200, Takashi Iwai wrote:
> At Mon, 16 Aug 2010 15:06:26 +0800,
> Shaohua Li wrote:
> > 
> > NFS client runs latest git. At client side, use vim to edit a file located at
> > NFS server. If I save the file, vim always reports 'E667: Fsync failed'. If I
> > revert f7fa16506bf9b6323e862a61e14c20555152bb3, vim works. No kernel errors
> > reported.
> 
> This hits me, too.  Reverting it cures the problem.
> (BTW, the correct commit id of the affecting patch is
>  af7fa16506bf9b6323e862a61e14c20555152bb3
>  "NFS: Fix up the fsync code")
> 
> Reproduced on 2.6.36-rc1.
> 
> Looking at strace output, 
> 
>   open("afo", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
>   write(4, "#!/bin\n", 7)                 = 7
>   fsync(4)                                = 1
>   stat("afo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0
>   close(4)                                = 0
> 
> So, fsync() returns 1 wrongly.

How about a band-aid fix below?


Takashi


>From c75eab5ac47f5ce27a0d450423f8c46824f832f0 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Mon, 16 Aug 2010 12:25:19 +0200
Subject: [PATCH] NFS: fix fsync return code

With the commit af7fa16506bf9b6323e862a61e14c20555152bb3
    NFS: Fix up the fsync code
fsync returns a postive number for success incorrectly because now it
calls nfs_commit_inode() which returns the number of pages.

This patch makes fsync simply ignore a positive return value.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 fs/nfs/file.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 2d141a7..eb51bd6 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -323,7 +323,7 @@ nfs_file_fsync(struct file *file, int datasync)
 	have_error |= test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
 	if (have_error)
 		ret = xchg(&ctx->error, 0);
-	if (!ret)
+	if (!ret && status < 0)
 		ret = status;
 	return ret;
 }
-- 
1.7.2.1


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

* Re: nfs regression 2.6.35+
  2010-08-16 10:40   ` Takashi Iwai
@ 2010-08-16 16:35       ` Bill Davidsen
  2010-08-16 18:17     ` Nick Bowler
  1 sibling, 0 replies; 7+ messages in thread
From: Bill Davidsen @ 2010-08-16 16:35 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Shaohua Li, Trond.Myklebust, rjw, linux-kernel, linux-nfs

Takashi Iwai wrote:
> At Mon, 16 Aug 2010 12:09:12 +0200, Takashi Iwai wrote:
>> At Mon, 16 Aug 2010 15:06:26 +0800,
>> Shaohua Li wrote:
>>> NFS client runs latest git. At client side, use vim to edit a file located at
>>> NFS server. If I save the file, vim always reports 'E667: Fsync failed'. If I
>>> revert f7fa16506bf9b6323e862a61e14c20555152bb3, vim works. No kernel errors
>>> reported.
>> This hits me, too.  Reverting it cures the problem.
>> (BTW, the correct commit id of the affecting patch is
>>  af7fa16506bf9b6323e862a61e14c20555152bb3
>>  "NFS: Fix up the fsync code")
>>
>> Reproduced on 2.6.36-rc1.
>>
>> Looking at strace output, 
>>
>>   open("afo", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
>>   write(4, "#!/bin\n", 7)                 = 7
>>   fsync(4)                                = 1
>>   stat("afo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0
>>   close(4)                                = 0
>>
>> So, fsync() returns 1 wrongly.
> 
> How about a band-aid fix below?
> 
Your band-aid sticks for me.

> 
> Takashi
> 
> 
> From c75eab5ac47f5ce27a0d450423f8c46824f832f0 Mon Sep 17 00:00:00 2001
> From: Takashi Iwai <tiwai@suse.de>
> Date: Mon, 16 Aug 2010 12:25:19 +0200
> Subject: [PATCH] NFS: fix fsync return code
> 
> With the commit af7fa16506bf9b6323e862a61e14c20555152bb3
>     NFS: Fix up the fsync code
> fsync returns a postive number for success incorrectly because now it
> calls nfs_commit_inode() which returns the number of pages.
> 
> This patch makes fsync simply ignore a positive return value.
> 
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
>  fs/nfs/file.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/nfs/file.c b/fs/nfs/file.c
> index 2d141a7..eb51bd6 100644
> --- a/fs/nfs/file.c
> +++ b/fs/nfs/file.c
> @@ -323,7 +323,7 @@ nfs_file_fsync(struct file *file, int datasync)
>  	have_error |= test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
>  	if (have_error)
>  		ret = xchg(&ctx->error, 0);
> -	if (!ret)
> +	if (!ret && status < 0)
>  		ret = status;
>  	return ret;
>  }


-- 
Bill Davidsen <davidsen-sQDSfeB7uhw@public.gmane.org>
   "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot

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

* Re: nfs regression 2.6.35+
@ 2010-08-16 16:35       ` Bill Davidsen
  0 siblings, 0 replies; 7+ messages in thread
From: Bill Davidsen @ 2010-08-16 16:35 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Shaohua Li, Trond.Myklebust, rjw, linux-kernel, linux-nfs

Takashi Iwai wrote:
> At Mon, 16 Aug 2010 12:09:12 +0200, Takashi Iwai wrote:
>> At Mon, 16 Aug 2010 15:06:26 +0800,
>> Shaohua Li wrote:
>>> NFS client runs latest git. At client side, use vim to edit a file located at
>>> NFS server. If I save the file, vim always reports 'E667: Fsync failed'. If I
>>> revert f7fa16506bf9b6323e862a61e14c20555152bb3, vim works. No kernel errors
>>> reported.
>> This hits me, too.  Reverting it cures the problem.
>> (BTW, the correct commit id of the affecting patch is
>>  af7fa16506bf9b6323e862a61e14c20555152bb3
>>  "NFS: Fix up the fsync code")
>>
>> Reproduced on 2.6.36-rc1.
>>
>> Looking at strace output, 
>>
>>   open("afo", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
>>   write(4, "#!/bin\n", 7)                 = 7
>>   fsync(4)                                = 1
>>   stat("afo", {st_mode=S_IFREG|0644, st_size=7, ...}) = 0
>>   close(4)                                = 0
>>
>> So, fsync() returns 1 wrongly.
> 
> How about a band-aid fix below?
> 
Your band-aid sticks for me.

> 
> Takashi
> 
> 
> From c75eab5ac47f5ce27a0d450423f8c46824f832f0 Mon Sep 17 00:00:00 2001
> From: Takashi Iwai <tiwai@suse.de>
> Date: Mon, 16 Aug 2010 12:25:19 +0200
> Subject: [PATCH] NFS: fix fsync return code
> 
> With the commit af7fa16506bf9b6323e862a61e14c20555152bb3
>     NFS: Fix up the fsync code
> fsync returns a postive number for success incorrectly because now it
> calls nfs_commit_inode() which returns the number of pages.
> 
> This patch makes fsync simply ignore a positive return value.
> 
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
>  fs/nfs/file.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/nfs/file.c b/fs/nfs/file.c
> index 2d141a7..eb51bd6 100644
> --- a/fs/nfs/file.c
> +++ b/fs/nfs/file.c
> @@ -323,7 +323,7 @@ nfs_file_fsync(struct file *file, int datasync)
>  	have_error |= test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
>  	if (have_error)
>  		ret = xchg(&ctx->error, 0);
> -	if (!ret)
> +	if (!ret && status < 0)
>  		ret = status;
>  	return ret;
>  }


-- 
Bill Davidsen <davidsen@tmr.com>
   "We have more to fear from the bungling of the incompetent than from
the machinations of the wicked."  - from Slashdot

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

* Re: nfs regression 2.6.35+
  2010-08-16 10:40   ` Takashi Iwai
  2010-08-16 16:35       ` Bill Davidsen
@ 2010-08-16 18:17     ` Nick Bowler
  1 sibling, 0 replies; 7+ messages in thread
From: Nick Bowler @ 2010-08-16 18:17 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Shaohua Li, Trond.Myklebust, rjw, linux-kernel, linux-nfs

On 2010-08-16 12:40 +0200, Takashi Iwai wrote:
> At Mon, 16 Aug 2010 12:09:12 +0200, Takashi Iwai wrote:
> > This hits me, too.  Reverting it cures the problem.
> > (BTW, the correct commit id of the affecting patch is
> >  af7fa16506bf9b6323e862a61e14c20555152bb3
> >  "NFS: Fix up the fsync code")
> > 
> > Reproduced on 2.6.36-rc1.
> > 
> > So, fsync() returns 1 wrongly.

Apparently this breaks NFS file locks as well:  

  fetchmail: starting fetchmail 6.3.17 daemon
  /home/nbowler/.fetchmail.pid: Bad file descriptor
  fetchmail: lock creation failed.

> How about a band-aid fix below?
[...]
> Subject: [PATCH] NFS: fix fsync return code

and this fixes all the problems for me.

-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)

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

* Re: nfs regression 2.6.35+
  2010-08-16  7:06 nfs regression 2.6.35+ Shaohua Li
  2010-08-16 10:09 ` Takashi Iwai
@ 2010-08-16 22:47 ` Trond Myklebust
  1 sibling, 0 replies; 7+ messages in thread
From: Trond Myklebust @ 2010-08-16 22:47 UTC (permalink / raw)
  To: Shaohua Li; +Cc: linux-kernel, rjw

On Mon, 2010-08-16 at 15:06 +0800, Shaohua Li wrote:
> NFS client runs latest git. At client side, use vim to edit a file located at
> NFS server. If I save the file, vim always reports 'E667: Fsync failed'. If I
> revert f7fa16506bf9b6323e862a61e14c20555152bb3, vim works. No kernel errors
> reported.
> 
> Thanks,
> Shaohua
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

There is already a fix for this in the linux-next tree and in the
'bugfixes' branch of
git://git.linux-nfs.org/projects/trondmy/nfs-2.6.git: see commit
0702099bd86c33c2dcdbd3963433a61f3f503901 (NFS: fix the return value of
nfs_file_fsync()).

I haven't pushed it to Linus yet due to excessive travel this past week.
Will do so soon.

Cheers
  Trond

----------------------------------------------------------------------------------------
commit 0702099bd86c33c2dcdbd3963433a61f3f503901
Author: J. R. Okajima <hooanon05@yahoo.co.jp>
Date:   Wed Aug 11 13:10:16 2010 -0400

    NFS: fix the return value of nfs_file_fsync()
    
    By the commit af7fa16 2010-08-03 NFS: Fix up the fsync code
    close(2) became returning the non-zero value even if it went well.
    nfs_file_fsync() should return 0 when "status" is positive.
    
    Signed-off-by: J. R. Okajima <hooanon05@yahoo.co.jp>
    Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 2d141a7..eb51bd6 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -323,7 +323,7 @@ nfs_file_fsync(struct file *file, int datasync)
 	have_error |= test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
 	if (have_error)
 		ret = xchg(&ctx->error, 0);
-	if (!ret)
+	if (!ret && status < 0)
 		ret = status;
 	return ret;
 }


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

end of thread, other threads:[~2010-08-16 22:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-16  7:06 nfs regression 2.6.35+ Shaohua Li
2010-08-16 10:09 ` Takashi Iwai
2010-08-16 10:40   ` Takashi Iwai
2010-08-16 16:35     ` Bill Davidsen
2010-08-16 16:35       ` Bill Davidsen
2010-08-16 18:17     ` Nick Bowler
2010-08-16 22:47 ` Trond Myklebust

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.