diff mbox series

[04/12] lustre: obdclass: make niduuid for lustre_stop_mgc() static

Message ID 1639321683-22909-5-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: backport OpenSFS work Dec 12, 2021 | expand

Commit Message

James Simmons Dec. 12, 2021, 3:07 p.m. UTC
The process to create a proper string for niduuid can be made
simpler and avoid a memory allocation.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9325
Lustre-commit: 85b400b67b0d8d493 ("LU-9325 obdclass: make niduuid for lustre_stop_mgc() static")
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/33617
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>
---
 fs/lustre/obdclass/obd_mount.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/obdclass/obd_mount.c b/fs/lustre/obdclass/obd_mount.c
index 19684fb..58ca72d 100644
--- a/fs/lustre/obdclass/obd_mount.c
+++ b/fs/lustre/obdclass/obd_mount.c
@@ -431,8 +431,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;
 
 	if (!lsi)
 		return -ENOENT;
@@ -467,24 +467,17 @@  static int lustre_stop_mgc(struct super_block *sb)
 			CDEBUG(D_MOUNT, "disconnect failed %d\n", rc);
 	}
 
-	/* Save the obdname for cleaning the nid uuids, which are obdname_XX */
-	len = strlen(obd->obd_name) + 6;
-	niduuid = kzalloc(len, GFP_NOFS);
-	if (niduuid) {
-		strcpy(niduuid, obd->obd_name);
-		ptr = niduuid + strlen(niduuid);
-	}
+	/*
+	 * Cache the obdname for cleaning the nid uuids, which are
+	 * obdname_XX before calling class_manual_cleanup
+	 */
+	strcpy(niduuid, obd->obd_name);
+	ptr = niduuid + strlen(niduuid);
 
 	rc = class_manual_cleanup(obd);
 	if (rc)
 		goto out;
 
-	/* Clean the nid uuids */
-	if (!niduuid) {
-		rc = -ENOMEM;
-		goto out;
-	}
-
 	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,
@@ -494,8 +487,6 @@  static int lustre_stop_mgc(struct super_block *sb)
 			       niduuid, rc);
 	}
 out:
-	kfree(niduuid);
-
 	/* class_import_put will get rid of the additional connections */
 	mutex_unlock(&mgc_start_lock);
 	return rc;