Whamcloud - gitweb
LU-6142 obdclass: Fix style issues for llog_ioctl.c
[fs/lustre-release.git] / lustre / ptlrpc / sec_config.c
index 43003b0..b661ff8 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2016, Intel Corporation.
+ * Copyright (c) 2011, 2017, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -44,7 +44,7 @@
 #include <lustre_log.h>
 #include <lustre_disk.h>
 #include <lustre_dlm.h>
-#include <lustre_param.h>
+#include <uapi/linux/lustre/lustre_param.h>
 #include <lustre_sec.h>
 
 #include "ptlrpc_internal.h"
@@ -504,37 +504,6 @@ 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;
-        }
-
-        /* if we didn't find the pattern, treat the whole string as fsname */
-        if (ptr == NULL)
-                len = strlen(tgt);
-        else
-                len = ptr - tgt;
-
-        len = min(len, buflen - 1);
-        memcpy(fsname, tgt, len);
-        fsname[len] = '\0';
-}
-
 static void sptlrpc_conf_free_rsets(struct sptlrpc_conf *conf)
 {
        struct sptlrpc_conf_tgt *conf_tgt, *conf_tgt_next;
@@ -656,7 +625,9 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg,
         char                    fsname[MTI_NAME_MAXLEN];
         struct sptlrpc_rule     rule;
         int                     rc;
-        ENTRY;
+
+       ENTRY;
+       print_lustre_cfg(lcfg);
 
         target = lustre_cfg_string(lcfg, 1);
         if (target == NULL) {
@@ -684,7 +655,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 +826,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 +928,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);