Whamcloud - gitweb
LU-9086 gss: handle specific mgc binding 59/25959/10
authorJames Simmons <uja.ornl@yahoo.com>
Sun, 9 Apr 2017 20:27:02 +0000 (16:27 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 23 Apr 2017 03:11:27 +0000 (03:11 +0000)
Recent work has made mgc config log handle more than one MGC
existing on a client node which is the case when more than
one lustre file system is mounted. This broke sptlrpc
handling due to cfg_instance no longer being NULL. Since
this is the case we remove the cfg_instance NULL test in
class_config_llog_handler.

The second problem exposed was due to cfg_obdname changing from
the file system name to the actual mgc abstract client device.
Since target2fsname() was only checking fsname-[MDT|OST]XXXX we
could use this function with the obd_uuid field which has the
format of fsname-[MDT|OST]XXXX_UUID. For the case of obd names
with the format fsname-XXXXXXX those obd device have an obd_uuid
that is just some random long hexadecimal string. To handle the
obd_uuid case use the proper obd_uuid2fsname() function instead
of target2fsname(). Rename target2fsname() to obdname2fsname()
since this what it now does. Add handling the fsname-XXXXXXXX
obd name format to obdname2fsname().

Change-Id: I6c3235b3e2d41ef955b98d30aec76d47346c2369
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/25959
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/obdclass/obd_config.c
lustre/ptlrpc/sec_config.c

index 84f8fb1..4def961 100644 (file)
@@ -1615,7 +1615,7 @@ int class_config_llog_handler(const struct lu_env *env,
                  * moving them to index [1] and [2], and insert MGC's
                  * obdname at index [0].
                  */
-               if (cfg->cfg_instance == NULL &&
+               if (cfg->cfg_instance != NULL &&
                    lcfg->lcfg_command == LCFG_SPTLRPC_CONF) {
                        lustre_cfg_bufs_set(&bufs, 2, bufs.lcfg_buf[1],
                                            bufs.lcfg_buflen[1]);
index 43003b0..5fc4dc4 100644 (file)
@@ -504,26 +504,38 @@ struct sptlrpc_conf {
 static struct mutex sptlrpc_conf_lock;
 static struct list_head sptlrpc_confs;
 
-static inline int is_hex(char c)
-{
-        return ((c >= '0' && c <= '9') ||
-                (c >= 'a' && c <= 'f'));
-}
-
-static void target2fsname(const char *tgt, char *fsname, int buflen)
-{
-        const char     *ptr;
-        int             len;
-
-        ptr = strrchr(tgt, '-');
-        if (ptr) {
-                if ((strncmp(ptr, "-MDT", 4) != 0 &&
-                     strncmp(ptr, "-OST", 4) != 0) ||
-                    !is_hex(ptr[4]) || !is_hex(ptr[5]) ||
-                    !is_hex(ptr[6]) || !is_hex(ptr[7]))
-                        ptr = NULL;
-        }
+/*
+ * The goal of this function is to extract the file system name
+ * from the obd name. This can come in two flavors. One is
+ * fsname-MDTXXXX or fsname-XXXXXXX were X is a hexadecimal
+ * number. In both cases we should be returned fsname. If it is
+ * not a valid obd name it is assumed to be the file system
+ * name itself.
+ */
+static void obdname2fsname(const char *tgt, char *fsname, size_t buflen)
+{
+       const char *ptr;
+       size_t len;
+
+       ptr = strrchr(tgt, '-');
+       if (ptr) {
+               if ((!strncmp(ptr, "-MDT", 4) ||
+                    !strncmp(ptr, "-OST", 4)) &&
+                    (isxdigit(ptr[4]) && isxdigit(ptr[5]) &&
+                     isxdigit(ptr[6]) && isxdigit(ptr[7])))
+                       goto valid_obd_name;
+
+               /* The length of the obdname can vary on different platforms */
+               len = strlen(ptr);
+               while (--len) {
+                       if (!isxdigit(ptr[len])) {
+                               ptr = NULL;
+                               break;
+                       }
+               }
+       }
 
+valid_obd_name:
         /* if we didn't find the pattern, treat the whole string as fsname */
         if (ptr == NULL)
                 len = strlen(tgt);
@@ -684,7 +696,7 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg,
                 RETURN(-EINVAL);
 
         if (conf == NULL) {
-                target2fsname(target, fsname, sizeof(fsname));
+               obdname2fsname(target, fsname, sizeof(fsname));
 
                mutex_lock(&sptlrpc_conf_lock);
                 conf = sptlrpc_conf_get(fsname, 0);
@@ -855,7 +867,7 @@ void sptlrpc_conf_choose_flavor(enum lustre_sec_part from,
         char                     name[MTI_NAME_MAXLEN];
         int                      len, rc = 0;
 
-        target2fsname(target->uuid, name, sizeof(name));
+       obd_uuid2fsname(name, target->uuid, sizeof(name));
 
        mutex_lock(&sptlrpc_conf_lock);
 
@@ -957,7 +969,7 @@ int sptlrpc_conf_target_get_rules(struct obd_device *obd,
                RETURN(-EINVAL);
        }
 
-       target2fsname(obd->obd_uuid.uuid, fsname, sizeof(fsname));
+       obd_uuid2fsname(fsname, obd->obd_uuid.uuid, sizeof(fsname));
 
        mutex_lock(&sptlrpc_conf_lock);
        conf = sptlrpc_conf_get(fsname, 0);