* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2012, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
{
unsigned int nob = 0;
+ LASSERT(niov == 0 || iov != NULL);
while (niov-- > 0)
nob += (iov++)->iov_len;
{
unsigned int nob = 0;
+ LASSERT(niov == 0 || kiov != NULL);
while (niov-- > 0)
nob += (kiov++)->kiov_len;
unsigned int nsiov, lnet_kiov_t *siov, unsigned int soffset,
unsigned int nob)
{
- /* NB diov, siov are READ-ONLY */
- unsigned int this_nob;
- char *daddr = NULL;
- char *saddr = NULL;
+ /* NB diov, siov are READ-ONLY */
+ unsigned int this_nob;
+ char *daddr = NULL;
+ char *saddr = NULL;
- if (nob == 0)
- return;
+ if (nob == 0)
+ return;
- LASSERT (!cfs_in_interrupt ());
+ LASSERT (!in_interrupt ());
- LASSERT (ndiov > 0);
+ LASSERT (ndiov > 0);
while (doffset >= diov->kiov_len) {
doffset -= diov->kiov_len;
diov++;
siov->kiov_len - soffset);
this_nob = MIN(this_nob, nob);
- if (daddr == NULL)
- daddr = ((char *)cfs_kmap(diov->kiov_page)) +
- diov->kiov_offset + doffset;
- if (saddr == NULL)
- saddr = ((char *)cfs_kmap(siov->kiov_page)) +
- siov->kiov_offset + soffset;
+ if (daddr == NULL)
+ daddr = ((char *)kmap(diov->kiov_page)) +
+ diov->kiov_offset + doffset;
+ if (saddr == NULL)
+ saddr = ((char *)kmap(siov->kiov_page)) +
+ siov->kiov_offset + soffset;
- /* Vanishing risk of kmap deadlock when mapping 2 pages.
- * However in practice at least one of the kiovs will be mapped
- * kernel pages and the map/unmap will be NOOPs */
+ /* Vanishing risk of kmap deadlock when mapping 2 pages.
+ * However in practice at least one of the kiovs will be mapped
+ * kernel pages and the map/unmap will be NOOPs */
- memcpy (daddr, saddr, this_nob);
- nob -= this_nob;
+ memcpy (daddr, saddr, this_nob);
+ nob -= this_nob;
- if (diov->kiov_len > doffset + this_nob) {
- daddr += this_nob;
- doffset += this_nob;
- } else {
- cfs_kunmap(diov->kiov_page);
- daddr = NULL;
- diov++;
- ndiov--;
- doffset = 0;
- }
+ if (diov->kiov_len > doffset + this_nob) {
+ daddr += this_nob;
+ doffset += this_nob;
+ } else {
+ kunmap(diov->kiov_page);
+ daddr = NULL;
+ diov++;
+ ndiov--;
+ doffset = 0;
+ }
- if (siov->kiov_len > soffset + this_nob) {
- saddr += this_nob;
- soffset += this_nob;
- } else {
- cfs_kunmap(siov->kiov_page);
- saddr = NULL;
- siov++;
- nsiov--;
- soffset = 0;
- }
- } while (nob > 0);
+ if (siov->kiov_len > soffset + this_nob) {
+ saddr += this_nob;
+ soffset += this_nob;
+ } else {
+ kunmap(siov->kiov_page);
+ saddr = NULL;
+ siov++;
+ nsiov--;
+ soffset = 0;
+ }
+ } while (nob > 0);
- if (daddr != NULL)
- cfs_kunmap(diov->kiov_page);
- if (saddr != NULL)
- cfs_kunmap(siov->kiov_page);
+ if (daddr != NULL)
+ kunmap(diov->kiov_page);
+ if (saddr != NULL)
+ kunmap(siov->kiov_page);
}
EXPORT_SYMBOL(lnet_copy_kiov2kiov);
unsigned int nkiov, lnet_kiov_t *kiov, unsigned int kiovoffset,
unsigned int nob)
{
- /* NB iov, kiov are READ-ONLY */
- unsigned int this_nob;
- char *addr = NULL;
+ /* NB iov, kiov are READ-ONLY */
+ unsigned int this_nob;
+ char *addr = NULL;
- if (nob == 0)
- return;
+ if (nob == 0)
+ return;
- LASSERT (!cfs_in_interrupt ());
+ LASSERT (!in_interrupt ());
- LASSERT (niov > 0);
+ LASSERT (niov > 0);
while (iovoffset >= iov->iov_len) {
iovoffset -= iov->iov_len;
iov++;
this_nob = MIN(this_nob, nob);
if (addr == NULL)
- addr = ((char *)cfs_kmap(kiov->kiov_page)) +
+ addr = ((char *)kmap(kiov->kiov_page)) +
kiov->kiov_offset + kiovoffset;
memcpy ((char *)iov->iov_base + iovoffset, addr, this_nob);
addr += this_nob;
kiovoffset += this_nob;
} else {
- cfs_kunmap(kiov->kiov_page);
- addr = NULL;
- kiov++;
- nkiov--;
- kiovoffset = 0;
- }
+ kunmap(kiov->kiov_page);
+ addr = NULL;
+ kiov++;
+ nkiov--;
+ kiovoffset = 0;
+ }
- } while (nob > 0);
+ } while (nob > 0);
- if (addr != NULL)
- cfs_kunmap(kiov->kiov_page);
+ if (addr != NULL)
+ kunmap(kiov->kiov_page);
}
EXPORT_SYMBOL(lnet_copy_kiov2iov);
unsigned int niov, struct iovec *iov, unsigned int iovoffset,
unsigned int nob)
{
- /* NB kiov, iov are READ-ONLY */
- unsigned int this_nob;
- char *addr = NULL;
+ /* NB kiov, iov are READ-ONLY */
+ unsigned int this_nob;
+ char *addr = NULL;
- if (nob == 0)
- return;
+ if (nob == 0)
+ return;
- LASSERT (!cfs_in_interrupt ());
+ LASSERT (!in_interrupt ());
- LASSERT (nkiov > 0);
+ LASSERT (nkiov > 0);
while (kiovoffset >= kiov->kiov_len) {
kiovoffset -= kiov->kiov_len;
kiov++;
this_nob = MIN(this_nob, nob);
if (addr == NULL)
- addr = ((char *)cfs_kmap(kiov->kiov_page)) +
- kiov->kiov_offset + kiovoffset;
+ addr = ((char *)kmap(kiov->kiov_page)) +
+ kiov->kiov_offset + kiovoffset;
- memcpy (addr, (char *)iov->iov_base + iovoffset, this_nob);
- nob -= this_nob;
+ memcpy (addr, (char *)iov->iov_base + iovoffset, this_nob);
+ nob -= this_nob;
- if (kiov->kiov_len > kiovoffset + this_nob) {
- addr += this_nob;
- kiovoffset += this_nob;
- } else {
- cfs_kunmap(kiov->kiov_page);
- addr = NULL;
- kiov++;
- nkiov--;
- kiovoffset = 0;
- }
+ if (kiov->kiov_len > kiovoffset + this_nob) {
+ addr += this_nob;
+ kiovoffset += this_nob;
+ } else {
+ kunmap(kiov->kiov_page);
+ addr = NULL;
+ kiov++;
+ nkiov--;
+ kiovoffset = 0;
+ }
- if (iov->iov_len > iovoffset + this_nob) {
- iovoffset += this_nob;
- } else {
- iov++;
- niov--;
- iovoffset = 0;
- }
- } while (nob > 0);
+ if (iov->iov_len > iovoffset + this_nob) {
+ iovoffset += this_nob;
+ } else {
+ iov++;
+ niov--;
+ iovoffset = 0;
+ }
+ } while (nob > 0);
- if (addr != NULL)
- cfs_kunmap(kiov->kiov_page);
+ if (addr != NULL)
+ kunmap(kiov->kiov_page);
}
EXPORT_SYMBOL(lnet_copy_iov2kiov);
dst->kiov_page = src->kiov_page;
dst->kiov_offset = src->kiov_offset + offset;
- if (len <= frag_len) {
- dst->kiov_len = len;
- LASSERT (dst->kiov_offset + dst->kiov_len <= CFS_PAGE_SIZE);
- return (niov);
- }
+ if (len <= frag_len) {
+ dst->kiov_len = len;
+ LASSERT (dst->kiov_offset + dst->kiov_len <= PAGE_CACHE_SIZE);
+ return niov;
+ }
- dst->kiov_len = frag_len;
- LASSERT (dst->kiov_offset + dst->kiov_len <= CFS_PAGE_SIZE);
+ dst->kiov_len = frag_len;
+ LASSERT (dst->kiov_offset + dst->kiov_len <= PAGE_CACHE_SIZE);
len -= frag_len;
dst++;
lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
unsigned int offset, unsigned int mlen, unsigned int rlen)
{
- unsigned int niov = 0;
- struct iovec *iov = NULL;
- lnet_kiov_t *kiov = NULL;
- int rc;
+ unsigned int niov = 0;
+ struct iovec *iov = NULL;
+ lnet_kiov_t *kiov = NULL;
+ int rc;
- LASSERT (!cfs_in_interrupt ());
- LASSERT (mlen == 0 || msg != NULL);
+ LASSERT (!in_interrupt ());
+ LASSERT (mlen == 0 || msg != NULL);
if (msg != NULL) {
LASSERT(msg->msg_receiving);
void
lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg)
{
- void *priv = msg->msg_private;
- int rc;
+ void *priv = msg->msg_private;
+ int rc;
- LASSERT (!cfs_in_interrupt ());
- LASSERT (LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND ||
- (msg->msg_txcredit && msg->msg_peertxcredit));
+ LASSERT (!in_interrupt ());
+ LASSERT (LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND ||
+ (msg->msg_txcredit && msg->msg_peertxcredit));
- rc = (ni->ni_lnd->lnd_send)(ni, priv, msg);
- if (rc < 0)
- lnet_finalize(ni, msg, rc);
+ rc = (ni->ni_lnd->lnd_send)(ni, priv, msg);
+ if (rc < 0)
+ lnet_finalize(ni, msg, rc);
}
int
void
lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp)
{
- cfs_time_t last_alive = 0;
+ cfs_time_t last_alive = 0;
LASSERT(lnet_peer_aliveness_enabled(lp));
LASSERT(ni->ni_lnd->lnd_query != NULL);
- LASSERT(the_lnet.ln_routing == 1);
lnet_net_unlock(lp->lp_cpt);
(ni->ni_lnd->lnd_query)(ni, lp->lp_nid, &last_alive);
cfs_time_t deadline;
LASSERT (lnet_peer_aliveness_enabled(lp));
- LASSERT (the_lnet.ln_routing == 1);
/* Trust lnet_notify() if it has more recent aliveness news, but
* ignore the initial assumed death (see lnet_peers_start_down()).
{
cfs_time_t now = cfs_time_current();
- /* LU-630: only router checks peer health. */
- if (the_lnet.ln_routing == 0)
- return 1;
-
if (!lnet_peer_aliveness_enabled(lp))
return -ENODEV;
rbp = &the_lnet.ln_rtrpools[cpt][0];
LASSERT(msg->msg_len <= LNET_MTU);
- while (msg->msg_len > (unsigned int)rbp->rbp_npages * CFS_PAGE_SIZE) {
+ while (msg->msg_len > (unsigned int)rbp->rbp_npages * PAGE_CACHE_SIZE) {
rbp++;
LASSERT(rbp < &the_lnet.ln_rtrpools[cpt][LNET_NRBPOOLS]);
}
lnet_peer_t *p1 = r1->lr_gateway;
lnet_peer_t *p2 = r2->lr_gateway;
+ if (r1->lr_priority < r2->lr_priority)
+ return 1;
+
+ if (r1->lr_priority > r2->lr_priority)
+ return -1;
+
if (r1->lr_hops < r2->lr_hops)
return 1;
lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid)
{
lnet_remotenet_t *rnet;
- lnet_route_t *rtr;
- lnet_route_t *rtr_best;
- lnet_route_t *rtr_last;
+ lnet_route_t *route;
+ lnet_route_t *best_route;
+ lnet_route_t *last_route;
struct lnet_peer *lp_best;
struct lnet_peer *lp;
int rc;
return NULL;
lp_best = NULL;
- rtr_best = rtr_last = NULL;
- cfs_list_for_each_entry(rtr, &rnet->lrn_routes, lr_list) {
- lp = rtr->lr_gateway;
+ best_route = last_route = NULL;
+ cfs_list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
+ lp = route->lr_gateway;
- if (!lp->lp_alive || /* gateway is down */
- ((lp->lp_ping_feats & LNET_PING_FEAT_NI_STATUS) != 0 &&
- rtr->lr_downis != 0)) /* NI to target is down */
+ if (!lnet_is_route_alive(route))
continue;
if (ni != NULL && lp->lp_ni != ni)
return lp;
if (lp_best == NULL) {
- rtr_best = rtr_last = rtr;
+ best_route = last_route = route;
lp_best = lp;
continue;
}
/* no protection on below fields, but it's harmless */
- if (rtr_last->lr_seq - rtr->lr_seq < 0)
- rtr_last = rtr;
+ if (last_route->lr_seq - route->lr_seq < 0)
+ last_route = route;
- rc = lnet_compare_routes(rtr, rtr_best);
+ rc = lnet_compare_routes(route, best_route);
if (rc < 0)
continue;
- rtr_best = rtr;
+ best_route = route;
lp_best = lp;
}
/* set sequence number on the best router to the latest sequence + 1
* so we can round-robin all routers, it's race and inaccurate but
* harmless and functional */
- if (rtr_best != NULL)
- rtr_best->lr_seq = rtr_last->lr_seq + 1;
+ if (best_route != NULL)
+ best_route->lr_seq = last_route->lr_seq + 1;
return lp_best;
}
struct lnet_msg *msg;
lnet_pid_t dest_pid;
lnet_nid_t dest_nid;
- lnet_nid_t src_nid;
- __u32 payload_length;
- __u32 type;
+ lnet_nid_t src_nid;
+ __u32 payload_length;
+ __u32 type;
- LASSERT (!cfs_in_interrupt ());
+ LASSERT (!in_interrupt ());
- type = le32_to_cpu(hdr->type);
- src_nid = le64_to_cpu(hdr->src_nid);
- dest_nid = le64_to_cpu(hdr->dest_nid);
- dest_pid = le32_to_cpu(hdr->dest_pid);
+ type = le32_to_cpu(hdr->type);
+ src_nid = le64_to_cpu(hdr->src_nid);
+ dest_nid = le64_to_cpu(hdr->dest_nid);
+ dest_pid = le32_to_cpu(hdr->dest_pid);
payload_length = le32_to_cpu(hdr->payload_length);
for_me = (ni->ni_nid == dest_nid);
libcfs_id2str(target));
return -ENOMEM;
}
- msg->msg_vmflush = !!cfs_memory_pressure_get();
+ msg->msg_vmflush = !!memory_pressure_get();
cpt = lnet_cpt_of_cookie(mdh.cookie);
lnet_res_lock(cpt);