Skip to contentSkip to conversation

Q. NFS, return value of close(2)

DISCUSSION Applied J. R. Okajima 3 participants 5 messages Aug 11, 2010 – Aug 13, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

By the commit af7fa16 "NFS: Fix up the fsync code", close(2) seems to return the non-zero value even if it goes well, eg. the number of page via

nfs_file_flush()
vfs_fsync()
nfs_file_fsync()
nfs_commit_inode()
nfs_scan_commit()
nfs_scan_list()

Should nfs_file_fsync() return 0 when "status" is positive?

{
	status = nfs_commit_inode(inode, FLUSH_SYNC);
		;;;
-	if (!ret)
+	if (!ret && status < 0)
		ret = status;
}

J. R. Okajima

#1 lore raw
Quoted 21 lines · J. R. Okajima

By the commit af7fa16 "NFS: Fix up the fsync code", close(2) seems to return the non-zero value even if it goes well, eg. the number of page via

nfs_file_flush()
vfs_fsync()
nfs_file_fsync()
nfs_commit_inode()
nfs_scan_commit()
nfs_scan_list()

Should nfs_file_fsync() return 0 when "status" is positive?

{
	status = nfs_commit_inode(inode, FLUSH_SYNC);
		;;;
(quoted diff) +1 -1
-	if (!ret)
+	if (!ret && status < 0)
		ret = status;
}
Quoted 1 line

J. R. Okajima

Yes. That looks correct. Can you resend with an appropriate signed-off line, etc.?

Cheers
Trond

#2 lore raw

Trond Myklebust:

Quoted 2 lines

Yes. That looks correct. Can you resend with an appropriate signed-off line, etc.?

Sure.

----------------------------------------------------------------------
commit e56f956a08a6227004cd9b7747df6a089dbb3594

Author: J. R. Okajima <[email protected]>
Date:   Thu Aug 12 02:00:02 2010 +0900

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.

fs/nfs/file.c +1 -1
index 2d141a7..eb51bd6 100644
@@ -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;
 }
#3 lore raw
Quoted 5 lines · J. R. Okajima

Trond Myklebust:

Quoted 2 lines

Yes. That looks correct. Can you resend with an appropriate signed-off line, etc.?

Sure.

Thank you! Applied...

Trond

Quoted 27 lines

----------------------------------------------------------------------
commit e56f956a08a6227004cd9b7747df6a089dbb3594

Author: J. R. Okajima <[email protected]>
Date:   Thu Aug 12 02:00:02 2010 +0900

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.

fs/nfs/file.c +1 -1
index 2d141a7..eb51bd6 100644
@@ -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;
 }
#4 lore raw
Quoted 4 lines · Trond Myklebust
Quoted 4 lines

commit e56f956a08a6227004cd9b7747df6a089dbb3594

Author: J. R. Okajima <[email protected]>
Date:   Thu Aug 12 02:00:02 2010 +0900
Quoted 8 lines
Quoted 8 lines

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.

Hi,

please can you send this patch to Linus' tree?
NFS is currently broken, so it will save time for people trying to bisect the problem.

It breaks even elementary operation on nfs mounts

# cat a > b
cat: write error

Patch above from nfs-git fixed the problem for me
http://git.linux-nfs.org/?p=trondmy/nfs-2.6.git;a=commitdiff;h=0702099bd86c33c2dcdbd3963433a61f3f503901

Thanks,
Milan
--
[email protected]