Whamcloud - gitweb
LU-11803 obd: replace class_uuid with linux kernel version.
[fs/lustre-release.git] / lustre / obdclass / obd_mount.c
index 1e3a2a9..65fe8fa 100644 (file)
@@ -43,6 +43,8 @@
 
 #include <obd.h>
 #include <obd_class.h>
+#include <linux/random.h>
+#include <libcfs/linux/linux-uuid.h>
 #include <linux/version.h>
 #include <lustre_log.h>
 #include <lustre_disk.h>
@@ -222,7 +224,7 @@ int lustre_start_mgc(struct super_block *sb)
        struct obd_device *obd;
        struct obd_export *exp;
        struct obd_uuid *uuid = NULL;
-       class_uuid_t uuidc;
+       uuid_t uuidc;
        lnet_nid_t nid;
        char nidstr[LNET_NIDSTR_SIZE];
        char *mgcname = NULL, *niduuid = NULL, *mgssec = NULL;
@@ -405,8 +407,8 @@ int lustre_start_mgc(struct super_block *sb)
        if (uuid == NULL)
                GOTO(out_free, rc = -ENOMEM);
 
-       ll_generate_random_uuid(uuidc);
-       class_uuid_unparse(uuidc, uuid);
+       generate_random_uuid(uuidc.b);
+       snprintf(uuid->uuid, UUID_SIZE, "%pU", uuidc.b);
 
        /* Start the MGC */
        rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,
@@ -502,11 +504,6 @@ out_free:
        RETURN(rc);
 }
 
-/*
- * Appended to obdname to form "obdname_XXXX".
- */
-#define MGC_IDX_LEN sizeof("_XXXX")
-
 static int lustre_stop_mgc(struct super_block *sb)
 {
        struct lustre_sb_info *lsi = s2lsi(sb);
@@ -552,13 +549,13 @@ static int lustre_stop_mgc(struct super_block *sb)
        }
 
        /*
-        * Save the obdname for cleaning the NID uuids, which are
+        * Save the obdname for cleaning the nid uuids, which are
         * obdname_XX
         */
-       len = strlen(obd->obd_name) + MGC_IDX_LEN;
+       len = strlen(obd->obd_name) + 6;
        OBD_ALLOC(niduuid, len);
        if (niduuid) {
-               strlcpy(niduuid, obd->obd_name, len);
+               strcpy(niduuid, obd->obd_name);
                ptr = niduuid + strlen(niduuid);
        }
 
@@ -566,12 +563,12 @@ static int lustre_stop_mgc(struct super_block *sb)
        if (rc)
                GOTO(out, rc);
 
-       /* Clean the NID uuids */
+       /* Clean the nid uuids */
        if (!niduuid)
                GOTO(out, rc = -ENOMEM);
 
        for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) {
-               snprintf(ptr, MGC_IDX_LEN, "_%x", i);
+               sprintf(ptr, "_%x", i);
                rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID,
                             niduuid, NULL, NULL, NULL);
                if (rc)
@@ -892,12 +889,9 @@ int target_name2index(const char *tgtname, __u32 *idx, const char **endptr)
                return rc | LDD_F_SV_ALL;
        }
 
-       if (idx) {
-               if (!(kstrtoul(dash, 16, &index)))
-                       *idx = index;
-               else
-                       rc = -EINVAL;
-       }
+       index = simple_strtoul(dash, (char **)endptr, 16);
+       if (idx != NULL)
+               *idx = index;
 
        return rc;
 }
@@ -1338,7 +1332,6 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
        while (*s1) {
                int clear = 0;
                int time_min = OBD_RECOVERY_TIME_MIN;
-               unsigned long result;
                char *s3;
 
                /* Skip whitespace and extra commas */
@@ -1359,18 +1352,14 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
                        lmd->lmd_flags |= LMD_FLG_ABORT_RECOV;
                        clear++;
                } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) {
-                       rc = kstrtoul(s1 + 19, 10, &result);
-                       if (rc)
-                               goto invalid;
-                       lmd->lmd_recovery_time_soft = max_t(int, result,
-                                                           time_min);
+                       lmd->lmd_recovery_time_soft =
+                               max_t(int, simple_strtoul(s1 + 19, NULL, 10),
+                                     time_min);
                        clear++;
                } else if (strncmp(s1, "recovery_time_hard=", 19) == 0) {
-                       rc = kstrtoul(s1 + 19, 10, &result);
-                       if (rc)
-                               goto invalid;
-                       lmd->lmd_recovery_time_hard = max_t(int, result,
-                                                           time_min);
+                       lmd->lmd_recovery_time_hard =
+                               max_t(int, simple_strtoul(s1 + 19, NULL, 10),
+                                     time_min);
                        clear++;
                } else if (strncmp(s1, "noir", 4) == 0) {
                        lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */