Whamcloud - gitweb
LU-12842 utils: llog_print with snapshot name 14/36414/2
authorAndreas Dilger <adilger@whamcloud.com>
Wed, 9 Oct 2019 17:26:24 +0000 (11:26 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 22 Oct 2019 23:57:22 +0000 (23:57 +0000)
The lsnapshot utility creates filesystems named with generated
hexadecimal strings.  In some cases the filesystem name may start
with a number instead of a character, which causes "lctl llog_print"
(via llog_ioctl()) to consider the filesystem name invalid.

Allow filesystem names in llog_ioctl() to start with a digit.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Ib2054d5afbeaa3f661148fff834c29f83f5d98ad
Reviewed-on: https://review.whamcloud.com/36414
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Nathaniel Clark <nclark@whamcloud.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/llog_ioctl.c

index 6c88632..1ee49ad 100644 (file)
@@ -318,12 +318,13 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
        struct llog_logid logid;
        int rc = 0;
        struct llog_handle *handle = NULL;
-       char *logname;
+       char *logname, start;
 
        ENTRY;
 
        logname = data->ioc_inlbuf1;
-       if (logname[0] == '#' || logname[0] == '[') {
+       start = logname[0];
+       if (start == '#' || start == '[') {
                rc = str2logid(&logid, logname, data->ioc_inllen1);
                if (rc)
                        RETURN(rc);
@@ -331,8 +332,8 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
                               LLOG_OPEN_EXISTS);
                if (rc)
                        RETURN(rc);
-       } else if (logname[0] == '$' || isalpha(logname[0])) {
-               if (logname[0] == '$')
+       } else if (start == '$' || isalpha(start) || isdigit(start)) {
+               if (start == '$')
                        logname++;
 
                rc = llog_open(env, ctxt, &handle, NULL, logname,
@@ -340,7 +341,10 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd,
                if (rc)
                        RETURN(rc);
        } else {
-               RETURN(-EINVAL);
+               rc = -EINVAL;
+               CDEBUG(D_INFO, "%s: invalid log name '%s': rc = %d\n",
+                     ctxt->loc_obd->obd_name, logname, rc);
+               RETURN(rc);
        }
 
        rc = llog_init_handle(env, handle, 0, NULL);