[lustre-devel] [PATCH 15/40] lustre: llite: fix relatime support
James Simmons <[email protected]> Sun, 9 Apr 2023 08:12:55 -0400
| Newsgroups | org.lustre.lists.lustre-devel |
|---|---|
| Message-ID | <[email protected]> |
From: Aurelien Degremont <[email protected]> relatime behavior is properly managed by VFS, however Lustre also stores acmtime on OST objects and atime updates for OST objects should honor relatime behavior. This patch updates 'ci_noatime' feature which was introduced to properly honor noatime option for OST objects, to also support 'relatime'. file_is_noatime() code already comes from upstream touch_atime(). Add missing parts from touch_atime() to also support relatime. It also forces atime to disk on MDD if ondisk atime is older than ondisk mtime/ctime to match relatime (even if relatime is not enabled) WC-bug-id: https://jira.whamcloud.com/browse/LU-15728 Lustre-commit: c10c6eeb37dd55316 ("LU-15728 llite: fix relatime support") Signed-off-by: Aurelien Degremont <[email protected]> Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/47017 Reviewed-by: Shaun Tancheff <[email protected]> Reviewed-by: Oleg Drokin <[email protected]> Reviewed-by: Yang Sheng <[email protected]> Reviewed-by: Andreas Dilger <[email protected]> Signed-off-by: James Simmons <[email protected]> --- fs/lustre/llite/file.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c index 668d544..18f3302 100644 --- a/fs/lustre/llite/file.c +++ b/fs/lustre/llite/file.c @@ -1541,12 +1541,46 @@ void ll_io_set_mirror(struct cl_io *io, const struct file *file) file->f_path.dentry->d_name.name, io->ci_designated_mirror); } +/* + * This is relatime_need_update() from Linux 5.17, which is not exported. + */ +static int relatime_need_update(struct vfsmount *mnt, struct inode *inode, + struct timespec64 now) +{ + if (!(mnt->mnt_flags & MNT_RELATIME)) + return 1; + /* + * Is mtime younger than atime? If yes, update atime: + */ + if (timespec64_compare(&inode->i_mtime, &inode->i_atime) >= 0) + return 1; + /* + * Is ctime younger than atime? If yes, update atime: + */ + if (timespec64_compare(&inode->i_ctime, &inode->i_atime) >= 0) + return 1; + + /* + * Is the previous atime value older than a day? If yes, + * update atime: + */ + if ((long)(now.tv_sec - inode->i_atime.tv_sec) >= 24*60*60) + return 1; + /* + * Good, we can skip the atime update: + */ + return 0; +} + +/* + * Very similar to kernel function: !__atime_needs_update() + */ static bool file_is_noatime(const struct file *file) { - const struct vfsmount *mnt = file->f_path.mnt; - const struct inode *inode = file_inode(file); + struct vfsmount *mnt = file->f_path.mnt; + struct inode *inode = file_inode(file); + struct timespec64 now; - /* Adapted from file_accessed() and touch_atime().*/ if (file->f_flags & O_NOATIME) return true; @@ -1565,6 +1599,11 @@ static bool file_is_noatime(const struct file *file) if ((inode->i_sb->s_flags & SB_NODIRATIME) && S_ISDIR(inode->i_mode)) return true; + now = current_time(inode); + + if (!relatime_need_update(mnt, inode, now)) + return true; + return false; } -- 1.8.3.1 _______________________________________________ lustre-devel mailing list [email protected] http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org