From 8f3ef1e961748525901ffb3948a333c2b1351a68 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Tue, 25 Sep 2012 19:16:14 +0800 Subject: [PATCH 1/1] LU-812 llite: 3.0+ kernel fsync should call write 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 Change-Id: I2f2f6792276eaf6783bffb813f3c3e5405be0450 Reviewed-on: http://review.whamcloud.com/4091 Tested-by: Hudson Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Bob Glossman Tested-by: Maloo --- lustre/llite/file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index fc92452..e988c81 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -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); } -- 1.8.3.1