Whamcloud - gitweb
LU-5620 ptlrpc: Add QoS for opcode in NRS-TBF
[fs/lustre-release.git] / lustre / include / lustre_nrs_tbf.h
index 3d52f78..bac1ccf 100644 (file)
@@ -56,6 +56,8 @@ struct nrs_tbf_client {
        lnet_nid_t                       tc_nid;
        /** Jobid of the client. */
        char                             tc_jobid[LUSTRE_JOBID_SIZE];
+       /** opcode of the client. */
+       __u32                            tc_opcode;
        /** Reference number of the client. */
        atomic_t                         tc_ref;
        /** Lock to protect rule and linkage. */
@@ -111,6 +113,10 @@ struct nrs_tbf_rule {
        struct list_head                 tr_jobids;
        /** Jobid list string of the rule.*/
        char                            *tr_jobids_str;
+       /** Opcode bitmap of the rule. */
+       struct cfs_bitmap               *tr_opcodes;
+       /** Opcode list string of the rule.*/
+       char                            *tr_opcodes_str;
        /** RPC/s limit. */
        __u64                            tr_rpc_rate;
        /** Time to wait for next token. */
@@ -149,9 +155,21 @@ struct nrs_tbf_ops {
 
 #define NRS_TBF_TYPE_JOBID     "jobid"
 #define NRS_TBF_TYPE_NID       "nid"
+#define NRS_TBF_TYPE_OPCODE    "opcode"
 #define NRS_TBF_TYPE_MAX_LEN   20
-#define NRS_TBF_FLAG_JOBID     0x0000001
-#define NRS_TBF_FLAG_NID       0x0000002
+
+enum nrs_tbf_flag {
+       NRS_TBF_FLAG_INVALID    = 0x0000000,
+       NRS_TBF_FLAG_JOBID      = 0x0000001,
+       NRS_TBF_FLAG_NID        = 0x0000002,
+       NRS_TBF_FLAG_OPCODE     = 0x0000004,
+};
+
+struct nrs_tbf_type {
+       const char              *ntt_name;
+       enum nrs_tbf_flag        ntt_flag;
+       struct nrs_tbf_ops      *ntt_ops;
+};
 
 struct nrs_tbf_bucket {
        /**
@@ -226,19 +244,30 @@ struct nrs_tbf_head {
 enum nrs_tbf_cmd_type {
        NRS_CTL_TBF_START_RULE = 0,
        NRS_CTL_TBF_STOP_RULE,
-       NRS_CTL_TBF_CHANGE_RATE,
+       NRS_CTL_TBF_CHANGE_RULE,
 };
 
 struct nrs_tbf_cmd {
-       enum nrs_tbf_cmd_type    tc_cmd;
-       char                    *tc_name;
-       __u64                    tc_rpc_rate;
-       struct list_head         tc_nids;
-       char                    *tc_nids_str;
-       struct list_head         tc_jobids;
-       char                    *tc_jobids_str;
-       __u32                    tc_valid_types;
-       __u32                    tc_rule_flags;
+       enum nrs_tbf_cmd_type                    tc_cmd;
+       char                                    *tc_name;
+       union {
+               struct nrs_tbf_cmd_start {
+                       __u64                    ts_rpc_rate;
+                       struct list_head         ts_nids;
+                       char                    *ts_nids_str;
+                       struct list_head         ts_jobids;
+                       char                    *ts_jobids_str;
+                       struct cfs_bitmap       *ts_opcodes;
+                       char                    *ts_opcodes_str;
+                       __u32                    ts_valid_type;
+                       __u32                    ts_rule_flags;
+                       char                    *ts_next_name;
+               } tc_start;
+               struct nrs_tbf_cmd_change {
+                       __u64                    tc_rpc_rate;
+                       char                    *tc_next_name;
+               } tc_change;
+       } u;
 };
 
 struct nrs_tbf_req {
@@ -264,6 +293,10 @@ enum nrs_ctl_tbf {
         * 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,
 };
 
 /** @} tbf */