Whamcloud - gitweb
LU-6142 lnet: use list_first_entry() where appropriate. 27/50827/4
authorMr NeilBrown <neilb@suse.de>
Wed, 6 Nov 2019 22:43:52 +0000 (09:43 +1100)
committerOleg Drokin <green@whamcloud.com>
Fri, 9 Jun 2023 05:24:15 +0000 (05:24 +0000)
This patch changes
   list_entry(foo.next, ...)
to
   list_first_entry(&foo, ...)

in cases where 'foo' is a list head, rather than a list member.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Ied04412bf976d8fb219bb3c14c56879d2cf83ae7
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50827
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/selftest/conrpc.c
lnet/selftest/console.c
lnet/selftest/framework.c
lnet/selftest/rpc.c

index d9ce964..130953e 100644 (file)
@@ -115,8 +115,8 @@ lstcon_rpc_prep(struct lstcon_node *nd, int service, unsigned int feats,
        spin_lock(&console_session.ses_rpc_lock);
 
        if (!list_empty(&console_session.ses_rpc_freelist)) {
-               crpc = list_entry(console_session.ses_rpc_freelist.next,
-                                 struct lstcon_rpc, crp_link);
+               crpc = list_first_entry(&console_session.ses_rpc_freelist,
+                                       struct lstcon_rpc, crp_link);
                list_del_init(&crpc->crp_link);
        }
 
@@ -1391,7 +1391,7 @@ lstcon_rpc_cleanup_wait(void)
        spin_unlock(&console_session.ses_rpc_lock);
 
        while (!list_empty(&zlist)) {
-               crpc = list_entry(zlist.next, struct lstcon_rpc, crp_link);
+               crpc = list_first_entry(&zlist, struct lstcon_rpc, crp_link);
 
                list_del(&crpc->crp_link);
                LIBCFS_FREE(crpc, sizeof(*crpc));
index ac26ad2..583536a 100644 (file)
@@ -324,8 +324,8 @@ lstcon_group_move(struct lstcon_group *old, struct lstcon_group *new)
        struct lstcon_ndlink *ndl;
 
        while (!list_empty(&old->grp_ndl_list)) {
-               ndl = list_entry(old->grp_ndl_list.next,
-                                struct lstcon_ndlink, ndl_link);
+               ndl = list_first_entry(&old->grp_ndl_list,
+                                      struct lstcon_ndlink, ndl_link);
                lstcon_group_ndlink_move(old, new, ndl);
        }
 }
@@ -1069,8 +1069,8 @@ lstcon_batch_destroy(struct lstcon_batch *bat)
        list_del(&bat->bat_link);
 
        while (!list_empty(&bat->bat_test_list)) {
-               test = list_entry(bat->bat_test_list.next,
-                                 struct lstcon_test, tes_link);
+               test = list_first_entry(&bat->bat_test_list,
+                                       struct lstcon_test, tes_link);
                LASSERT(list_empty(&test->tes_trans_list));
 
                list_del(&test->tes_link);
@@ -1085,16 +1085,16 @@ lstcon_batch_destroy(struct lstcon_batch *bat)
        LASSERT(list_empty(&bat->bat_trans_list));
 
        while (!list_empty(&bat->bat_cli_list)) {
-               ndl = list_entry(bat->bat_cli_list.next,
-                                struct lstcon_ndlink, ndl_link);
+               ndl = list_first_entry(&bat->bat_cli_list,
+                                      struct lstcon_ndlink, ndl_link);
                list_del_init(&ndl->ndl_link);
 
                lstcon_ndlink_release(ndl);
        }
 
        while (!list_empty(&bat->bat_srv_list)) {
-               ndl = list_entry(bat->bat_srv_list.next,
-                                struct lstcon_ndlink, ndl_link);
+               ndl = list_first_entry(&bat->bat_srv_list,
+                                      struct lstcon_ndlink, ndl_link);
                list_del_init(&ndl->ndl_link);
 
                lstcon_ndlink_release(ndl);
@@ -1787,16 +1787,16 @@ int lstcon_session_end(void)
 
        /* destroy all batches */
        while (!list_empty(&console_session.ses_bat_list)) {
-               bat = list_entry(console_session.ses_bat_list.next,
-                                struct lstcon_batch, bat_link);
+               bat = list_first_entry(&console_session.ses_bat_list,
+                                      struct lstcon_batch, bat_link);
 
                lstcon_batch_destroy(bat);
        }
 
        /* destroy all groups */
        while (!list_empty(&console_session.ses_grp_list)) {
-               grp = list_entry(console_session.ses_grp_list.next,
-                                struct lstcon_group, grp_link);
+               grp = list_first_entry(&console_session.ses_grp_list,
+                                      struct lstcon_group, grp_link);
                LASSERT(grp->grp_ref == 1);
 
                lstcon_group_decref(grp);
index 919cd05..d48ab64 100644 (file)
@@ -644,15 +644,15 @@ sfw_destroy_test_instance(struct sfw_test_instance *tsi)
        LASSERT(!sfw_test_active(tsi));
 
        while (!list_empty(&tsi->tsi_units)) {
-               tsu = list_entry(tsi->tsi_units.next,
-                                struct sfw_test_unit, tsu_list);
+               tsu = list_first_entry(&tsi->tsi_units,
+                                      struct sfw_test_unit, tsu_list);
                list_del(&tsu->tsu_list);
                LIBCFS_FREE(tsu, sizeof(*tsu));
        }
 
        while (!list_empty(&tsi->tsi_free_rpcs)) {
-               rpc = list_entry(tsi->tsi_free_rpcs.next,
-                                struct srpc_client_rpc, crpc_list);
+               rpc = list_first_entry(&tsi->tsi_free_rpcs,
+                                      struct srpc_client_rpc, crpc_list);
                list_del(&rpc->crpc_list);
                swi_cancel_workitem(&rpc->crpc_wi);
                LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc));
@@ -672,8 +672,8 @@ sfw_destroy_batch(struct sfw_batch *tsb)
        LASSERT(list_empty(&tsb->bat_list));
 
        while (!list_empty(&tsb->bat_tests)) {
-               tsi = list_entry(tsb->bat_tests.next,
-                                struct sfw_test_instance, tsi_list);
+               tsi = list_first_entry(&tsb->bat_tests,
+                                      struct sfw_test_instance, tsi_list);
                list_del_init(&tsi->tsi_list);
                sfw_destroy_test_instance(tsi);
        }
@@ -690,8 +690,8 @@ sfw_destroy_session(struct sfw_session *sn)
        LASSERT(sn != sfw_data.fw_session);
 
        while (!list_empty(&sn->sn_batches)) {
-               batch = list_entry(sn->sn_batches.next,
-                                  struct sfw_batch, bat_list);
+               batch = list_first_entry(&sn->sn_batches,
+                                        struct sfw_batch, bat_list);
                list_del_init(&batch->bat_list);
                sfw_destroy_batch(batch);
        }
@@ -930,8 +930,8 @@ sfw_create_test_rpc(struct sfw_test_unit *tsu, struct lnet_process_id peer,
 
        if (!list_empty(&tsi->tsi_free_rpcs)) {
                /* pick request from buffer */
-               rpc = list_entry(tsi->tsi_free_rpcs.next,
-                                struct srpc_client_rpc, crpc_list);
+               rpc = list_first_entry(&tsi->tsi_free_rpcs,
+                                      struct srpc_client_rpc, crpc_list);
                LASSERT(nblk == rpc->crpc_bulk.bk_niov);
                list_del_init(&rpc->crpc_list);
        }
@@ -1418,8 +1418,8 @@ sfw_create_rpc(struct lnet_process_id peer, int service,
         LASSERT (service <= SRPC_FRAMEWORK_SERVICE_MAX_ID);
 
        if (nbulkiov == 0 && !list_empty(&sfw_data.fw_zombie_rpcs)) {
-               rpc = list_entry(sfw_data.fw_zombie_rpcs.next,
-                                    struct srpc_client_rpc, crpc_list);
+               rpc = list_first_entry(&sfw_data.fw_zombie_rpcs,
+                                      struct srpc_client_rpc, crpc_list);
                list_del(&rpc->crpc_list);
        }
        spin_unlock(&sfw_data.fw_lock);
@@ -1763,8 +1763,8 @@ sfw_shutdown (void)
        while (!list_empty(&sfw_data.fw_zombie_rpcs)) {
                struct srpc_client_rpc *rpc;
 
-               rpc = list_entry(sfw_data.fw_zombie_rpcs.next,
-                                struct srpc_client_rpc, crpc_list);
+               rpc = list_first_entry(&sfw_data.fw_zombie_rpcs,
+                                      struct srpc_client_rpc, crpc_list);
                list_del(&rpc->crpc_list);
 
                LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc));
@@ -1779,8 +1779,8 @@ sfw_shutdown (void)
         }
 
        while (!list_empty(&sfw_data.fw_tests)) {
-               tsc = list_entry(sfw_data.fw_tests.next,
-                                struct sfw_test_case, tsc_list);
+               tsc = list_first_entry(&sfw_data.fw_tests,
+                                      struct sfw_test_case, tsc_list);
 
                srpc_wait_service_shutdown(tsc->tsc_srv_service);
 
index 4326c7b..2b2def8 100644 (file)
@@ -240,9 +240,9 @@ srpc_service_fini(struct srpc_service *svc)
                LASSERT(list_empty(&scd->scd_rpc_active));
 
                while (!list_empty(&scd->scd_rpc_free)) {
-                       rpc = list_entry(scd->scd_rpc_free.next,
-                                        struct srpc_server_rpc,
-                                        srpc_list);
+                       rpc = list_first_entry(&scd->scd_rpc_free,
+                                              struct srpc_server_rpc,
+                                              srpc_list);
                        list_del(&rpc->srpc_list);
                        LIBCFS_FREE(rpc, sizeof(*rpc));
                }
@@ -694,8 +694,8 @@ srpc_finish_service(struct srpc_service *sv)
                        continue;
                }
 
-               rpc = list_entry(scd->scd_rpc_active.next,
-                                struct srpc_server_rpc, srpc_list);
+               rpc = list_first_entry(&scd->scd_rpc_active,
+                                      struct srpc_server_rpc, srpc_list);
                CNETERR("Active RPC %p on shutdown: sv %s, peer %s, wi %s, ev fired %d type %d status %d lnet %d\n",
                        rpc, sv->sv_name, libcfs_id2str(rpc->srpc_peer),
                        swi_state2str(rpc->srpc_wi.swi_state),
@@ -957,8 +957,8 @@ srpc_server_rpc_done(struct srpc_server_rpc *rpc, int status)
        rpc->srpc_wi.swi_state = SWI_STATE_DONE;
 
        if (!sv->sv_shuttingdown && !list_empty(&scd->scd_buf_blocked)) {
-               buffer = list_entry(scd->scd_buf_blocked.next,
-                                   struct srpc_buffer, buf_list);
+               buffer = list_first_entry(&scd->scd_buf_blocked,
+                                         struct srpc_buffer, buf_list);
                list_del(&buffer->buf_list);
 
                srpc_init_server_rpc(rpc, scd, buffer);
@@ -1552,9 +1552,9 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
                }
 
                if (!list_empty(&scd->scd_rpc_free)) {
-                       srpc = list_entry(scd->scd_rpc_free.next,
-                                         struct srpc_server_rpc,
-                                         srpc_list);
+                       srpc = list_first_entry(&scd->scd_rpc_free,
+                                               struct srpc_server_rpc,
+                                               srpc_list);
                        list_del(&srpc->srpc_list);
 
                        srpc_init_server_rpc(srpc, scd, buffer);