Whamcloud - gitweb
LU-9325 obdclass: make niduuid for lustre_stop_mgc() static 17/33617/8
authorJames Simmons <jsimmons@infradead.org>
Mon, 1 Nov 2021 18:31:24 +0000 (14:31 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 30 Nov 2021 03:46:43 +0000 (03:46 +0000)
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 <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/33617
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdclass/obd_mount.c

index 53b359c..ecfebc5 100644 (file)
@@ -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);