Whamcloud - gitweb
LU-19098 hsm: don't print progname twice with lhsmtool 80/59680/2 master
authorAurelien Degremont <adegremont@nvidia.com>
Tue, 28 Jan 2025 14:08:07 +0000 (15:08 +0100)
committerOleg Drokin <green@whamcloud.com>
Mon, 23 Jun 2025 04:35:12 +0000 (04:35 +0000)
Since Lustre 2.11, log message from llapi_error() prefixes
the message with the current program short name. There is no
more a need for lhsmtool_posix log fonctions (CT_xxxx) to also
do the same.

Remove the duplicate prog name and cmd_name.

Test-Parameters: trivial testlist=sanity-hsm
Signed-off-by: Aurelien Degremont <adegremont@nvidia.com>
Change-Id: I4ebdf01cd00d1544678cbad066e2c3a79ecfda38
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59680
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/lhsmtool_posix.c

index ae6e608..7e02586 100644 (file)
@@ -169,7 +169,6 @@ static int arc_fd = -1;
 static int err_major;
 static int err_minor;
 
-static char cmd_name[PATH_MAX];
 static char fs_name[MAX_OBD_NAME + 1];
 static int pid_file_fd = -1;
 
@@ -186,23 +185,23 @@ static inline double ct_now(void)
 
 #define CT_ERROR(_rc, _format, ...)                                    \
        llapi_error(LLAPI_MSG_ERROR, _rc,                               \
-                   "%f %s[%ld]: "_format,                              \
-                   ct_now(), cmd_name, syscall(SYS_gettid), ## __VA_ARGS__)
+                   "%f [%ld]: "_format,                                \
+                   ct_now(), syscall(SYS_gettid), ## __VA_ARGS__)
 
 #define CT_DEBUG(_format, ...)                                         \
        llapi_error(LLAPI_MSG_DEBUG | LLAPI_MSG_NO_ERRNO, 0,            \
-                   "%f %s[%ld]: "_format,                              \
-                   ct_now(), cmd_name, syscall(SYS_gettid), ## __VA_ARGS__)
+                   "%f [%ld]: "_format,                                \
+                   ct_now(), syscall(SYS_gettid), ## __VA_ARGS__)
 
 #define CT_WARN(_format, ...) \
        llapi_error(LLAPI_MSG_WARN | LLAPI_MSG_NO_ERRNO, 0,             \
-                   "%f %s[%ld]: "_format,                              \
-                   ct_now(), cmd_name, syscall(SYS_gettid), ## __VA_ARGS__)
+                   "%f [%ld]: "_format,                                \
+                   ct_now(), syscall(SYS_gettid), ## __VA_ARGS__)
 
 #define CT_TRACE(_format, ...)                                         \
        llapi_error(LLAPI_MSG_INFO | LLAPI_MSG_NO_ERRNO, 0,             \
-                   "%f %s[%ld]: "_format,                              \
-                   ct_now(), cmd_name, syscall(SYS_gettid), ## __VA_ARGS__)
+                   "%f [%ld]: "_format,                                \
+                   ct_now(), syscall(SYS_gettid), ## __VA_ARGS__)
 
 static void usage(const char *name, int rc)
 {
@@ -257,7 +256,7 @@ static void usage(const char *name, int rc)
        "   -u, --update-interval <s> Interval between progress reports sent\n"
        "                             to Coordinator\n"
        "   -v, --verbose             Produce more verbose output\n",
-       cmd_name, cmd_name, cmd_name, cmd_name, cmd_name, cmd_name);
+       name, name, name, name, name, name);
 
        exit(rc);
 }
@@ -410,7 +409,7 @@ repeat:
                        opt.o_event_fifo = optarg;
                        break;
                case 'h':
-                       usage(argv[0], 0);
+                       usage(basename(argv[0]), 0);
                case 'i':
                        opt.o_action = CA_IMPORT;
                        break;
@@ -2446,10 +2445,10 @@ int main(int argc, char **argv)
 {
        int     rc;
 
-       snprintf(cmd_name, sizeof(cmd_name), "%s", basename(argv[0]));
        rc = ct_parseopts(argc, argv);
        if (rc < 0) {
-               CT_WARN("try '%s --help' for more information", cmd_name);
+               CT_WARN("try '%s --help' for more information",
+                       basename(argv[0]));
                return -rc;
        }