Commit 58cb2ad3 authored by James Simmons's avatar James Simmons Committed by Greg Kroah-Hartman

staging: lustre: return proper error code for LNet core

It is consider bad style in the linux kernel to
return -1 or a positive number for an error.
Instead return the appropriate error codes.
Signed-off-by: default avatarJames Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6142
Reviewed-on: http://review.whamcloud.com/17626Reviewed-by: default avatarDoug Oucharek <doug.s.oucharek@intel.com>
Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b9bbb61c
...@@ -1409,7 +1409,7 @@ int lnet_lib_init(void) ...@@ -1409,7 +1409,7 @@ int lnet_lib_init(void)
/* we are under risk of consuming all lh_cookie */ /* we are under risk of consuming all lh_cookie */
CERROR("Can't have %d CPTs for LNet (max allowed is %d), please change setting of CPT-table and retry\n", CERROR("Can't have %d CPTs for LNet (max allowed is %d), please change setting of CPT-table and retry\n",
the_lnet.ln_cpt_number, LNET_CPT_MAX); the_lnet.ln_cpt_number, LNET_CPT_MAX);
return -1; return -E2BIG;
} }
while ((1 << the_lnet.ln_cpt_bits) < the_lnet.ln_cpt_number) while ((1 << the_lnet.ln_cpt_bits) < the_lnet.ln_cpt_number)
...@@ -1418,7 +1418,7 @@ int lnet_lib_init(void) ...@@ -1418,7 +1418,7 @@ int lnet_lib_init(void)
rc = lnet_create_locks(); rc = lnet_create_locks();
if (rc) { if (rc) {
CERROR("Can't create LNet global locks: %d\n", rc); CERROR("Can't create LNet global locks: %d\n", rc);
return -1; return rc;
} }
the_lnet.ln_refcount = 0; the_lnet.ln_refcount = 0;
......
...@@ -467,7 +467,7 @@ lnet_str2tbs_sep(struct list_head *tbs, char *str) ...@@ -467,7 +467,7 @@ lnet_str2tbs_sep(struct list_head *tbs, char *str)
ltb = lnet_new_text_buf(nob); ltb = lnet_new_text_buf(nob);
if (!ltb) { if (!ltb) {
lnet_free_text_bufs(&pending); lnet_free_text_bufs(&pending);
return -1; return -ENOMEM;
} }
for (i = 0; i < nob; i++) for (i = 0; i < nob; i++)
...@@ -598,7 +598,7 @@ lnet_str2tbs_expand(struct list_head *tbs, char *str) ...@@ -598,7 +598,7 @@ lnet_str2tbs_expand(struct list_head *tbs, char *str)
failed: failed:
lnet_free_text_bufs(&pending); lnet_free_text_bufs(&pending);
return -1; return -EINVAL;
} }
static int static int
...@@ -634,7 +634,7 @@ lnet_parse_priority(char *str, unsigned int *priority, char **token) ...@@ -634,7 +634,7 @@ lnet_parse_priority(char *str, unsigned int *priority, char **token)
* priority as the token to report in the error message. * priority as the token to report in the error message.
*/ */
*token += sep - str + 1; *token += sep - str + 1;
return -1; return -EINVAL;
} }
CDEBUG(D_NET, "gateway %s, priority %d, nob %d\n", str, *priority, nob); CDEBUG(D_NET, "gateway %s, priority %d, nob %d\n", str, *priority, nob);
......
...@@ -320,7 +320,7 @@ __must_hold(&the_lnet.ln_eq_wait_lock) ...@@ -320,7 +320,7 @@ __must_hold(&the_lnet.ln_eq_wait_lock)
unsigned long now; unsigned long now;
if (!tms) if (!tms)
return -1; /* don't want to wait and no new event */ return -ENXIO; /* don't want to wait and no new event */
init_waitqueue_entry(&wl, current); init_waitqueue_entry(&wl, current);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
......
...@@ -1167,30 +1167,30 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2) ...@@ -1167,30 +1167,30 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2)
return 1; return 1;
if (r1->lr_priority > r2->lr_priority) if (r1->lr_priority > r2->lr_priority)
return -1; return -ERANGE;
if (r1_hops < r2_hops) if (r1_hops < r2_hops)
return 1; return 1;
if (r1_hops > r2_hops) if (r1_hops > r2_hops)
return -1; return -ERANGE;
if (p1->lp_txqnob < p2->lp_txqnob) if (p1->lp_txqnob < p2->lp_txqnob)
return 1; return 1;
if (p1->lp_txqnob > p2->lp_txqnob) if (p1->lp_txqnob > p2->lp_txqnob)
return -1; return -ERANGE;
if (p1->lp_txcredits > p2->lp_txcredits) if (p1->lp_txcredits > p2->lp_txcredits)
return 1; return 1;
if (p1->lp_txcredits < p2->lp_txcredits) if (p1->lp_txcredits < p2->lp_txcredits)
return -1; return -ERANGE;
if (r1->lr_seq - r2->lr_seq <= 0) if (r1->lr_seq - r2->lr_seq <= 0)
return 1; return 1;
return -1; return -ERANGE;
} }
static lnet_peer_t * static lnet_peer_t *
...@@ -1517,7 +1517,7 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg) ...@@ -1517,7 +1517,7 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
libcfs_id2str(info.mi_id), info.mi_portal, libcfs_id2str(info.mi_id), info.mi_portal,
info.mi_mbits, info.mi_roffset, info.mi_rlength, rc); info.mi_mbits, info.mi_roffset, info.mi_rlength, rc);
return ENOENT; /* +ve: OK but no match */ return -ENOENT; /* -ve: OK but no match */
} }
} }
...@@ -1548,7 +1548,7 @@ lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get) ...@@ -1548,7 +1548,7 @@ lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get)
CNETERR("Dropping GET from %s portal %d match %llu offset %d length %d\n", CNETERR("Dropping GET from %s portal %d match %llu offset %d length %d\n",
libcfs_id2str(info.mi_id), info.mi_portal, libcfs_id2str(info.mi_id), info.mi_portal,
info.mi_mbits, info.mi_roffset, info.mi_rlength); info.mi_mbits, info.mi_roffset, info.mi_rlength);
return ENOENT; /* +ve: OK but no match */ return -ENOENT; /* -ve: OK but no match */
} }
LASSERT(rc == LNET_MATCHMD_OK); LASSERT(rc == LNET_MATCHMD_OK);
...@@ -1615,7 +1615,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg) ...@@ -1615,7 +1615,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
md->md_me->me_portal); md->md_me->me_portal);
lnet_res_unlock(cpt); lnet_res_unlock(cpt);
return ENOENT; /* +ve: OK but no match */ return -ENOENT; /* -ve: OK but no match */
} }
LASSERT(!md->md_offset); LASSERT(!md->md_offset);
...@@ -1630,7 +1630,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg) ...@@ -1630,7 +1630,7 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
rlength, hdr->msg.reply.dst_wmd.wh_object_cookie, rlength, hdr->msg.reply.dst_wmd.wh_object_cookie,
mlength); mlength);
lnet_res_unlock(cpt); lnet_res_unlock(cpt);
return ENOENT; /* +ve: OK but no match */ return -ENOENT; /* -ve: OK but no match */
} }
CDEBUG(D_NET, "%s: Reply from %s of length %d/%d into md %#llx\n", CDEBUG(D_NET, "%s: Reply from %s of length %d/%d into md %#llx\n",
...@@ -1683,7 +1683,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg) ...@@ -1683,7 +1683,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
md->md_me->me_portal); md->md_me->me_portal);
lnet_res_unlock(cpt); lnet_res_unlock(cpt);
return ENOENT; /* +ve! */ return -ENOENT; /* -ve! */
} }
CDEBUG(D_NET, "%s: ACK from %s into md %#llx\n", CDEBUG(D_NET, "%s: ACK from %s into md %#llx\n",
...@@ -2030,7 +2030,7 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, ...@@ -2030,7 +2030,7 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
if (!rc) if (!rc)
return 0; return 0;
LASSERT(rc == ENOENT); LASSERT(rc == -ENOENT);
free_drop: free_drop:
LASSERT(!msg->msg_md); LASSERT(!msg->msg_md);
......
...@@ -1085,7 +1085,7 @@ libcfs_str2lnd(const char *str) ...@@ -1085,7 +1085,7 @@ libcfs_str2lnd(const char *str)
if (nf) if (nf)
return nf->nf_type; return nf->nf_type;
return -1; return -ENXIO;
} }
EXPORT_SYMBOL(libcfs_str2lnd); EXPORT_SYMBOL(libcfs_str2lnd);
......
...@@ -1503,7 +1503,7 @@ lnet_nrb_tiny_calculate(void) ...@@ -1503,7 +1503,7 @@ lnet_nrb_tiny_calculate(void)
LCONSOLE_ERROR_MSG(0x10c, LCONSOLE_ERROR_MSG(0x10c,
"tiny_router_buffers=%d invalid when routing enabled\n", "tiny_router_buffers=%d invalid when routing enabled\n",
tiny_router_buffers); tiny_router_buffers);
return -1; return -EINVAL;
} }
if (tiny_router_buffers > 0) if (tiny_router_buffers > 0)
...@@ -1522,7 +1522,7 @@ lnet_nrb_small_calculate(void) ...@@ -1522,7 +1522,7 @@ lnet_nrb_small_calculate(void)
LCONSOLE_ERROR_MSG(0x10c, LCONSOLE_ERROR_MSG(0x10c,
"small_router_buffers=%d invalid when routing enabled\n", "small_router_buffers=%d invalid when routing enabled\n",
small_router_buffers); small_router_buffers);
return -1; return -EINVAL;
} }
if (small_router_buffers > 0) if (small_router_buffers > 0)
...@@ -1541,7 +1541,7 @@ lnet_nrb_large_calculate(void) ...@@ -1541,7 +1541,7 @@ lnet_nrb_large_calculate(void)
LCONSOLE_ERROR_MSG(0x10c, LCONSOLE_ERROR_MSG(0x10c,
"large_router_buffers=%d invalid when routing enabled\n", "large_router_buffers=%d invalid when routing enabled\n",
large_router_buffers); large_router_buffers);
return -1; return -EINVAL;
} }
if (large_router_buffers > 0) if (large_router_buffers > 0)
......
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