Whamcloud - gitweb
LU-16518 ptlrpc: fix clang build errors 59/49859/3
authorTimothy Day <timday@amazon.com>
Sun, 19 Feb 2023 21:21:09 +0000 (21:21 +0000)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 Mar 2023 03:28:38 +0000 (03:28 +0000)
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 <timday@amazon.com>
Change-Id: If994c625199b392198f944f9cd21bbf2142bce69
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49859
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_nrs.h
lustre/include/lustre_nrs_crr.h
lustre/include/lustre_nrs_delay.h
lustre/include/lustre_nrs_orr.h
lustre/include/lustre_nrs_tbf.h
lustre/ptlrpc/nrs_crr.c
lustre/ptlrpc/nrs_delay.c
lustre/ptlrpc/nrs_orr.c
lustre/ptlrpc/nrs_tbf.c
lustre/ptlrpc/sec_config.c
lustre/ptlrpc/sec_lproc.c

index 80f9f6b..fd80e40 100644 (file)
@@ -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
 };
 
 /**
index c4c217b..1ccf0e1 100644 (file)
@@ -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
index 9ffbc51..a44e17f 100644 (file)
@@ -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 */
 
index df3d16a..4aff35f 100644 (file)
 /**
  * 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
index 4bc9abf..7d5c9f9 100644 (file)
@@ -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
index f844c8e..33b61bf 100644 (file)
@@ -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);
 
index e8304a1..33aef12 100644 (file)
@@ -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);
 
index a81609a..e2d1a3c 100644 (file)
@@ -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);
 
index 9754e05..6f1c351 100644 (file)
@@ -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;
index a36452e..ee7e019 100644 (file)
@@ -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)
index fb25a28..c6c0242 100644 (file)
@@ -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)