Close()/fsync() returns 1 or 2 (or more) on nfs v3/v4

From Linux NFS

Jump to: navigation, search

Contents

About

  • Kernel version: 2.6.36-rc1-3b89f567
  • Bug 16624
  • Reported by: Petr Vandrovec (August 19, 2010)
  • Closed by: Trond Myklebust (August 19, 2010)


Symptoms

  • nfs_file_fsync now calls nfs_commit_node(), which calls nfs_scan_commit(), which can return positive value of number of pages committed. If that number is > 0, then value is propagated back from fsync to vfs_fsync to nfs_file_flush to sys_close to caller, making applications very unhappy:
15497 close(1)                          = 2
15497 munmap(0x7fdcaede6000, 32768)     = 0
15497 write(2, "diff: ", 6)             = 6
15497 write(2, "standard output", 15)   = 15
15497 write(2, "\n", 1)                 = 1
15497 exit_group(2)                     = ?

15516 close(1)                          = 1
15516 munmap(0x7f454d92b000, 32768)     = 0
15516 write(2, "diff: ", 6)             = 6
15516 write(2, "standard output", 15)   = 15
15516 write(2, "\n", 1)                 = 1
15516 exit_group(2)                     = ?

15535 close(1)                          = 1
15535 munmap(0x7f8ec09fd000, 32768)     = 0
15535 write(2, "diff: ", 6)             = 6
15535 write(2, "standard output", 15)   = 15
15535 write(2, "\n", 1)                 = 1

15655 close(1)                          = 1
15655 munmap(0x7f9528391000, 32768)     = 0
15655 write(2, "grep: ", 6)             = 6
15655 write(2, "write error", 11)       = 11


First bad commit

commit af7fa16506bf9b6323e862a61e14c20555152bb3
Author: Trond Myklebust <Trond.Myklebust@netapp.com>
Date:   Sat Jul 31 14:29:06 2010 -0400

    NFS: Fix up the fsync code
    
    Christoph points out that the VFS will always flush out data before calling
    nfs_fsync(), so we can dispense with a full call to nfs_wb_all(), and
    replace that with a simpler call to nfs_commit_inode().
    
    Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>


Resolution

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>
Personal tools