From patchwork Thu Feb 27 21:11:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410279 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0456B92A for ; Thu, 27 Feb 2020 21:33:58 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E151B24677 for ; Thu, 27 Feb 2020 21:33:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E151B24677 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id E9E3521FA17; Thu, 27 Feb 2020 13:28:45 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 885AA21FC4C for ; Thu, 27 Feb 2020 13:19:17 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 964AB2ACF; Thu, 27 Feb 2020 16:18:15 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 950A746F; Thu, 27 Feb 2020 16:18:15 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:11:04 -0500 Message-Id: <1582838290-17243-197-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 196/622] lustre: sptlrpc: split sptlrpc_process_config() X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" Make sptlrpc_process_config() more than a single line wapper exporting function. Instead migrate the lcfg parsing out of __sptlrpc_process_config() so that we can use this function for both LCFG_PARAM and LCFG_SET_PARAM handling. The first field parsed from struct lustre_cfg *lcfg is the target. This can be "_mgs", file system name, or an obd target i.e fsname-MDT0000. We can move to extracting the file system name out of the target string using server_name2fsname(). WC-bug-id: https://jira.whamcloud.com/browse/LU-10937 Lustre-commit: 0ff7d548eb7b ("LU-10937 sptlrpc: split sptlrpc_process_config()") Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/33760 Reviewed-by: Andreas Dilger Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/lustre_disk.h | 1 + fs/lustre/obdclass/obd_mount.c | 5 ++- fs/lustre/ptlrpc/sec_config.c | 85 +++++++++++++++++++++++++---------------- 3 files changed, 57 insertions(+), 34 deletions(-) diff --git a/fs/lustre/include/lustre_disk.h b/fs/lustre/include/lustre_disk.h index 92618e8..b6b693f 100644 --- a/fs/lustre/include/lustre_disk.h +++ b/fs/lustre/include/lustre_disk.h @@ -145,6 +145,7 @@ struct lustre_sb_info { /****************** prototypes *********************/ /* obd_mount.c */ +int server_name2fsname(const char *svname, char *fsname, const char **endptr); int lustre_start_mgc(struct super_block *sb); int lustre_common_put_super(struct super_block *sb); diff --git a/fs/lustre/obdclass/obd_mount.c b/fs/lustre/obdclass/obd_mount.c index d143112..6c68bc7 100644 --- a/fs/lustre/obdclass/obd_mount.c +++ b/fs/lustre/obdclass/obd_mount.c @@ -597,8 +597,8 @@ int lustre_put_lsi(struct super_block *sb) * * Returns: rc < 0 on error */ -static int server_name2fsname(const char *svname, char *fsname, - const char **endptr) +int server_name2fsname(const char *svname, char *fsname, + const char **endptr) { const char *dash; @@ -618,6 +618,7 @@ static int server_name2fsname(const char *svname, char *fsname, return 0; } +EXPORT_SYMBOL(server_name2fsname); /* Get the index from the obd name. * rc = server type, or diff --git a/fs/lustre/ptlrpc/sec_config.c b/fs/lustre/ptlrpc/sec_config.c index 135ce99..e4b1a075 100644 --- a/fs/lustre/ptlrpc/sec_config.c +++ b/fs/lustre/ptlrpc/sec_config.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -577,14 +578,45 @@ static int sptlrpc_conf_merge_rule(struct sptlrpc_conf *conf, * find one through the target name in the record inside conf_lock; * otherwise means caller already hold conf_lock. */ -static int __sptlrpc_process_config(struct lustre_cfg *lcfg, +static int __sptlrpc_process_config(char *target, const char *fsname, + struct sptlrpc_rule *rule, struct sptlrpc_conf *conf) { - char *target, *param; + int rc; + + if (!conf) { + if (!fsname) + return -ENODEV; + + mutex_lock(&sptlrpc_conf_lock); + conf = sptlrpc_conf_get(fsname, 0); + if (!conf) { + CERROR("can't find conf\n"); + rc = -ENOMEM; + } else { + rc = sptlrpc_conf_merge_rule(conf, target, rule); + } + mutex_unlock(&sptlrpc_conf_lock); + } else { + LASSERT(mutex_is_locked(&sptlrpc_conf_lock)); + rc = sptlrpc_conf_merge_rule(conf, target, rule); + } + + if (!rc) + conf->sc_modified++; + + return rc; +} + +int sptlrpc_process_config(struct lustre_cfg *lcfg) +{ char fsname[MTI_NAME_MAXLEN]; struct sptlrpc_rule rule; + char *target, *param; int rc; + print_lustre_cfg(lcfg); + target = lustre_cfg_string(lcfg, 1); if (!target) { CERROR("missing target name\n"); @@ -597,45 +629,34 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, return -EINVAL; } - CDEBUG(D_SEC, "processing rule: %s.%s\n", target, param); - /* parse rule to make sure the format is correct */ - if (strncmp(param, PARAM_SRPC_FLVR, sizeof(PARAM_SRPC_FLVR) - 1) != 0) { + if (strncmp(param, PARAM_SRPC_FLVR, + sizeof(PARAM_SRPC_FLVR) - 1) != 0) { CERROR("Invalid sptlrpc parameter: %s\n", param); return -EINVAL; } param += sizeof(PARAM_SRPC_FLVR) - 1; - rc = sptlrpc_parse_rule(param, &rule); - if (rc) - return -EINVAL; - - if (!conf) { - target2fsname(target, fsname, sizeof(fsname)); - - mutex_lock(&sptlrpc_conf_lock); - conf = sptlrpc_conf_get(fsname, 0); - if (!conf) { - CERROR("can't find conf\n"); - rc = -ENOMEM; - } else { - rc = sptlrpc_conf_merge_rule(conf, target, &rule); - } - mutex_unlock(&sptlrpc_conf_lock); - } else { - LASSERT(mutex_is_locked(&sptlrpc_conf_lock)); - rc = sptlrpc_conf_merge_rule(conf, target, &rule); - } + CDEBUG(D_SEC, "processing rule: %s.%s\n", target, param); - if (rc == 0) - conf->sc_modified++; + /* + * Three types of targets exist for sptlrpc using conf_param + * 1. '_mgs' which targets mgc srpc settings. Treat it as + * as a special file system name. + * 2. target is a device which can be fsname-MDTXXXX or + * fsname-OSTXXXX. This can be verified by the function + * server_name2fsname. + * 3. If both above conditions are not meet then the target + * is a actual filesystem. + */ + if (server_name2fsname(target, fsname, NULL)) + strlcpy(fsname, target, sizeof(target)); - return rc; -} + rc = sptlrpc_parse_rule(param, &rule); + if (rc) + return rc; -int sptlrpc_process_config(struct lustre_cfg *lcfg) -{ - return __sptlrpc_process_config(lcfg, NULL); + return __sptlrpc_process_config(target, fsname, &rule, NULL); } EXPORT_SYMBOL(sptlrpc_process_config);