Whamcloud - gitweb
EX-4125 lipe: adjust atime in lpcc_purge
authorLei Feng <flei@whamcloud.com>
Mon, 6 Nov 2023 06:40:13 +0000 (14:40 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 9 Nov 2023 08:46:56 +0000 (08:46 +0000)
Some time atime < mtime. In this case, adjust atime with mtime.

Signed-off-by: Lei Feng <flei@whamcloud.com>
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 <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lipe/src/lpcc_purge.c

index 892bc65..00a38b7 100644 (file)
@@ -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,