From: Niu Yawei Date: Thu, 19 Jan 2017 02:58:51 +0000 (-0500) Subject: LU-9033 llite: don't zero timestamps internally X-Git-Tag: 2.9.53~29 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8718346e06cf2e17447dd3e3dc4e45b66d945aaf LU-9033 llite: don't zero timestamps internally In ll_md_blocking_ast(), we zero all timestamps to avoid these 'leftovers' interfering the new timestamps from MDS, especially when the timestamps are set back by other clients. It's not quite right to change timestamps in this way, because: 1. The pending lock can be matched by getattr, so these zero timestamps can be fetched by application in a small race window. 2. It doesn't make sense to zero the mtime and ctime, because we always use the newest ctime and mtime from MDS when do attributes merge, they won't interfere new timestamps set by other clients. Signed-off-by: Niu Yawei Change-Id: Ieb9577abe4938bc47dc0577454a4a1bbf4796876 Reviewed-on: https://review.whamcloud.com/24984 Tested-by: Jenkins Reviewed-by: Jinshan Xiong Tested-by: Maloo Reviewed-by: Andreas Dilger --- diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 95d1598..2b68937 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -1013,8 +1013,10 @@ int ll_merge_attr(const struct lu_env *env, struct inode *inode) * All in all, the atime in Lustre does not strictly comply with * POSIX. Solving this problem needs to send an RPC to MDT for each * read, this will hurt performance. */ - if (LTIME_S(inode->i_atime) < lli->lli_atime) + if (LTIME_S(inode->i_atime) < lli->lli_atime || lli->lli_update_atime) { LTIME_S(inode->i_atime) = lli->lli_atime; + lli->lli_update_atime = 0; + } LTIME_S(inode->i_mtime) = lli->lli_mtime; LTIME_S(inode->i_ctime) = lli->lli_ctime; diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 6f621d8..506ca46 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -133,6 +133,10 @@ struct ll_inode_info { s64 lli_ctime; spinlock_t lli_agl_lock; + /* update atime from MDS no matter if it's older than + * local inode atime. */ + unsigned int lli_update_atime:1; + /* Try to make the d::member and f::member are aligned. Before using * these members, make clear whether it is directory or not. */ union { diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 51d9aba..1d9e9ce 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -271,12 +271,7 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, if (bits & MDS_INODELOCK_UPDATE) { struct ll_inode_info *lli = ll_i2info(inode); - - spin_lock(&lli->lli_lock); - LTIME_S(inode->i_mtime) = 0; - LTIME_S(inode->i_atime) = 0; - LTIME_S(inode->i_ctime) = 0; - spin_unlock(&lli->lli_lock); + lli->lli_update_atime = 1; } if ((bits & MDS_INODELOCK_UPDATE) && S_ISDIR(inode->i_mode)) {