Commit a94dae86 authored by Danil Kipnis's avatar Danil Kipnis Committed by Jason Gunthorpe

RDMA/rtrs: Get rid of the do_next_path while_next_path macros

The macros do_each_path/while_each_path lead to a smatch warning:

drivers/infiniband/ulp/rtrs/rtrs-clt.c:1196 rtrs_clt_failover_req() warn: inconsistent indenting
drivers/infiniband/ulp/rtrs/rtrs-clt.c:2890 rtrs_clt_request() warn: inconsistent indenting

Also checkpatch complains:
ERROR: Macros with multiple statements should be enclosed in a do - while loop

The macros are used only in two places: for a normal IO path and for the
failover path triggered after errors.

Get rid of the macros and just use a for loop iterating over the list of
paths in both places. It is easier to read and also less lines of code.

Fixes: 6a98d71d ("RDMA/rtrs: client: main functionality")
Link: https://lore.kernel.org/r/20200522053924.528980-1-danil.kipnis@cloud.ionos.comReported-by: default avatarkbuild test robot <lkp@intel.com>
Signed-off-by: default avatarDanil Kipnis <danil.kipnis@cloud.ionos.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent e172037b
......@@ -726,18 +726,6 @@ struct path_it {
struct rtrs_clt_sess *(*next_path)(struct path_it *it);
};
#define do_each_path(path, clt, it) { \
path_it_init(it, clt); \
rcu_read_lock(); \
for ((it)->i = 0; ((path) = ((it)->next_path)(it)) && \
(it)->i < (it)->clt->paths_num; \
(it)->i++)
#define while_each_path(it) \
path_it_deinit(it); \
rcu_read_unlock(); \
}
/**
* list_next_or_null_rr_rcu - get next list element in round-robin fashion.
* @head: the head for the list.
......@@ -1175,7 +1163,10 @@ static int rtrs_clt_failover_req(struct rtrs_clt *clt,
int err = -ECONNABORTED;
struct path_it it;
do_each_path(alive_sess, clt, &it) {
rcu_read_lock();
for (path_it_init(&it, clt);
(alive_sess = it.next_path(&it)) && it.i < it.clt->paths_num;
it.i++) {
if (unlikely(READ_ONCE(alive_sess->state) !=
RTRS_CLT_CONNECTED))
continue;
......@@ -1191,7 +1182,9 @@ static int rtrs_clt_failover_req(struct rtrs_clt *clt,
/* Success path */
rtrs_clt_inc_failover_cnt(alive_sess->stats);
break;
} while_each_path(&it);
}
path_it_deinit(&it);
rcu_read_unlock();
return err;
}
......@@ -2862,7 +2855,9 @@ int rtrs_clt_request(int dir, struct rtrs_clt_req_ops *ops,
dma_dir = DMA_TO_DEVICE;
}
do_each_path(sess, clt, &it) {
rcu_read_lock();
for (path_it_init(&it, clt);
(sess = it.next_path(&it)) && it.i < it.clt->paths_num; it.i++) {
if (unlikely(READ_ONCE(sess->state) != RTRS_CLT_CONNECTED))
continue;
......@@ -2887,7 +2882,9 @@ int rtrs_clt_request(int dir, struct rtrs_clt_req_ops *ops,
}
/* Success path */
break;
} while_each_path(&it);
}
path_it_deinit(&it);
rcu_read_unlock();
return err;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment