Whamcloud - gitweb
EX-3041 lipe: include reserved space into disk usage
authorLei Feng <flei@whamcloud.com>
Tue, 20 Apr 2021 00:08:59 +0000 (08:08 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 22 Jul 2021 17:38:35 +0000 (17:38 +0000)
Typically ext4 fs reserves 5% disk space for root. It's
calculated as used space when df command shows the Use%.
So we calculate the usage in lpcc_purge in the same way
to be consistent with df.

Change-Id: I1cdee6ea66ad27bf7501cecb4a4a9495e09647a6
Signed-off-by: Lei Feng <flei@whamcloud.com>
Test-Parameters: trivial
Reviewed-on: https://review.whamcloud.com/43376
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lipe/src/lpcc_purge.c

index cb690af..e3946fe 100644 (file)
@@ -229,6 +229,7 @@ static void lpcc_purge_usr1_handler(int sig)
        if (stats.s_start_time != 0) {
                ctime_r(&stats.s_start_time, buff);
                json_object_object_add(j_stats, "start_time", json_object_new_string(buff));
+               json_object_object_add(j_stats, "start_usage", json_object_new_double(stats.s_start_usage));
        }
        if (stats.s_end_time != 0) {
                ctime_r(&stats.s_end_time, buff);
@@ -694,7 +695,7 @@ static double lpcc_purge_get_fs_usage(const char *fs)
                exit(1);
        }
 
-       usage = 100.0 * (statfs_buf.f_blocks - statfs_buf.f_bfree) / statfs_buf.f_blocks;
+       usage = 100.0 * (statfs_buf.f_blocks - statfs_buf.f_bavail) / statfs_buf.f_blocks;
        i_usage = 100.0 * (statfs_buf.f_files - statfs_buf.f_ffree) / statfs_buf.f_files;
 
        return (usage > i_usage) ? usage : i_usage;
@@ -914,6 +915,8 @@ static void lpcc_purge_scan(void)
        policy.lp_attr_bits = LIPE_OBJECT_ATTR_ATTR;
        memset(&result, 0x00, sizeof(result));
 
+       llapi_printf(LLAPI_MSG_DEBUG, "start scanning...\n");
+
        rc = lipe_scan(instance, &policy, &result, NULL,
                        NULL, opt.o_scan_threads, "lpcc_purge",
                        NULL, true, false, &ldd_err);