From 50f28f81b5aa8f8ad1c8585bd7e262910f936e50 Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Sun, 19 Feb 2023 21:21:09 +0000 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. Signed-off-by: Timothy Day Change-Id: If994c625199b392198f944f9cd21bbf2142bce69 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49859 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: jsimmons Reviewed-by: Oleg Drokin --- 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 80f9f6b..fd80e40 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 c4c217b..1ccf0e1 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 9ffbc51..a44e17f 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 df3d16a..4aff35f 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 4bc9abf..7d5c9f9 100644 --- a/lustre/include/lustre_nrs_tbf.h +++ b/lustre/include/lustre_nrs_tbf.h @@ -362,21 +362,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 f844c8e..33b61bf 100644 --- a/lustre/ptlrpc/nrs_crr.c +++ b/lustre/ptlrpc/nrs_crr.c @@ -233,7 +233,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 e8304a1..33aef12 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 a81609a..e2d1a3c 100644 --- a/lustre/ptlrpc/nrs_orr.c +++ b/lustre/ptlrpc/nrs_orr.c @@ -747,7 +747,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 9754e05..6f1c351 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); @@ -3094,13 +3094,9 @@ struct ptlrpc_nrs_request *nrs_tbf_req_get(struct ptlrpc_nrs_policy *policy, ntoken = 1; 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 a36452e..ee7e019 100644 --- a/lustre/ptlrpc/sec_config.c +++ b/lustre/ptlrpc/sec_config.c @@ -688,7 +688,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 fb25a28..c6c0242 100644 --- a/lustre/ptlrpc/sec_lproc.c +++ b/lustre/ptlrpc/sec_lproc.c @@ -352,7 +352,7 @@ EXPORT_SYMBOL(sptlrpc_lprocfs_dir); int sptlrpc_lproc_init(void) { - int rc; + int rc = 0; LASSERT(sptlrpc_debugfs_dir == NULL); @@ -368,7 +368,7 @@ int sptlrpc_lproc_init(void) : -ENOMEM; sptlrpc_lprocfs_dir = NULL; } - return 0; + return rc; } void sptlrpc_lproc_fini(void) -- 1.8.3.1