aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lnet/selftest/conrpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/lustre/lnet/selftest/conrpc.c')
-rw-r--r--drivers/staging/lustre/lnet/selftest/conrpc.c344
1 files changed, 172 insertions, 172 deletions
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index 1066c70434b1..bcd78888f9cc 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -54,14 +54,16 @@ lstcon_rpc_done(srpc_client_rpc_t *rpc)
{
lstcon_rpc_t *crpc = (lstcon_rpc_t *)rpc->crpc_priv;
- LASSERT(crpc != NULL && rpc == crpc->crp_rpc);
+ LASSERT(crpc && rpc == crpc->crp_rpc);
LASSERT(crpc->crp_posted && !crpc->crp_finished);
spin_lock(&rpc->crpc_lock);
- if (crpc->crp_trans == NULL) {
- /* Orphan RPC is not in any transaction,
- * I'm just a poor body and nobody loves me */
+ if (!crpc->crp_trans) {
+ /*
+ * Orphan RPC is not in any transaction,
+ * I'm just a poor body and nobody loves me
+ */
spin_unlock(&rpc->crpc_lock);
/* release it */
@@ -72,11 +74,11 @@ lstcon_rpc_done(srpc_client_rpc_t *rpc)
/* not an orphan RPC */
crpc->crp_finished = 1;
- if (crpc->crp_stamp == 0) {
+ if (!crpc->crp_stamp) {
/* not aborted */
- LASSERT(crpc->crp_status == 0);
+ LASSERT(!crpc->crp_status);
- crpc->crp_stamp = cfs_time_current();
+ crpc->crp_stamp = cfs_time_current();
crpc->crp_status = rpc->crpc_status;
}
@@ -94,16 +96,16 @@ lstcon_rpc_init(lstcon_node_t *nd, int service, unsigned feats,
crpc->crp_rpc = sfw_create_rpc(nd->nd_id, service,
feats, bulk_npg, bulk_len,
lstcon_rpc_done, (void *)crpc);
- if (crpc->crp_rpc == NULL)
+ if (!crpc->crp_rpc)
return -ENOMEM;
- crpc->crp_trans = NULL;
- crpc->crp_node = nd;
- crpc->crp_posted = 0;
+ crpc->crp_trans = NULL;
+ crpc->crp_node = nd;
+ crpc->crp_posted = 0;
crpc->crp_finished = 0;
crpc->crp_unpacked = 0;
- crpc->crp_status = 0;
- crpc->crp_stamp = 0;
+ crpc->crp_status = 0;
+ crpc->crp_stamp = 0;
crpc->crp_embedded = embedded;
INIT_LIST_HEAD(&crpc->crp_link);
@@ -121,22 +123,21 @@ lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned 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,
- lstcon_rpc_t, crp_link);
+ crpc = list_first_entry_or_null(&console_session.ses_rpc_freelist,
+ lstcon_rpc_t, crp_link);
+ if (crpc)
list_del_init(&crpc->crp_link);
- }
spin_unlock(&console_session.ses_rpc_lock);
- if (crpc == NULL) {
+ if (!crpc) {
LIBCFS_ALLOC(crpc, sizeof(*crpc));
- if (crpc == NULL)
+ if (!crpc)
return -ENOMEM;
}
rc = lstcon_rpc_init(nd, service, feats, bulk_npg, bulk_len, 0, crpc);
- if (rc == 0) {
+ if (!rc) {
*crpcpp = crpc;
return 0;
}
@@ -155,7 +156,7 @@ lstcon_rpc_put(lstcon_rpc_t *crpc)
LASSERT(list_empty(&crpc->crp_link));
for (i = 0; i < bulk->bk_niov; i++) {
- if (bulk->bk_iovs[i].kiov_page == NULL)
+ if (!bulk->bk_iovs[i].kiov_page)
continue;
__free_page(bulk->bk_iovs[i].kiov_page);
@@ -172,7 +173,7 @@ lstcon_rpc_put(lstcon_rpc_t *crpc)
spin_lock(&console_session.ses_rpc_lock);
list_add(&crpc->crp_link,
- &console_session.ses_rpc_freelist);
+ &console_session.ses_rpc_freelist);
spin_unlock(&console_session.ses_rpc_lock);
}
@@ -186,7 +187,7 @@ lstcon_rpc_post(lstcon_rpc_t *crpc)
{
lstcon_rpc_trans_t *trans = crpc->crp_trans;
- LASSERT(trans != NULL);
+ LASSERT(trans);
atomic_inc(&trans->tas_remaining);
crpc->crp_posted = 1;
@@ -234,15 +235,17 @@ lstcon_rpc_trans_name(int transop)
}
int
-lstcon_rpc_trans_prep(struct list_head *translist,
- int transop, lstcon_rpc_trans_t **transpp)
+lstcon_rpc_trans_prep(struct list_head *translist, int transop,
+ lstcon_rpc_trans_t **transpp)
{
lstcon_rpc_trans_t *trans;
- if (translist != NULL) {
+ if (translist) {
list_for_each_entry(trans, translist, tas_link) {
- /* Can't enqueue two private transaction on
- * the same object */
+ /*
+ * Can't enqueue two private transaction on
+ * the same object
+ */
if ((trans->tas_opc & transop) == LST_TRANS_PRIVATE)
return -EPERM;
}
@@ -250,12 +253,12 @@ lstcon_rpc_trans_prep(struct list_head *translist,
/* create a trans group */
LIBCFS_ALLOC(trans, sizeof(*trans));
- if (trans == NULL)
+ if (!trans)
return -ENOMEM;
trans->tas_opc = transop;
- if (translist == NULL)
+ if (!translist)
INIT_LIST_HEAD(&trans->tas_olink);
else
list_add_tail(&trans->tas_olink, translist);
@@ -285,8 +288,8 @@ void
lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error)
{
srpc_client_rpc_t *rpc;
- lstcon_rpc_t *crpc;
- lstcon_node_t *nd;
+ lstcon_rpc_t *crpc;
+ lstcon_node_t *nd;
list_for_each_entry(crpc, &trans->tas_rpcs_list, crp_link) {
rpc = crpc->crp_rpc;
@@ -294,8 +297,8 @@ lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error)
spin_lock(&rpc->crpc_lock);
if (!crpc->crp_posted || /* not posted */
- crpc->crp_stamp != 0) { /* rpc done or aborted already */
- if (crpc->crp_stamp == 0) {
+ crpc->crp_stamp) { /* rpc done or aborted already */
+ if (!crpc->crp_stamp) {
crpc->crp_stamp = cfs_time_current();
crpc->crp_status = -EINTR;
}
@@ -303,14 +306,14 @@ lstcon_rpc_trans_abort(lstcon_rpc_trans_t *trans, int error)
continue;
}
- crpc->crp_stamp = cfs_time_current();
+ crpc->crp_stamp = cfs_time_current();
crpc->crp_status = error;
spin_unlock(&rpc->crpc_lock);
sfw_abort_rpc(rpc);
- if (error != ETIMEDOUT)
+ if (error != -ETIMEDOUT)
continue;
nd = crpc->crp_node;
@@ -329,7 +332,7 @@ lstcon_rpc_trans_check(lstcon_rpc_trans_t *trans)
!list_empty(&trans->tas_olink)) /* Not an end session RPC */
return 1;
- return (atomic_read(&trans->tas_remaining) == 0) ? 1 : 0;
+ return !atomic_read(&trans->tas_remaining) ? 1 : 0;
}
int
@@ -366,7 +369,7 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
if (console_session.ses_shutdown)
rc = -ESHUTDOWN;
- if (rc != 0 || atomic_read(&trans->tas_remaining) != 0) {
+ if (rc || atomic_read(&trans->tas_remaining)) {
/* treat short timeout as canceled */
if (rc == -ETIMEDOUT && timeout < LST_TRANS_MIN_TIMEOUT * 2)
rc = -EINTR;
@@ -385,14 +388,14 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
static int
lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
{
- lstcon_node_t *nd = crpc->crp_node;
+ lstcon_node_t *nd = crpc->crp_node;
srpc_client_rpc_t *rpc = crpc->crp_rpc;
srpc_generic_reply_t *rep;
- LASSERT(nd != NULL && rpc != NULL);
- LASSERT(crpc->crp_stamp != 0);
+ LASSERT(nd && rpc);
+ LASSERT(crpc->crp_stamp);
- if (crpc->crp_status != 0) {
+ if (crpc->crp_status) {
*msgpp = NULL;
return crpc->crp_status;
}
@@ -422,23 +425,23 @@ lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
void
lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat)
{
- lstcon_rpc_t *crpc;
+ lstcon_rpc_t *crpc;
srpc_msg_t *rep;
int error;
- LASSERT(stat != NULL);
+ LASSERT(stat);
memset(stat, 0, sizeof(*stat));
list_for_each_entry(crpc, &trans->tas_rpcs_list, crp_link) {
lstcon_rpc_stat_total(stat, 1);
- LASSERT(crpc->crp_stamp != 0);
+ LASSERT(crpc->crp_stamp);
error = lstcon_rpc_get_reply(crpc, &rep);
- if (error != 0) {
+ if (error) {
lstcon_rpc_stat_failure(stat, 1);
- if (stat->trs_rpc_errno == 0)
+ if (!stat->trs_rpc_errno)
stat->trs_rpc_errno = -error;
continue;
@@ -449,7 +452,7 @@ lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat)
lstcon_rpc_stat_reply(trans, rep, crpc->crp_node, stat);
}
- if (trans->tas_opc == LST_TRANS_SESNEW && stat->trs_fwk_errno == 0) {
+ if (trans->tas_opc == LST_TRANS_SESNEW && !stat->trs_fwk_errno) {
stat->trs_fwk_errno =
lstcon_session_feats_check(trans->tas_features);
}
@@ -460,17 +463,15 @@ lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat)
lstcon_rpc_stat_failure(stat, 0),
lstcon_rpc_stat_total(stat, 0),
stat->trs_rpc_errno, stat->trs_fwk_errno);
-
- return;
}
int
lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
- struct list_head *head_up,
+ struct list_head __user *head_up,
lstcon_rpc_readent_func_t readent)
{
struct list_head tmp;
- struct list_head *next;
+ struct list_head __user *next;
lstcon_rpc_ent_t *ent;
srpc_generic_reply_t *rep;
lstcon_rpc_t *crpc;
@@ -480,13 +481,13 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
struct timeval tv;
int error;
- LASSERT(head_up != NULL);
+ LASSERT(head_up);
next = head_up;
list_for_each_entry(crpc, &trans->tas_rpcs_list, crp_link) {
if (copy_from_user(&tmp, next,
- sizeof(struct list_head)))
+ sizeof(struct list_head)))
return -EFAULT;
if (tmp.next == head_up)
@@ -496,7 +497,7 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
ent = list_entry(next, lstcon_rpc_ent_t, rpe_link);
- LASSERT(crpc->crp_stamp != 0);
+ LASSERT(crpc->crp_stamp);
error = lstcon_rpc_get_reply(crpc, &msg);
@@ -506,33 +507,32 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
(unsigned long)console_session.ses_id.ses_stamp);
jiffies_to_timeval(dur, &tv);
- if (copy_to_user(&ent->rpe_peer,
- &nd->nd_id, sizeof(lnet_process_id_t)) ||
+ if (copy_to_user(&ent->rpe_peer, &nd->nd_id,
+ sizeof(lnet_process_id_t)) ||
copy_to_user(&ent->rpe_stamp, &tv, sizeof(tv)) ||
- copy_to_user(&ent->rpe_state,
- &nd->nd_state, sizeof(nd->nd_state)) ||
+ copy_to_user(&ent->rpe_state, &nd->nd_state,
+ sizeof(nd->nd_state)) ||
copy_to_user(&ent->rpe_rpc_errno, &error,
- sizeof(error)))
+ sizeof(error)))
return -EFAULT;
- if (error != 0)
+ if (error)
continue;
/* RPC is done */
rep = (srpc_generic_reply_t *)&msg->msg_body.reply;
- if (copy_to_user(&ent->rpe_sid,
- &rep->sid, sizeof(lst_sid_t)) ||
- copy_to_user(&ent->rpe_fwk_errno,
- &rep->status, sizeof(rep->status)))
+ if (copy_to_user(&ent->rpe_sid, &rep->sid, sizeof(lst_sid_t)) ||
+ copy_to_user(&ent->rpe_fwk_errno, &rep->status,
+ sizeof(rep->status)))
return -EFAULT;
- if (readent == NULL)
+ if (!readent)
continue;
error = readent(trans->tas_opc, msg, ent);
- if (error != 0)
+ if (error)
return error;
}
@@ -547,8 +547,7 @@ lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
lstcon_rpc_t *tmp;
int count = 0;
- list_for_each_entry_safe(crpc, tmp, &trans->tas_rpcs_list,
- crp_link) {
+ list_for_each_entry_safe(crpc, tmp, &trans->tas_rpcs_list, crp_link) {
rpc = crpc->crp_rpc;
spin_lock(&rpc->crpc_lock);
@@ -563,14 +562,15 @@ lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
continue;
}
- /* rpcs can be still not callbacked (even LNetMDUnlink is called)
+ /*
+ * rpcs can be still not callbacked (even LNetMDUnlink is called)
* because huge timeout for inaccessible network, don't make
* user wait for them, just abandon them, they will be recycled
- * in callback */
+ * in callback
+ */
+ LASSERT(crpc->crp_status);
- LASSERT(crpc->crp_status != 0);
-
- crpc->crp_node = NULL;
+ crpc->crp_node = NULL;
crpc->crp_trans = NULL;
list_del_init(&crpc->crp_link);
count++;
@@ -580,7 +580,7 @@ lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
atomic_dec(&trans->tas_remaining);
}
- LASSERT(atomic_read(&trans->tas_remaining) == 0);
+ LASSERT(!atomic_read(&trans->tas_remaining));
list_del(&trans->tas_link);
if (!list_empty(&trans->tas_olink))
@@ -590,8 +590,6 @@ lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
lstcon_rpc_trans_name(trans->tas_opc), count);
LIBCFS_FREE(trans, sizeof(*trans));
-
- return;
}
int
@@ -606,12 +604,12 @@ lstcon_sesrpc_prep(lstcon_node_t *nd, int transop,
case LST_TRANS_SESNEW:
rc = lstcon_rpc_prep(nd, SRPC_SERVICE_MAKE_SESSION,
feats, 0, 0, crpc);
- if (rc != 0)
+ if (rc)
return rc;
msrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.mksn_reqst;
- msrq->mksn_sid = console_session.ses_id;
- msrq->mksn_force = console_session.ses_force;
+ msrq->mksn_sid = console_session.ses_id;
+ msrq->mksn_force = console_session.ses_force;
strlcpy(msrq->mksn_name, console_session.ses_name,
sizeof(msrq->mksn_name));
break;
@@ -619,7 +617,7 @@ lstcon_sesrpc_prep(lstcon_node_t *nd, int transop,
case LST_TRANS_SESEND:
rc = lstcon_rpc_prep(nd, SRPC_SERVICE_REMOVE_SESSION,
feats, 0, 0, crpc);
- if (rc != 0)
+ if (rc)
return rc;
rsrq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.rmsn_reqst;
@@ -640,12 +638,12 @@ lstcon_dbgrpc_prep(lstcon_node_t *nd, unsigned feats, lstcon_rpc_t **crpc)
int rc;
rc = lstcon_rpc_prep(nd, SRPC_SERVICE_DEBUG, feats, 0, 0, crpc);
- if (rc != 0)
+ if (rc)
return rc;
drq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.dbg_reqst;
- drq->dbg_sid = console_session.ses_id;
+ drq->dbg_sid = console_session.ses_id;
drq->dbg_flags = 0;
return rc;
@@ -655,28 +653,28 @@ int
lstcon_batrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
lstcon_tsb_hdr_t *tsb, lstcon_rpc_t **crpc)
{
- lstcon_batch_t *batch;
+ lstcon_batch_t *batch;
srpc_batch_reqst_t *brq;
- int rc;
+ int rc;
rc = lstcon_rpc_prep(nd, SRPC_SERVICE_BATCH, feats, 0, 0, crpc);
- if (rc != 0)
+ if (rc)
return rc;
brq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.bat_reqst;
- brq->bar_sid = console_session.ses_id;
- brq->bar_bid = tsb->tsb_id;
+ brq->bar_sid = console_session.ses_id;
+ brq->bar_bid = tsb->tsb_id;
brq->bar_testidx = tsb->tsb_index;
- brq->bar_opc = transop == LST_TRANS_TSBRUN ? SRPC_BATCH_OPC_RUN :
- (transop == LST_TRANS_TSBSTOP ? SRPC_BATCH_OPC_STOP :
- SRPC_BATCH_OPC_QUERY);
+ brq->bar_opc = transop == LST_TRANS_TSBRUN ? SRPC_BATCH_OPC_RUN :
+ (transop == LST_TRANS_TSBSTOP ? SRPC_BATCH_OPC_STOP :
+ SRPC_BATCH_OPC_QUERY);
if (transop != LST_TRANS_TSBRUN &&
transop != LST_TRANS_TSBSTOP)
return 0;
- LASSERT(tsb->tsb_index == 0);
+ LASSERT(!tsb->tsb_index);
batch = (lstcon_batch_t *)tsb;
brq->bar_arg = batch->bat_arg;
@@ -688,15 +686,15 @@ int
lstcon_statrpc_prep(lstcon_node_t *nd, unsigned feats, lstcon_rpc_t **crpc)
{
srpc_stat_reqst_t *srq;
- int rc;
+ int rc;
rc = lstcon_rpc_prep(nd, SRPC_SERVICE_QUERY_STAT, feats, 0, 0, crpc);
- if (rc != 0)
+ if (rc)
return rc;
srq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.stat_reqst;
- srq->str_sid = console_session.ses_id;
+ srq->str_sid = console_session.ses_id;
srq->str_type = 0; /* XXX remove it */
return 0;
@@ -736,7 +734,7 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx,
return -EINVAL;
start = ((idx / dist) * span) % grp->grp_nnode;
- end = ((idx / dist) * span + span - 1) % grp->grp_nnode;
+ end = ((idx / dist) * span + span - 1) % grp->grp_nnode;
list_for_each_entry(ndl, &grp->grp_ndl_list, ndl_link) {
nd = ndl->ndl_node;
@@ -776,7 +774,7 @@ lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req)
{
test_ping_req_t *prq = &req->tsr_u.ping;
- prq->png_size = param->png_size;
+ prq->png_size = param->png_size;
prq->png_flags = param->png_flags;
/* TODO dest */
return 0;
@@ -787,9 +785,9 @@ lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req)
{
test_bulk_req_t *brq = &req->tsr_u.bulk_v0;
- brq->blk_opc = param->blk_opc;
- brq->blk_npg = (param->blk_size + PAGE_CACHE_SIZE - 1) /
- PAGE_CACHE_SIZE;
+ brq->blk_opc = param->blk_opc;
+ brq->blk_npg = (param->blk_size + PAGE_CACHE_SIZE - 1) /
+ PAGE_CACHE_SIZE;
brq->blk_flags = param->blk_flags;
return 0;
@@ -800,9 +798,9 @@ lstcon_bulkrpc_v1_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req)
{
test_bulk_req_v1_t *brq = &req->tsr_u.bulk_v1;
- brq->blk_opc = param->blk_opc;
- brq->blk_flags = param->blk_flags;
- brq->blk_len = param->blk_size;
+ brq->blk_opc = param->blk_opc;
+ brq->blk_flags = param->blk_flags;
+ brq->blk_len = param->blk_size;
brq->blk_offset = 0; /* reserved */
return 0;
@@ -812,27 +810,27 @@ int
lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
lstcon_test_t *test, lstcon_rpc_t **crpc)
{
- lstcon_group_t *sgrp = test->tes_src_grp;
- lstcon_group_t *dgrp = test->tes_dst_grp;
+ lstcon_group_t *sgrp = test->tes_src_grp;
+ lstcon_group_t *dgrp = test->tes_dst_grp;
srpc_test_reqst_t *trq;
- srpc_bulk_t *bulk;
- int i;
- int npg = 0;
- int nob = 0;
- int rc = 0;
+ srpc_bulk_t *bulk;
+ int i;
+ int npg = 0;
+ int nob = 0;
+ int rc = 0;
if (transop == LST_TRANS_TSBCLIADD) {
npg = sfw_id_pages(test->tes_span);
- nob = (feats & LST_FEAT_BULK_LEN) == 0 ?
+ nob = !(feats & LST_FEAT_BULK_LEN) ?
npg * PAGE_CACHE_SIZE :
sizeof(lnet_process_id_packed_t) * test->tes_span;
}
rc = lstcon_rpc_prep(nd, SRPC_SERVICE_TEST, feats, npg, nob, crpc);
- if (rc != 0)
+ if (rc)
return rc;
- trq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.tes_reqst;
+ trq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.tes_reqst;
if (transop == LST_TRANS_TSBSRVADD) {
int ndist = (sgrp->grp_nnode + test->tes_dist - 1) /
@@ -842,27 +840,27 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
int nmax = (ndist + nspan - 1) / nspan;
trq->tsr_ndest = 0;
- trq->tsr_loop = nmax * test->tes_dist * test->tes_concur;
+ trq->tsr_loop = nmax * test->tes_dist * test->tes_concur;
} else {
bulk = &(*crpc)->crp_rpc->crpc_bulk;
for (i = 0; i < npg; i++) {
- int len;
+ int len;
LASSERT(nob > 0);
- len = (feats & LST_FEAT_BULK_LEN) == 0 ?
+ len = !(feats & LST_FEAT_BULK_LEN) ?
PAGE_CACHE_SIZE :
min_t(int, nob, PAGE_CACHE_SIZE);
nob -= len;
bulk->bk_iovs[i].kiov_offset = 0;
- bulk->bk_iovs[i].kiov_len = len;
- bulk->bk_iovs[i].kiov_page =
+ bulk->bk_iovs[i].kiov_len = len;
+ bulk->bk_iovs[i].kiov_page =
alloc_page(GFP_KERNEL);
- if (bulk->bk_iovs[i].kiov_page == NULL) {
+ if (!bulk->bk_iovs[i].kiov_page) {
lstcon_rpc_put(*crpc);
return -ENOMEM;
}
@@ -877,19 +875,19 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
test->tes_dist,
test->tes_span,
npg, &bulk->bk_iovs[0]);
- if (rc != 0) {
+ if (rc) {
lstcon_rpc_put(*crpc);
return rc;
}
trq->tsr_ndest = test->tes_span;
- trq->tsr_loop = test->tes_loop;
+ trq->tsr_loop = test->tes_loop;
}
- trq->tsr_sid = console_session.ses_id;
- trq->tsr_bid = test->tes_hdr.tsb_id;
- trq->tsr_concur = test->tes_concur;
- trq->tsr_is_client = (transop == LST_TRANS_TSBCLIADD) ? 1 : 0;
+ trq->tsr_sid = console_session.ses_id;
+ trq->tsr_bid = test->tes_hdr.tsb_id;
+ trq->tsr_concur = test->tes_concur;
+ trq->tsr_is_client = (transop == LST_TRANS_TSBCLIADD) ? 1 : 0;
trq->tsr_stop_onerr = !!test->tes_stop_onerr;
switch (test->tes_type) {
@@ -901,7 +899,7 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
case LST_TEST_BULK:
trq->tsr_service = SRPC_SERVICE_BRW;
- if ((feats & LST_FEAT_BULK_LEN) == 0) {
+ if (!(feats & LST_FEAT_BULK_LEN)) {
rc = lstcon_bulkrpc_v0_prep((lst_test_bulk_param_t *)
&test->tes_param[0], trq);
} else {
@@ -923,10 +921,10 @@ lstcon_sesnew_stat_reply(lstcon_rpc_trans_t *trans,
lstcon_node_t *nd, srpc_msg_t *reply)
{
srpc_mksn_reply_t *mksn_rep = &reply->msg_body.mksn_reply;
- int status = mksn_rep->mksn_status;
+ int status = mksn_rep->mksn_status;
- if (status == 0 &&
- (reply->msg_ses_feats & ~LST_FEATS_MASK) != 0) {
+ if (!status &&
+ (reply->msg_ses_feats & ~LST_FEATS_MASK)) {
mksn_rep->mksn_status = EPROTO;
status = EPROTO;
}
@@ -937,22 +935,27 @@ lstcon_sesnew_stat_reply(lstcon_rpc_trans_t *trans,
reply->msg_ses_feats);
}
- if (status != 0)
+ if (status)
return status;
if (!trans->tas_feats_updated) {
- trans->tas_feats_updated = 1;
- trans->tas_features = reply->msg_ses_feats;
+ spin_lock(&console_session.ses_rpc_lock);
+ if (!trans->tas_feats_updated) { /* recheck with lock */
+ trans->tas_feats_updated = 1;
+ trans->tas_features = reply->msg_ses_feats;
+ }
+ spin_unlock(&console_session.ses_rpc_lock);
}
if (reply->msg_ses_feats != trans->tas_features) {
CNETERR("Framework features %x from %s is different with features on this transaction: %x\n",
- reply->msg_ses_feats, libcfs_nid2str(nd->nd_id.nid),
- trans->tas_features);
- status = mksn_rep->mksn_status = EPROTO;
+ reply->msg_ses_feats, libcfs_nid2str(nd->nd_id.nid),
+ trans->tas_features);
+ mksn_rep->mksn_status = EPROTO;
+ status = EPROTO;
}
- if (status == 0) {
+ if (!status) {
/* session timeout on remote node */
nd->nd_timeout = mksn_rep->mksn_timeout;
}
@@ -964,17 +967,17 @@ void
lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
lstcon_node_t *nd, lstcon_trans_stat_t *stat)
{
- srpc_rmsn_reply_t *rmsn_rep;
+ srpc_rmsn_reply_t *rmsn_rep;
srpc_debug_reply_t *dbg_rep;
srpc_batch_reply_t *bat_rep;
- srpc_test_reply_t *test_rep;
- srpc_stat_reply_t *stat_rep;
- int rc = 0;
+ srpc_test_reply_t *test_rep;
+ srpc_stat_reply_t *stat_rep;
+ int rc = 0;
switch (trans->tas_opc) {
case LST_TRANS_SESNEW:
rc = lstcon_sesnew_stat_reply(trans, nd, msg);
- if (rc == 0) {
+ if (!rc) {
lstcon_sesop_stat_success(stat, 1);
return;
}
@@ -985,7 +988,7 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
case LST_TRANS_SESEND:
rmsn_rep = &msg->msg_body.rmsn_reply;
/* ESRCH is not an error for end session */
- if (rmsn_rep->rmsn_status == 0 ||
+ if (!rmsn_rep->rmsn_status ||
rmsn_rep->rmsn_status == ESRCH) {
lstcon_sesop_stat_success(stat, 1);
return;
@@ -1014,7 +1017,7 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
case LST_TRANS_TSBSTOP:
bat_rep = &msg->msg_body.bat_reply;
- if (bat_rep->bar_status == 0) {
+ if (!bat_rep->bar_status) {
lstcon_tsbop_stat_success(stat, 1);
return;
}
@@ -1033,12 +1036,12 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
case LST_TRANS_TSBSRVQRY:
bat_rep = &msg->msg_body.bat_reply;
- if (bat_rep->bar_active != 0)
+ if (bat_rep->bar_active)
lstcon_tsbqry_stat_run(stat, 1);
else
lstcon_tsbqry_stat_idle(stat, 1);
- if (bat_rep->bar_status == 0)
+ if (!bat_rep->bar_status)
return;
lstcon_tsbqry_stat_failure(stat, 1);
@@ -1049,7 +1052,7 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
case LST_TRANS_TSBSRVADD:
test_rep = &msg->msg_body.tes_reply;
- if (test_rep->tsr_status == 0) {
+ if (!test_rep->tsr_status) {
lstcon_tsbop_stat_success(stat, 1);
return;
}
@@ -1061,7 +1064,7 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
case LST_TRANS_STATQRY:
stat_rep = &msg->msg_body.stat_reply;
- if (stat_rep->str_status == 0) {
+ if (!stat_rep->str_status) {
lstcon_statqry_stat_success(stat, 1);
return;
}
@@ -1074,10 +1077,8 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
LBUG();
}
- if (stat->trs_fwk_errno == 0)
+ if (!stat->trs_fwk_errno)
stat->trs_fwk_errno = rc;
-
- return;
}
int
@@ -1096,22 +1097,22 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
/* Creating session RPG for list of nodes */
rc = lstcon_rpc_trans_prep(translist, transop, &trans);
- if (rc != 0) {
+ if (rc) {
CERROR("Can't create transaction %d: %d\n", transop, rc);
return rc;
}
feats = trans->tas_features;
list_for_each_entry(ndl, ndlist, ndl_link) {
- rc = condition == NULL ? 1 :
+ rc = !condition ? 1 :
condition(transop, ndl->ndl_node, arg);
- if (rc == 0)
+ if (!rc)
continue;
if (rc < 0) {
CDEBUG(D_NET, "Condition error while creating RPC for transaction %d: %d\n",
- transop, rc);
+ transop, rc);
break;
}
@@ -1146,7 +1147,7 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
break;
}
- if (rc != 0) {
+ if (rc) {
CERROR("Failed to create RPC for transaction %s: %d\n",
lstcon_rpc_trans_name(transop), rc);
break;
@@ -1155,7 +1156,7 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
lstcon_rpc_trans_addreq(trans, rpc);
}
- if (rc == 0) {
+ if (!rc) {
*transpp = trans;
return 0;
}
@@ -1168,7 +1169,7 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
static void
lstcon_rpc_pinger(void *arg)
{
- stt_timer_t *ptimer = (stt_timer_t *)arg;
+ struct stt_timer *ptimer = (struct stt_timer *)arg;
lstcon_rpc_trans_t *trans;
lstcon_rpc_t *crpc;
srpc_msg_t *rep;
@@ -1196,7 +1197,7 @@ lstcon_rpc_pinger(void *arg)
trans = console_session.ses_ping;
- LASSERT(trans != NULL);
+ LASSERT(trans);
list_for_each_entry(ndl, &console_session.ses_ndl_list, ndl_link) {
nd = ndl->ndl_node;
@@ -1208,7 +1209,7 @@ lstcon_rpc_pinger(void *arg)
rc = lstcon_sesrpc_prep(nd, LST_TRANS_SESEND,
trans->tas_features, &crpc);
- if (rc != 0) {
+ if (rc) {
CERROR("Out of memory\n");
break;
}
@@ -1221,7 +1222,7 @@ lstcon_rpc_pinger(void *arg)
crpc = &nd->nd_ping;
- if (crpc->crp_rpc != NULL) {
+ if (crpc->crp_rpc) {
LASSERT(crpc->crp_trans == trans);
LASSERT(!list_empty(&crpc->crp_link));
@@ -1247,20 +1248,20 @@ lstcon_rpc_pinger(void *arg)
if (nd->nd_state != LST_NODE_ACTIVE)
continue;
- intv = (jiffies - nd->nd_stamp) / HZ;
+ intv = (jiffies - nd->nd_stamp) / msecs_to_jiffies(MSEC_PER_SEC);
if (intv < nd->nd_timeout / 2)
continue;
rc = lstcon_rpc_init(nd, SRPC_SERVICE_DEBUG,
trans->tas_features, 0, 0, 1, crpc);
- if (rc != 0) {
+ if (rc) {
CERROR("Out of memory\n");
break;
}
drq = &crpc->crp_rpc->crpc_reqstmsg.msg_body.dbg_reqst;
- drq->dbg_sid = console_session.ses_id;
+ drq->dbg_sid = console_session.ses_id;
drq->dbg_flags = 0;
lstcon_rpc_trans_addreq(trans, crpc);
@@ -1285,15 +1286,15 @@ lstcon_rpc_pinger(void *arg)
int
lstcon_rpc_pinger_start(void)
{
- stt_timer_t *ptimer;
+ struct stt_timer *ptimer;
int rc;
LASSERT(list_empty(&console_session.ses_rpc_freelist));
- LASSERT(atomic_read(&console_session.ses_rpc_counter) == 0);
+ LASSERT(!atomic_read(&console_session.ses_rpc_counter));
rc = lstcon_rpc_trans_prep(NULL, LST_TRANS_SESPING,
&console_session.ses_ping);
- if (rc != 0) {
+ if (rc) {
CERROR("Failed to create console pinger\n");
return rc;
}
@@ -1327,6 +1328,7 @@ lstcon_rpc_cleanup_wait(void)
{
lstcon_rpc_trans_t *trans;
lstcon_rpc_t *crpc;
+ lstcon_rpc_t *temp;
struct list_head *pacer;
struct list_head zlist;
@@ -1337,7 +1339,7 @@ lstcon_rpc_cleanup_wait(void)
while (!list_empty(&console_session.ses_trans_list)) {
list_for_each(pacer, &console_session.ses_trans_list) {
trans = list_entry(pacer, lstcon_rpc_trans_t,
- tas_link);
+ tas_link);
CDEBUG(D_NET, "Session closed, wakeup transaction %s\n",
lstcon_rpc_trans_name(trans->tas_opc));
@@ -1356,7 +1358,7 @@ lstcon_rpc_cleanup_wait(void)
spin_lock(&console_session.ses_rpc_lock);
- lst_wait_until((atomic_read(&console_session.ses_rpc_counter) == 0),
+ lst_wait_until(!atomic_read(&console_session.ses_rpc_counter),
console_session.ses_rpc_lock,
"Network is not accessible or target is down, waiting for %d console RPCs to being recycled\n",
atomic_read(&console_session.ses_rpc_counter));
@@ -1366,9 +1368,7 @@ lstcon_rpc_cleanup_wait(void)
spin_unlock(&console_session.ses_rpc_lock);
- while (!list_empty(&zlist)) {
- crpc = list_entry(zlist.next, lstcon_rpc_t, crp_link);
-
+ list_for_each_entry_safe(crpc, temp, &zlist, crp_link) {
list_del(&crpc->crp_link);
LIBCFS_FREE(crpc, sizeof(lstcon_rpc_t));
}
@@ -1394,5 +1394,5 @@ void
lstcon_rpc_module_fini(void)
{
LASSERT(list_empty(&console_session.ses_rpc_freelist));
- LASSERT(atomic_read(&console_session.ses_rpc_counter) == 0);
+ LASSERT(!atomic_read(&console_session.ses_rpc_counter));
}