Whamcloud - gitweb
EX-9280 lipe: lpurge: Add periodical stats on scanned files
authorAlexandre Ioffe <aioffe@ddn.com>
Sat, 9 Mar 2024 00:32:04 +0000 (16:32 -0800)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 16 Mar 2024 08:17:59 +0000 (08:17 +0000)
- Report INFO message on each lpurge period.
- Include in the message number of purged files, number of files
for which mirror deleting failed, number of files
which are not purged due to a stale component.
- Reset the periodic counter every period.

Test-Parameters: trivial testlist=hot-pools
Signed-off-by: Alexandre Ioffe <aioffe@ddn.com>
Change-Id: Ib70604c990801b79b0a0356991d45e83ec62db6c
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54337
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Vitaliy Kuznetsov <vkuznetsov@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lipe/src/lpurge.c

index 86bcc6b..581d65f 100644 (file)
@@ -106,18 +106,22 @@ struct lpurge_slot {
 #define LPURGE_HIST_MAX        16
 static struct lpurge_slot lpurge_hist[LPURGE_HIST_MAX];
 
-struct stats {
+static struct stats {
        unsigned long long s_scan_time;
        unsigned long s_scans;
        unsigned long s_fast_scans;
        unsigned long s_slow_scans;
-       unsigned long s_queued; /* # files queued for purge */
-       unsigned long s_started; /* # files dequeued for purge by worker */
-       unsigned long s_purged; /* # files we successfully purged */
-       unsigned long s_failed; /* # files we failed to purge */
-       /* TODO count mirrors we tried to purge but found last non stale */
-};
-static struct stats stats;
+       unsigned long s_queued;         /* # files queued for purge */
+       unsigned long s_started;        /* # files dequeued for purge by worker */
+       unsigned long s_purged;         /* # files successfully purged */
+       unsigned long s_purged1;        /* # files successfully purged in one period */
+       unsigned long s_purged1_kb;     /* purged KB in one period*/
+       unsigned long s_failed;         /* # files failed to purge */
+       unsigned long s_failed1;        /* # files failed to purge in one period */
+       unsigned long s_failed1_kb;     /* total not purged KB */
+       unsigned long s_stale_mirror1;  /* # stale mirror not purged in one period */
+       unsigned long s_stale_mirror1_kb; /* # stale mirror KB not purged in one period */
+} stats;
 
 #define DEF_MIN_USED 10 /* 100 - DEF_FREEHI */
 #define DEF_MAX_USED 25 /* 100 - DEF_FREELO */
@@ -1040,14 +1044,24 @@ static void *lpurge_work_func(void *data)
                pthread_mutex_unlock(&lpurge_work_lock);
 
                rc = lpurge_mirror_delete(&lo->lo_fid, lo->lo_mirror_id);
-               free(lo);
 
                pthread_mutex_lock(&lpurge_work_lock);
 
-               if (rc < 0)
+               if (rc < 0) {
                        stats.s_failed++;
-               else
+                       stats.s_failed1++;
+                       stats.s_failed1_kb += lo->lo_used_kb;
+                       if (rc == -EUCLEAN) {
+                               stats.s_stale_mirror1++;
+                               stats.s_stale_mirror1_kb += lo->lo_used_kb;
+                       }
+               } else {
                        stats.s_purged++;
+                       stats.s_purged1++;
+                       stats.s_purged1_kb += lo->lo_used_kb;
+               }
+
+               free(lo);
 
                assert(stats.s_purged + stats.s_failed <= stats.s_queued);
 
@@ -1284,6 +1298,17 @@ static void lpurge_purge(void)
                lpurge_purge_slot(ls, used_kb - lpurge_min_used_kb);
        }
 
+       LX_INFO("purged: %lu (%lu KB) failed: %lu (%lu KB) stale: %lu (%lu KB)\n",
+               stats.s_purged1, stats.s_purged1_kb,
+               stats.s_failed1, stats.s_failed1_kb,
+               stats.s_stale_mirror1, stats.s_stale_mirror1_kb);
+       stats.s_purged1 = 0;
+       stats.s_purged1_kb = 0;
+       stats.s_failed1 = 0;
+       stats.s_failed1_kb = 0;
+       stats.s_stale_mirror1 = 0;
+       stats.s_stale_mirror1_kb = 0;
+
        rc = lpurge_get_used_kb(&used_kb);
        if (!rc)
                LX_INFO("used_kb = %llu\n", used_kb);