@@ -94,6 +94,8 @@ int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type)
rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
value ? OBD_MD_FLXATTR : OBD_MD_FLXATTRRM,
name, value, value_size, 0, 0, &req);
+ if (!rc)
+ ll_i2info(inode)->lli_synced_to_mds = false;
ptlrpc_req_finished(req);
out_value:
@@ -4758,11 +4758,20 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
}
}
- err = md_fsync(ll_i2sbi(inode)->ll_md_exp, ll_inode2fid(inode), &req);
- if (!rc)
- rc = err;
- if (!err)
- ptlrpc_req_finished(req);
+ if (S_ISREG(inode->i_mode) && !lli->lli_synced_to_mds) {
+ /*
+ * only the first sync on MDS makes sense,
+ * everything else is stored on OSTs
+ */
+ err = md_fsync(ll_i2sbi(inode)->ll_md_exp,
+ ll_inode2fid(inode), &req);
+ if (!rc)
+ rc = err;
+ if (!err) {
+ lli->lli_synced_to_mds = true;
+ ptlrpc_req_finished(req);
+ }
+ }
if (S_ISREG(inode->i_mode)) {
struct ll_file_data *fd = file->private_data;
@@ -155,6 +155,7 @@ struct ll_inode_info {
s64 lli_ctime;
s64 lli_btime;
spinlock_t lli_agl_lock;
+ bool lli_synced_to_mds;
/* inode specific open lock caching threshold */
u32 lli_open_thrsh_count;
@@ -2181,6 +2181,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr,
rc = ll_md_setattr(dentry, op_data);
if (rc)
goto out;
+ lli->lli_synced_to_mds = false;
if (!S_ISREG(inode->i_mode) || hsm_import) {
rc = 0;
@@ -160,6 +160,7 @@ static int ll_xattr_set_common(const struct xattr_handler *handler,
}
return rc;
}
+ ll_i2info(inode)->lli_synced_to_mds = false;
ptlrpc_req_finished(req);