Whamcloud - gitweb
LU-812 llite: 3.0+ kernel fsync should call write
authorPeng Tao <tao.peng@emc.com>
Tue, 25 Sep 2012 11:16:14 +0000 (19:16 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 29 Oct 2012 06:09:57 +0000 (02:09 -0400)
Since 3.0, kernel pushes i_mutex and fsync to fs fsync
callback. So Lustre should check and do the same. Otherwise
there might be data corruption and sanity 63b will fail.

Signed-off-by: Peng Tao <tao.peng@emc.com>
Change-Id: I2f2f6792276eaf6783bffb813f3c3e5405be0450
Reviewed-on: http://review.whamcloud.com/4091
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/llite/file.c

index fc92452..e988c81 100644 (file)
@@ -2078,9 +2078,14 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
                inode->i_generation, inode);
         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FSYNC, 1);
 
+#ifdef HAVE_FILE_FSYNC_4ARGS
+       rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
+       mutex_lock(&inode->i_mutex);
+#else
         /* fsync's caller has already called _fdata{sync,write}, we want
          * that IO to finish before calling the osc and mdc sync methods */
         rc = filemap_fdatawait(inode->i_mapping);
+#endif
 
         /* catch async errors that were recorded back when async writeback
          * failed for pages in this mapping. */
@@ -2118,6 +2123,9 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
        }
        ccc_inode_lsm_put(inode, lsm);
 
+#ifdef HAVE_FILE_FSYNC_4ARGS
+       mutex_unlock(&inode->i_mutex);
+#endif
        RETURN(rc);
 }