From 8759d2c96904c600acb759c9736f9a0ff35f6c53 Mon Sep 17 00:00:00 2001 From: Lei Feng Date: Mon, 6 Nov 2023 14:40:13 +0800 Subject: [PATCH] EX-4125 lipe: adjust atime in lpcc_purge Some time atime < mtime. In this case, adjust atime with mtime. Signed-off-by: Lei Feng Test-Parameters: trivial testlist=sanity-pcc env=ONLY="200-203" Change-Id: I35b3da543b57265b09ef65f4e810761aa727f483 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53002 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lipe/src/lpcc_purge.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lipe/src/lpcc_purge.c b/lipe/src/lpcc_purge.c index 892bc65..00a38b7 100644 --- a/lipe/src/lpcc_purge.c +++ b/lipe/src/lpcc_purge.c @@ -157,7 +157,8 @@ struct lpcc_purge_candidate *lpcc_purge_candidate_new( candidate->c_fid = fid; candidate->c_size = attr->loa_size; - candidate->c_atime_ms = attr->loa_atime_ms; + candidate->c_atime_ms = (attr->loa_atime_ms > attr->loa_mtime_ms) ? + attr->loa_atime_ms : attr->loa_mtime_ms; strcpy(candidate->c_path, path); return candidate; @@ -993,7 +994,7 @@ static int lpcc_purge_detach_candidate(const char *mnt, { int rc; struct stat statbuf; - uint64_t atime_ms; + uint64_t atime_ms, mtime_ms; /* test log level to save the cost of preparing data */ if (llapi_msg_get_level() >= LLAPI_MSG_DEBUG) { @@ -1035,6 +1036,10 @@ static int lpcc_purge_detach_candidate(const char *mnt, return rc; } atime_ms = statbuf.st_atim.tv_sec * 1000 + statbuf.st_atim.tv_nsec / 1000000; + mtime_ms = statbuf.st_mtim.tv_sec * 1000 + statbuf.st_mtim.tv_nsec / 1000000; + if (atime_ms < mtime_ms) + atime_ms = mtime_ms; + if (candidate->c_atime_ms != atime_ms) { /* skip entirely */ LPCC_PURGE_LOG(LLAPI_MSG_DEBUG, -- 1.8.3.1