X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Finclude%2Flustre_nrs_tbf.h;h=6e0c736ab8d87999f0bd85e87dbd6ac8426eac7e;hb=cc6ef11d2f972ebc440013bddda87a536a09750c;hp=c02620fe542add60bf00f151a67f5f4f8fcab0bb;hpb=d867368cdfa1138909a64d13ab11ed3c0212a0b2;p=fs%2Flustre-release.git diff --git a/lustre/include/lustre_nrs_tbf.h b/lustre/include/lustre_nrs_tbf.h index c02620f..6e0c736 100644 --- a/lustre/include/lustre_nrs_tbf.h +++ b/lustre/include/lustre_nrs_tbf.h @@ -42,11 +42,16 @@ struct nrs_tbf_head; struct nrs_tbf_cmd; +#define NRS_TBF_MATCH_FULL 0x0000001 +#define NRS_TBF_MATCH_WILDCARD 0x0000002 + struct nrs_tbf_jobid { char *tj_id; + __u32 tj_match_flag; struct list_head tj_linkage; }; +#define NRS_TBF_KEY_LEN (LNET_NIDSTR_SIZE + LUSTRE_JOBID_SIZE + 3 + 2) struct nrs_tbf_client { /** Resource object for policy instance. */ struct ptlrpc_nrs_resource tc_res; @@ -56,9 +61,15 @@ 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; + /** Hash key of the client. */ + char tc_key[NRS_TBF_KEY_LEN]; /** Reference number of the client. */ atomic_t tc_ref; - /** Likage to rule. */ + /** Lock to protect rule and linkage. */ + spinlock_t tc_rule_lock; + /** Linkage to rule. */ struct list_head tc_linkage; /** Pointer to rule. */ struct nrs_tbf_rule *tc_rule; @@ -77,7 +88,7 @@ struct nrs_tbf_client { /** List of queued requests. */ struct list_head tc_list; /** Node in binary heap. */ - cfs_binheap_node_t tc_node; + struct cfs_binheap_node tc_node; /** Whether the client is in heap. */ bool tc_in_heap; /** Sequence of the newest rule. */ @@ -109,12 +120,22 @@ 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; + /** Condition list of the rule.*/ + struct list_head tr_conds; + /** Generic condition string of the rule. */ + char *tr_conds_str; /** RPC/s limit. */ __u64 tr_rpc_rate; /** Time to wait for next token. */ __u64 tr_nsecs; /** Token bucket depth. */ __u64 tr_depth; + /** Lock to protect the list of clients. */ + spinlock_t tr_rule_lock; /** List of client. */ struct list_head tr_cli_list; /** Flags of the rule. */ @@ -145,9 +166,23 @@ 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_GENERIC "generic" #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, + NRS_TBF_FLAG_GENERIC = 0x0000008, +}; + +struct nrs_tbf_type { + const char *ntt_name; + enum nrs_tbf_flag ntt_flag; + struct nrs_tbf_ops *ntt_ops; +}; struct nrs_tbf_bucket { /** @@ -196,11 +231,11 @@ struct nrs_tbf_head { /** * Heap of queues. */ - cfs_binheap_t *th_binheap; + struct cfs_binheap *th_binheap; /** * Hash of clients. */ - cfs_hash_t *th_cli_hash; + struct cfs_hash *th_cli_hash; /** * Type of TBF policy. */ @@ -222,19 +257,57 @@ 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; + struct list_head ts_conds; + char *ts_conds_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; +}; + +enum nrs_tbf_field { + NRS_TBF_FIELD_NID, + NRS_TBF_FIELD_JOBID, + NRS_TBF_FIELD_OPCODE, + NRS_TBF_FIELD_MAX +}; + +struct nrs_tbf_expression { + enum nrs_tbf_field te_field; + struct list_head te_cond; + struct cfs_bitmap *te_opcodes; + struct list_head te_linkage; +}; + +struct nrs_tbf_conjunction { + /** + * link to disjunction. + */ + struct list_head tc_linkage; + /** + * list of logical conjunction + */ + struct list_head tc_expressions; }; struct nrs_tbf_req { @@ -260,6 +333,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 */