From e2602bd49c1d670b8bf0ad75cdd115941b885575 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Thu, 26 May 2022 14:42:44 +1000 Subject: [PATCH] LU-10391 ptlrpc: change tc_nid in nrs to be struct lnet_nid switch to struct lnet_nid and adjust accordingly. Test-Parameters:trivial testlist=sanityn envdefinitions=ONLY="77" Signed-off-by: Mr NeilBrown Change-Id: Iaa73bc5b95d78f1d69500ea8856ae0d5cd442f8b Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50101 Tested-by: Maloo Tested-by: jenkins Reviewed-by: James Simmons Reviewed-by: Nikitas Angelinas Reviewed-by: Serguei Smirnov Reviewed-by: Oleg Drokin --- lustre/include/lustre_nrs_tbf.h | 2 +- lustre/ptlrpc/nrs_tbf.c | 40 +++++++++++++++++----------------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/lustre/include/lustre_nrs_tbf.h b/lustre/include/lustre_nrs_tbf.h index 7d5c9f9..442bafe 100644 --- a/lustre/include/lustre_nrs_tbf.h +++ b/lustre/include/lustre_nrs_tbf.h @@ -82,7 +82,7 @@ struct nrs_tbf_client { /** Node in the hash table. */ struct hlist_node tc_hnode; /** NID of the client. */ - lnet_nid_t tc_nid; + struct lnet_nid tc_nid; /** Jobid of the client. */ char tc_jobid[LUSTRE_JOBID_SIZE]; /** opcode of the client. */ diff --git a/lustre/ptlrpc/nrs_tbf.c b/lustre/ptlrpc/nrs_tbf.c index a135e84..d44e4ae 100644 --- a/lustre/ptlrpc/nrs_tbf.c +++ b/lustre/ptlrpc/nrs_tbf.c @@ -1051,19 +1051,19 @@ static unsigned nrs_tbf_nid_hop_hash(struct cfs_hash *hs, const void *key, static int nrs_tbf_nid_hop_keycmp(const void *key, struct hlist_node *hnode) { - lnet_nid_t *nid = (lnet_nid_t *)key; + const struct lnet_nid *nid = key; struct nrs_tbf_client *cli = hlist_entry(hnode, - struct nrs_tbf_client, - tc_hnode); + struct nrs_tbf_client, + tc_hnode); - return *nid == cli->tc_nid; + return nid_same(nid, &cli->tc_nid); } static void *nrs_tbf_nid_hop_key(struct hlist_node *hnode) { struct nrs_tbf_client *cli = hlist_entry(hnode, - struct nrs_tbf_client, - tc_hnode); + struct nrs_tbf_client, + tc_hnode); return &cli->tc_nid; } @@ -1071,8 +1071,8 @@ static void *nrs_tbf_nid_hop_key(struct hlist_node *hnode) static void nrs_tbf_nid_hop_get(struct cfs_hash *hs, struct hlist_node *hnode) { struct nrs_tbf_client *cli = hlist_entry(hnode, - struct nrs_tbf_client, - tc_hnode); + struct nrs_tbf_client, + tc_hnode); atomic_inc(&cli->tc_ref); } @@ -1080,8 +1080,8 @@ static void nrs_tbf_nid_hop_get(struct cfs_hash *hs, struct hlist_node *hnode) static void nrs_tbf_nid_hop_put(struct cfs_hash *hs, struct hlist_node *hnode) { struct nrs_tbf_client *cli = hlist_entry(hnode, - struct nrs_tbf_client, - tc_hnode); + struct nrs_tbf_client, + tc_hnode); atomic_dec(&cli->tc_ref); } @@ -1089,12 +1089,12 @@ static void nrs_tbf_nid_hop_put(struct cfs_hash *hs, struct hlist_node *hnode) static void nrs_tbf_nid_hop_exit(struct cfs_hash *hs, struct hlist_node *hnode) { struct nrs_tbf_client *cli = hlist_entry(hnode, - struct nrs_tbf_client, - tc_hnode); + struct nrs_tbf_client, + tc_hnode); LASSERTF(atomic_read(&cli->tc_ref) == 0, "Busy TBF object from client with NID %s, with %d refs\n", - libcfs_nid2str(cli->tc_nid), atomic_read(&cli->tc_ref)); + libcfs_nidstr(&cli->tc_nid), atomic_read(&cli->tc_ref)); nrs_tbf_cli_fini(cli); } @@ -1172,7 +1172,7 @@ static void nrs_tbf_nid_cli_init(struct nrs_tbf_client *cli, struct ptlrpc_request *req) { - cli->tc_nid = lnet_nid_to_nid4(&req->rq_peer.nid); + cli->tc_nid = req->rq_peer.nid; } static int nrs_tbf_nid_rule_init(struct ptlrpc_nrs_policy *policy, @@ -1217,10 +1217,7 @@ static int nrs_tbf_nid_rule_match(struct nrs_tbf_rule *rule, struct nrs_tbf_client *cli) { - struct lnet_nid nid; - - lnet_nid4_to_nid(cli->tc_nid, &nid); - return cfs_match_nid(&nid, &rule->tr_nids); + return cfs_match_nid(&cli->tc_nid, &rule->tr_nids); } static void nrs_tbf_nid_rule_fini(struct nrs_tbf_rule *rule) @@ -1656,7 +1653,7 @@ static inline void nrs_tbf_cli_gen_key(struct nrs_tbf_client *cli, INIT_LIST_HEAD(&cli->tc_lru); strlcpy(cli->tc_key, keystr, sizeof(cli->tc_key)); strlcpy(cli->tc_jobid, jobid, sizeof(cli->tc_jobid)); - cli->tc_nid = lnet_nid_to_nid4(&req->rq_peer.nid); + cli->tc_nid = req->rq_peer.nid; cli->tc_opcode = opc; cli->tc_id = id; } @@ -1984,12 +1981,9 @@ nrs_tbf_expression_match(struct nrs_tbf_expression *expr, struct nrs_tbf_rule *rule, struct nrs_tbf_client *cli) { - struct lnet_nid nid; - switch (expr->te_field) { case NRS_TBF_FIELD_NID: - lnet_nid4_to_nid(cli->tc_nid, &nid); - return cfs_match_nid(&nid, &expr->te_cond); + return cfs_match_nid(&cli->tc_nid, &expr->te_cond); case NRS_TBF_FIELD_JOBID: return nrs_tbf_jobid_list_match(&expr->te_cond, cli->tc_jobid); case NRS_TBF_FIELD_OPCODE: -- 1.8.3.1