From 7eb7f852ba4cb642ef0d45842a0dc8cbd6f2024d Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 19 Mar 2019 14:12:53 -0400 Subject: [PATCH] LU-9859 libcfs: remove wi_data from cfs_workitem In every case, the value passed via wi_data can be determined from the cfs_workitem pointer using container_of(). So use container_of(), and discard wi_data. Linux-commit: 19ae89d32503493315dec77919815d3add851389 Change-Id: Iefc4b6ebf40b48bd60a5820de05eb44746a041c0 Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman Reviewed-on: https://review.whamcloud.com/34466 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Jian Yu --- libcfs/include/libcfs/libcfs_workitem.h | 5 +---- lnet/selftest/framework.c | 8 +++----- lnet/selftest/rpc.c | 14 +++++++------- lnet/selftest/selftest.h | 6 +++--- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_workitem.h b/libcfs/include/libcfs/libcfs_workitem.h index 84da4d9..7050472 100644 --- a/libcfs/include/libcfs/libcfs_workitem.h +++ b/libcfs/include/libcfs/libcfs_workitem.h @@ -75,8 +75,6 @@ struct cfs_workitem { struct list_head wi_list; /** working function */ cfs_wi_action_t wi_action; - /** arg for working function */ - void *wi_data; /** in running */ unsigned short wi_running:1; /** scheduled */ @@ -84,13 +82,12 @@ struct cfs_workitem { }; static inline void -cfs_wi_init(struct cfs_workitem *wi, void *data, cfs_wi_action_t action) +cfs_wi_init(struct cfs_workitem *wi, cfs_wi_action_t action) { INIT_LIST_HEAD(&wi->wi_list); wi->wi_running = 0; wi->wi_scheduled = 0; - wi->wi_data = data; wi->wi_action = action; } diff --git a/lnet/selftest/framework.c b/lnet/selftest/framework.c index 000fca9..1ad3c1e 100644 --- a/lnet/selftest/framework.c +++ b/lnet/selftest/framework.c @@ -957,7 +957,7 @@ sfw_create_test_rpc(struct sfw_test_unit *tsu, struct lnet_process_id peer, static int sfw_run_test(struct swi_workitem *wi) { - struct sfw_test_unit *tsu = wi->swi_workitem.wi_data; + struct sfw_test_unit *tsu = container_of(wi, struct sfw_test_unit, tsu_worker); struct sfw_test_instance *tsi = tsu->tsu_instance; struct srpc_client_rpc *rpc = NULL; @@ -1029,10 +1029,8 @@ sfw_run_batch(struct sfw_batch *tsb) atomic_inc(&tsi->tsi_nactive); tsu->tsu_loop = tsi->tsi_loop; wi = &tsu->tsu_worker; - swi_init_workitem(wi, tsu, sfw_run_test, - lst_sched_test[\ - lnet_cpt_of_nid(tsu->tsu_dest.nid, - NULL)]); + swi_init_workitem(wi, sfw_run_test, + lst_sched_test[lnet_cpt_of_nid(tsu->tsu_dest.nid, NULL)]); swi_schedule_workitem(wi); } } diff --git a/lnet/selftest/rpc.c b/lnet/selftest/rpc.c index 17e7e60..78362e3 100644 --- a/lnet/selftest/rpc.c +++ b/lnet/selftest/rpc.c @@ -175,7 +175,7 @@ srpc_init_server_rpc(struct srpc_server_rpc *rpc, struct srpc_buffer *buffer) { memset(rpc, 0, sizeof(*rpc)); - swi_init_workitem(&rpc->srpc_wi, rpc, srpc_handle_rpc, + swi_init_workitem(&rpc->srpc_wi, srpc_handle_rpc, srpc_serv_is_framework(scd->scd_svc) ? lst_sched_serial : lst_sched_test[scd->scd_cpt]); @@ -278,7 +278,7 @@ srpc_service_init(struct srpc_service *svc) /* NB: don't use lst_sched_serial for adding buffer, * see details in srpc_service_add_buffers() */ - swi_init_workitem(&scd->scd_buf_wi, scd, + swi_init_workitem(&scd->scd_buf_wi, srpc_add_buffer, lst_sched_test[i]); if (i != 0 && srpc_serv_is_framework(svc)) { @@ -509,9 +509,9 @@ __must_hold(&scd->scd_lock) int srpc_add_buffer(struct swi_workitem *wi) { - struct srpc_service_cd *scd = wi->swi_workitem.wi_data; - struct srpc_buffer *buf; - int rc = 0; + struct srpc_service_cd *scd = container_of(wi, struct srpc_service_cd, scd_buf_wi); + struct srpc_buffer *buf; + int rc = 0; /* it's called by workitem scheduler threads, these threads * should have been set CPT affinity, so buffers will be posted @@ -953,7 +953,7 @@ srpc_server_rpc_done(struct srpc_server_rpc *rpc, int status) /* handles an incoming RPC */ static int srpc_handle_rpc(struct swi_workitem *wi) { - struct srpc_server_rpc *rpc = wi->swi_workitem.wi_data; + struct srpc_server_rpc *rpc = container_of(wi, struct srpc_server_rpc, srpc_wi); struct srpc_service_cd *scd = rpc->srpc_scd; struct srpc_service *sv = scd->scd_svc; struct srpc_event *ev = &rpc->srpc_ev; @@ -1173,7 +1173,7 @@ srpc_send_rpc(struct swi_workitem *wi) LASSERT(wi != NULL); - rpc = wi->swi_workitem.wi_data; + rpc = container_of(wi, struct srpc_client_rpc, crpc_wi); LASSERT (rpc != NULL); LASSERT (wi == &rpc->crpc_wi); diff --git a/lnet/selftest/selftest.h b/lnet/selftest/selftest.h index 3f7c295..ea1ee06 100644 --- a/lnet/selftest/selftest.h +++ b/lnet/selftest/selftest.h @@ -467,13 +467,13 @@ swi_wi_action(struct cfs_workitem *wi) } static inline void -swi_init_workitem(struct swi_workitem *swi, void *data, +swi_init_workitem(struct swi_workitem *swi, swi_action_t action, struct cfs_wi_sched *sched) { swi->swi_sched = sched; swi->swi_action = action; swi->swi_state = SWI_STATE_NEWBORN; - cfs_wi_init(&swi->swi_workitem, data, swi_wi_action); + cfs_wi_init(&swi->swi_workitem, swi_wi_action); } static inline void @@ -527,7 +527,7 @@ srpc_init_client_rpc(struct srpc_client_rpc *rpc, struct lnet_process_id peer, crpc_bulk.bk_iovs[nbulkiov])); INIT_LIST_HEAD(&rpc->crpc_list); - swi_init_workitem(&rpc->crpc_wi, rpc, srpc_send_rpc, + swi_init_workitem(&rpc->crpc_wi, srpc_send_rpc, lst_sched_test[lnet_cpt_of_nid(peer.nid, NULL)]); spin_lock_init(&rpc->crpc_lock); atomic_set(&rpc->crpc_refcount, 1); /* 1 ref for caller */ -- 1.8.3.1