From: James Simmons Date: Mon, 1 Nov 2021 18:31:24 +0000 (-0400) Subject: LU-9325 obdclass: make niduuid for lustre_stop_mgc() static X-Git-Tag: 2.14.56~50 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=85b400b67b0d8d49315f80252025c98303d242bb;p=fs%2Flustre-release.git LU-9325 obdclass: make niduuid for lustre_stop_mgc() static The process to create a proper string for niduuid can be made simpler and avoid a memory allocation. Change-Id: I52cb01117e41cbcf2756477e91934a42d31fd157 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/33617 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 53b359c..ecfebc5 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -502,8 +502,8 @@ static int lustre_stop_mgc(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *obd; - char *niduuid = NULL, *ptr = NULL; - int i, rc = 0, len = 0; + char niduuid[MAX_OBD_NAME + 6], *ptr = NULL; + int i, rc = 0; ENTRY; @@ -543,24 +543,16 @@ static int lustre_stop_mgc(struct super_block *sb) } /* - * Save the obdname for cleaning the nid uuids, which are - * obdname_XX + * Cache the obdname for cleaning the nid uuids, which are + * obdname_XX before calling class_manual_cleanup */ - len = strlen(obd->obd_name) + 6; - OBD_ALLOC(niduuid, len); - if (niduuid) { - strcpy(niduuid, obd->obd_name); - ptr = niduuid + strlen(niduuid); - } + strcpy(niduuid, obd->obd_name); + ptr = niduuid + strlen(niduuid); rc = class_manual_cleanup(obd); if (rc) GOTO(out, rc); - /* Clean the nid uuids */ - if (!niduuid) - GOTO(out, rc = -ENOMEM); - for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) { sprintf(ptr, "_%x", i); rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID, @@ -570,9 +562,6 @@ static int lustre_stop_mgc(struct super_block *sb) niduuid, rc); } out: - if (niduuid) - OBD_FREE(niduuid, len); - /* class_import_put will get rid of the additional connections */ mutex_unlock(&mgc_start_lock); RETURN(rc);