NFS: Write the entire file if a server reboot occurs during fsync()
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Tue, 11 Sep 2012 20:19:38 +0000 (16:19 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 28 Sep 2012 20:03:05 +0000 (16:03 -0400)
This is to ensure that we don't clear the NFS_CONTEXT_RESEND_WRITES
flag while there are still writes that haven't been resent.

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

index cc9b56691bef42a5205011192542f92c906c616f..c814666bbe7f92a5af33f9d8d697820c5ac90bed 100644 (file)
@@ -301,6 +301,13 @@ nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
                mutex_lock(&inode->i_mutex);
                ret = nfs_file_fsync_commit(file, start, end, datasync);
                mutex_unlock(&inode->i_mutex);
+               /*
+                * If nfs_file_fsync_commit detected a server reboot, then
+                * resend all dirty pages that might have been covered by
+                * the NFS_CONTEXT_RESEND_WRITES flag
+                */
+               start = 0;
+               end = LLONG_MAX;
        } while (ret == -EAGAIN);
 
        return ret;
index eef1b38a1b082b9530911069fa902e53bd181e9f..afddd6639afb1bd5242e95c5b659fa2b86174181 100644 (file)
@@ -105,6 +105,13 @@ nfs4_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
                        /* application has asked for meta-data sync */
                        ret = pnfs_layoutcommit_inode(inode, true);
                mutex_unlock(&inode->i_mutex);
+               /*
+                * If nfs_file_fsync_commit detected a server reboot, then
+                * resend all dirty pages that might have been covered by
+                * the NFS_CONTEXT_RESEND_WRITES flag
+                */
+               start = 0;
+               end = LLONG_MAX;
        } while (ret == -EAGAIN);
 
        return ret;