From 52e0a32b780269ee658d9b6e45e61324ff9ff4cc Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Tue, 31 Dec 2013 16:07:37 +0800 Subject: [PATCH] LU-4388 llite: issue OST_SYNC for fsync() The last parameter @datasync of fsync() has following indication: * if datasync=0, we'd always flush data and metadata * if datasync=1, we'd always flush data while does not flush modifed metadata unless that metadata is needed in order to allow a subsequent data retrieval to be correctly handled. For example, a change to the file size would require a metadata flush. Lustre client can not tell the difference easily, and would issue MDS_SYNC and OST_SYNC in all cases. Signed-off-by: Bobi Jam Change-Id: I90fa8e761e91c8a04afba3fbfafe1f60f5839ad1 Reviewed-on: http://review.whamcloud.com/8684 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong --- lustre/llite/file.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 9018eb6..d0f978d 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2809,48 +2809,48 @@ int ll_fsync(struct file *file, int datasync) int ll_fsync(struct file *file, struct dentry *dentry, int datasync) { #endif - struct inode *inode = dentry->d_inode; - struct ll_inode_info *lli = ll_i2info(inode); - struct ptlrpc_request *req; - struct obd_capa *oc; - int rc, err; - ENTRY; + struct inode *inode = dentry->d_inode; + struct ll_inode_info *lli = ll_i2info(inode); + struct ptlrpc_request *req; + struct obd_capa *oc; + int rc, err; + ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n", PFID(ll_inode2fid(inode)), inode); - ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FSYNC, 1); + 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); + /* 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. */ - if (!S_ISDIR(inode->i_mode)) { - err = lli->lli_async_rc; - lli->lli_async_rc = 0; - if (rc == 0) - rc = err; + /* catch async errors that were recorded back when async writeback + * failed for pages in this mapping. */ + if (!S_ISDIR(inode->i_mode)) { + err = lli->lli_async_rc; + lli->lli_async_rc = 0; + if (rc == 0) + rc = err; err = lov_read_and_clear_async_rc(lli->lli_clob); if (rc == 0) rc = err; - } + } - oc = ll_mdscapa_get(inode); + oc = ll_mdscapa_get(inode); err = md_fsync(ll_i2sbi(inode)->ll_md_exp, ll_inode2fid(inode), oc, &req); - capa_put(oc); - if (!rc) - rc = err; - if (!err) - ptlrpc_req_finished(req); + capa_put(oc); + if (!rc) + rc = err; + if (!err) + ptlrpc_req_finished(req); - if (datasync && S_ISREG(inode->i_mode)) { + if (S_ISREG(inode->i_mode)) { struct ll_file_data *fd = LUSTRE_FPRIVATE(file); err = cl_sync_file_range(inode, 0, OBD_OBJECT_EOF, -- 1.8.3.1