From f9842343b8c5eab435cc4a431ca7c1fe6098a839 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Wed, 21 Feb 2024 13:14:17 -0800 Subject: [PATCH] LU-16518 ptlrpc: fix clang build errors Fixed bugs which cause errors on Clang. The majority of changes involve adding defines for the 'ptlrpc_nrs_ctl' enum. This avoids having to explicitly cast enums from one type to another. An unused variable 'req' was removed from 'nrs_tbf_req_get'. A 'strlcpy' in 'sptlrpc_process_config' was copying the wrong number of bytes. Another variable, 'rc' in 'sptlrpc_lproc_init', seemed to be neglected unintentionally; this was also fixed. Lustre-change: https://review.whamcloud.com/49859 Lustre-commit: 50f28f81b5aa8f8ad1c8585bd7e262910f936e50 Signed-off-by: Timothy Day Change-Id: If994c625199b392198f944f9cd21bbf2142bce69 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54131 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/include/lustre_nrs.h | 11 ++++++++++- lustre/include/lustre_nrs_crr.h | 17 +++++++---------- lustre/include/lustre_nrs_delay.h | 14 ++++++-------- lustre/include/lustre_nrs_orr.h | 14 ++++++-------- lustre/include/lustre_nrs_tbf.h | 25 +++++++++++-------------- lustre/ptlrpc/nrs_crr.c | 2 +- lustre/ptlrpc/nrs_delay.c | 2 +- lustre/ptlrpc/nrs_orr.c | 2 +- lustre/ptlrpc/nrs_tbf.c | 10 +++------- lustre/ptlrpc/sec_config.c | 2 +- lustre/ptlrpc/sec_lproc.c | 4 ++-- 11 files changed, 49 insertions(+), 54 deletions(-) diff --git a/lustre/include/lustre_nrs.h b/lustre/include/lustre_nrs.h index bafbc7e..32a548f 100644 --- a/lustre/include/lustre_nrs.h +++ b/lustre/include/lustre_nrs.h @@ -63,7 +63,16 @@ enum ptlrpc_nrs_ctl { * Policies can start using opcodes from this value and onwards for * their own purposes; the assigned value itself is arbitrary. */ - PTLRPC_NRS_CTL_1ST_POL_SPEC = 0x20, + PTLRPC_NRS_CTL_POL_SPEC_01 = 0x20, + PTLRPC_NRS_CTL_POL_SPEC_02, + PTLRPC_NRS_CTL_POL_SPEC_03, + PTLRPC_NRS_CTL_POL_SPEC_04, + PTLRPC_NRS_CTL_POL_SPEC_05, + PTLRPC_NRS_CTL_POL_SPEC_06, + PTLRPC_NRS_CTL_POL_SPEC_07, + PTLRPC_NRS_CTL_POL_SPEC_08, + PTLRPC_NRS_CTL_POL_SPEC_09, + PTLRPC_NRS_CTL_POL_SPEC_10 }; /** diff --git a/lustre/include/lustre_nrs_crr.h b/lustre/include/lustre_nrs_crr.h index 06be0ae..fc436e9 100644 --- a/lustre/include/lustre_nrs_crr.h +++ b/lustre/include/lustre_nrs_crr.h @@ -112,17 +112,14 @@ struct nrs_crrn_req { /** * CRR-N policy operations. + * + * Read the RR quantum size of a CRR-N policy. */ -enum nrs_ctl_crr { - /** - * Read the RR quantum size of a CRR-N policy. - */ - NRS_CTL_CRRN_RD_QUANTUM = PTLRPC_NRS_CTL_1ST_POL_SPEC, - /** - * Write the RR quantum size of a CRR-N policy. - */ - NRS_CTL_CRRN_WR_QUANTUM, -}; +#define NRS_CTL_CRRN_RD_QUANTUM PTLRPC_NRS_CTL_POL_SPEC_01 +/** + * Write the RR quantum size of a CRR-N policy. + */ +#define NRS_CTL_CRRN_WR_QUANTUM PTLRPC_NRS_CTL_POL_SPEC_02 /** @} CRR-N */ #endif diff --git a/lustre/include/lustre_nrs_delay.h b/lustre/include/lustre_nrs_delay.h index 01605a7..70e7714 100644 --- a/lustre/include/lustre_nrs_delay.h +++ b/lustre/include/lustre_nrs_delay.h @@ -73,14 +73,12 @@ struct nrs_delay_req { time64_t req_start_time; }; -enum nrs_ctl_delay { - NRS_CTL_DELAY_RD_MIN = PTLRPC_NRS_CTL_1ST_POL_SPEC, - NRS_CTL_DELAY_WR_MIN, - NRS_CTL_DELAY_RD_MAX, - NRS_CTL_DELAY_WR_MAX, - NRS_CTL_DELAY_RD_PCT, - NRS_CTL_DELAY_WR_PCT, -}; +#define NRS_CTL_DELAY_RD_MIN PTLRPC_NRS_CTL_POL_SPEC_01 +#define NRS_CTL_DELAY_WR_MIN PTLRPC_NRS_CTL_POL_SPEC_02 +#define NRS_CTL_DELAY_RD_MAX PTLRPC_NRS_CTL_POL_SPEC_03 +#define NRS_CTL_DELAY_WR_MAX PTLRPC_NRS_CTL_POL_SPEC_04 +#define NRS_CTL_DELAY_RD_PCT PTLRPC_NRS_CTL_POL_SPEC_05 +#define NRS_CTL_DELAY_WR_PCT PTLRPC_NRS_CTL_POL_SPEC_06 /** @} delay */ diff --git a/lustre/include/lustre_nrs_orr.h b/lustre/include/lustre_nrs_orr.h index 609eb25..11aff7e 100644 --- a/lustre/include/lustre_nrs_orr.h +++ b/lustre/include/lustre_nrs_orr.h @@ -36,14 +36,12 @@ /** * ORR policy operations */ -enum nrs_ctl_orr { - NRS_CTL_ORR_RD_QUANTUM = PTLRPC_NRS_CTL_1ST_POL_SPEC, - NRS_CTL_ORR_WR_QUANTUM, - NRS_CTL_ORR_RD_OFF_TYPE, - NRS_CTL_ORR_WR_OFF_TYPE, - NRS_CTL_ORR_RD_SUPP_REQ, - NRS_CTL_ORR_WR_SUPP_REQ, -}; +#define NRS_CTL_ORR_RD_QUANTUM PTLRPC_NRS_CTL_POL_SPEC_01 +#define NRS_CTL_ORR_WR_QUANTUM PTLRPC_NRS_CTL_POL_SPEC_02 +#define NRS_CTL_ORR_RD_OFF_TYPE PTLRPC_NRS_CTL_POL_SPEC_03 +#define NRS_CTL_ORR_WR_OFF_TYPE PTLRPC_NRS_CTL_POL_SPEC_04 +#define NRS_CTL_ORR_RD_SUPP_REQ PTLRPC_NRS_CTL_POL_SPEC_05 +#define NRS_CTL_ORR_WR_SUPP_REQ PTLRPC_NRS_CTL_POL_SPEC_06 /** * \name ORR/TRR diff --git a/lustre/include/lustre_nrs_tbf.h b/lustre/include/lustre_nrs_tbf.h index e4bbf8a..0ad63f1 100644 --- a/lustre/include/lustre_nrs_tbf.h +++ b/lustre/include/lustre_nrs_tbf.h @@ -360,21 +360,18 @@ struct nrs_tbf_req { /** * TBF policy operations. + * + * Read the the data of a TBF policy. */ -enum nrs_ctl_tbf { - /** - * Read the the data of a TBF policy. - */ - NRS_CTL_TBF_RD_RULE = PTLRPC_NRS_CTL_1ST_POL_SPEC, - /** - * Write the the data of a TBF policy. - */ - NRS_CTL_TBF_WR_RULE, - /** - * Read the TBF policy type preset by proc entry "nrs_policies". - */ - NRS_CTL_TBF_RD_TYPE_FLAG, -}; +#define NRS_CTL_TBF_RD_RULE PTLRPC_NRS_CTL_POL_SPEC_01 +/** + * Write the the data of a TBF policy. + */ +#define NRS_CTL_TBF_WR_RULE PTLRPC_NRS_CTL_POL_SPEC_02 +/** + * Read the TBF policy type preset by proc entry "nrs_policies". + */ +#define NRS_CTL_TBF_RD_TYPE_FLAG PTLRPC_NRS_CTL_POL_SPEC_03 /** @} tbf */ #endif diff --git a/lustre/ptlrpc/nrs_crr.c b/lustre/ptlrpc/nrs_crr.c index 41d0cb6..625e679 100644 --- a/lustre/ptlrpc/nrs_crr.c +++ b/lustre/ptlrpc/nrs_crr.c @@ -234,7 +234,7 @@ static int nrs_crrn_ctl(struct ptlrpc_nrs_policy *policy, { assert_spin_locked(&policy->pol_nrs->nrs_lock); - switch((enum nrs_ctl_crr)opc) { + switch (opc) { default: RETURN(-EINVAL); diff --git a/lustre/ptlrpc/nrs_delay.c b/lustre/ptlrpc/nrs_delay.c index c6174f8..5d80065 100644 --- a/lustre/ptlrpc/nrs_delay.c +++ b/lustre/ptlrpc/nrs_delay.c @@ -323,7 +323,7 @@ static int nrs_delay_ctl(struct ptlrpc_nrs_policy *policy, assert_spin_locked(&policy->pol_nrs->nrs_lock); - switch ((enum nrs_ctl_delay)opc) { + switch (opc) { default: RETURN(-EINVAL); diff --git a/lustre/ptlrpc/nrs_orr.c b/lustre/ptlrpc/nrs_orr.c index 6d3ab7e..cd2e650 100644 --- a/lustre/ptlrpc/nrs_orr.c +++ b/lustre/ptlrpc/nrs_orr.c @@ -748,7 +748,7 @@ static int nrs_orr_ctl(struct ptlrpc_nrs_policy *policy, { assert_spin_locked(&policy->pol_nrs->nrs_lock); - switch((enum nrs_ctl_orr)opc) { + switch (opc) { default: RETURN(-EINVAL); diff --git a/lustre/ptlrpc/nrs_tbf.c b/lustre/ptlrpc/nrs_tbf.c index 6bdf48f..3873c53 100644 --- a/lustre/ptlrpc/nrs_tbf.c +++ b/lustre/ptlrpc/nrs_tbf.c @@ -2870,7 +2870,7 @@ static int nrs_tbf_ctl(struct ptlrpc_nrs_policy *policy, assert_spin_locked(&policy->pol_nrs->nrs_lock); - switch ((enum nrs_ctl_tbf)opc) { + switch (opc) { default: RETURN(-EINVAL); @@ -3091,13 +3091,9 @@ struct ptlrpc_nrs_request *nrs_tbf_req_get(struct ptlrpc_nrs_policy *policy, ntoken = cli->tc_depth; if (ntoken > 0) { - struct ptlrpc_request *req; nrq = list_entry(cli->tc_list.next, - struct ptlrpc_nrs_request, - nr_u.tbf.tr_list); - req = container_of(nrq, - struct ptlrpc_request, - rq_nrq); + struct ptlrpc_nrs_request, + nr_u.tbf.tr_list); ntoken--; cli->tc_ntoken = ntoken; cli->tc_check_time = now; diff --git a/lustre/ptlrpc/sec_config.c b/lustre/ptlrpc/sec_config.c index 8f592a3..d8469d3 100644 --- a/lustre/ptlrpc/sec_config.c +++ b/lustre/ptlrpc/sec_config.c @@ -693,7 +693,7 @@ int sptlrpc_process_config(struct lustre_cfg *lcfg) * is a actual filesystem. */ if (server_name2fsname(target, fsname, NULL)) - strlcpy(fsname, target, sizeof(target)); + strlcpy(fsname, target, sizeof(fsname)); rc = sptlrpc_parse_rule(param, &rule); if (rc) diff --git a/lustre/ptlrpc/sec_lproc.c b/lustre/ptlrpc/sec_lproc.c index 6b7d652..97d162a 100644 --- a/lustre/ptlrpc/sec_lproc.c +++ b/lustre/ptlrpc/sec_lproc.c @@ -357,7 +357,7 @@ EXPORT_SYMBOL(sptlrpc_lprocfs_dir); int sptlrpc_lproc_init(void) { - int rc; + int rc = 0; LASSERT(sptlrpc_debugfs_dir == NULL); @@ -373,7 +373,7 @@ int sptlrpc_lproc_init(void) : -ENOMEM; sptlrpc_lprocfs_dir = NULL; } - return 0; + return rc; } void sptlrpc_lproc_fini(void) -- 1.8.3.1