Whamcloud - gitweb
LU-11404 llite: only first sync to MDS matter 75/33175/19
authorAlex Zhuravlev <bzzz@whamcloud.com>
Thu, 20 Oct 2022 05:27:48 +0000 (08:27 +0300)
committerOleg Drokin <green@whamcloud.com>
Tue, 11 Apr 2023 20:04:24 +0000 (20:04 +0000)
fsync() is supposed to sync metadata and data, but given file's
layout the only first MDS_SYNC matters to ensure the file creation
has been committed, everything else go to OSTs (data and attributes)
also, uid/gid/mode, EAs and ACLs must be subject to sync.

Change-Id: Iaa9095a9ace319a6dfa8840313dc536e39786847
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/33175
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Mikhail Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/acl.c
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/xattr.c

index 5ae1aab..7d6d5be 100644 (file)
@@ -108,6 +108,8 @@ int ll_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
        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:
index 70c55e8..04138c5 100644 (file)
@@ -4798,11 +4798,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;
index 6e8b5c6..ab81f01 100644 (file)
@@ -150,6 +150,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;
index 4fcf0a7..39b3edb 100644 (file)
@@ -2300,6 +2300,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr,
        rc = ll_md_setattr(dentry, op_data);
        if (rc)
                GOTO(out, rc);
+       lli->lli_synced_to_mds = false;
 
        if (!S_ISREG(inode->i_mode) || hsm_import)
                GOTO(out, rc = 0);
index 9231650..a6c0d91 100644 (file)
@@ -175,6 +175,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);