NFS: Don't do a full flush to disk on close() if we hold a delegation
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Sun, 6 May 2012 23:10:59 +0000 (19:10 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 8 May 2012 16:53:21 +0000 (12:53 -0400)
If we hold a delegation then we know that it should be safe to continue
to cache the data beyond the close(). However since the process that wrote
the data may die after close(), we may still want to send the data to
server before those RPCSEC_GSS credentials expire. We therefore compromise
by starting writeback to the server, but don't wait for completion.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/file.c

index aa9b709..8eda8a6 100644 (file)
@@ -174,6 +174,13 @@ nfs_file_flush(struct file *file, fl_owner_t id)
        if ((file->f_mode & FMODE_WRITE) == 0)
                return 0;
 
+       /*
+        * If we're holding a write delegation, then just start the i/o
+        * but don't wait for completion (or send a commit).
+        */
+       if (nfs_have_delegation(inode, FMODE_WRITE))
+               return filemap_fdatawrite(file->f_mapping);
+
        /* Flush writes to the server and return any errors */
        return vfs_fsync(file, 0);
 }