#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>
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;
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,
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);
}
/*
- * 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);
}
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)
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;
}
while (*s1) {
int clear = 0;
int time_min = OBD_RECOVERY_TIME_MIN;
- unsigned long result;
char *s3;
/* Skip whitespace and extra commas */
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. */