*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*
* lnet/lnet/net_fault.c
*
};
static bool
-lnet_fault_nid_match(lnet_nid_t nid, lnet_nid_t msg_nid)
+lnet_fault_nid_match(lnet_nid_t nid, struct lnet_nid *msg_nid)
{
- if (nid == msg_nid || nid == LNET_NID_ANY)
+ if (nid == LNET_NID_ANY)
+ return true;
+ if (!msg_nid)
+ return false;
+ if (lnet_nid_to_nid4(msg_nid) == nid)
return true;
- if (LNET_NIDNET(nid) != LNET_NIDNET(msg_nid))
+ if (LNET_NIDNET(nid) != LNET_NID_NET(msg_nid))
return false;
/* 255.255.255.255@net is wildcard for all addresses in a network */
}
static bool
-lnet_fault_attr_match(struct lnet_fault_attr *attr, lnet_nid_t src,
- lnet_nid_t local_nid, lnet_nid_t dst,
+lnet_fault_attr_match(struct lnet_fault_attr *attr,
+ struct lnet_nid *src,
+ struct lnet_nid *local_nid,
+ struct lnet_nid *dst,
unsigned int type, unsigned int portal)
{
if (!lnet_fault_nid_match(attr->fa_src, src) ||
!lnet_fault_nid_match(attr->fa_local_nid, local_nid))
return false;
- if (!(attr->fa_msg_mask & (1 << type)))
+ if (!(attr->fa_msg_mask & BIT(type)))
return false;
/* NB: ACK and REPLY have no portal, but they should have been
return;
}
- if (mask & (1 << choice)) {
+ if (mask & BIT(choice)) {
*hstatus = choice;
return;
}
i = HSTATUS_END;
best_delta = HSTATUS_END;
while (i > 0) {
- if (mask & (1 << i)) {
+ if (mask & BIT(i)) {
delta = choice - i;
if (delta < 0)
delta *= -1;
* decide whether should drop this message or not
*/
static bool
-drop_rule_match(struct lnet_drop_rule *rule, lnet_nid_t src,
- lnet_nid_t local_nid, lnet_nid_t dst,
+drop_rule_match(struct lnet_drop_rule *rule,
+ struct lnet_nid *src,
+ struct lnet_nid *local_nid,
+ struct lnet_nid *dst,
unsigned int type, unsigned int portal,
enum lnet_msg_hstatus *hstatus)
{
*/
bool
lnet_drop_rule_match(struct lnet_hdr *hdr,
- lnet_nid_t local_nid,
+ struct lnet_nid *local_nid,
enum lnet_msg_hstatus *hstatus)
{
- lnet_nid_t src = le64_to_cpu(hdr->src_nid);
- lnet_nid_t dst = le64_to_cpu(hdr->dest_nid);
- unsigned int typ = le32_to_cpu(hdr->type);
+ unsigned int typ = hdr->type;
struct lnet_drop_rule *rule;
unsigned int ptl = -1;
bool drop = false;
cpt = lnet_net_lock_current();
list_for_each_entry(rule, &the_lnet.ln_drop_rules, dr_link) {
- drop = drop_rule_match(rule, src, local_nid, dst, typ, ptl,
+ drop = drop_rule_match(rule, &hdr->src_nid, local_nid,
+ &hdr->dest_nid, typ, ptl,
hstatus);
if (drop)
break;
* decide whether should delay this message or not
*/
static bool
-delay_rule_match(struct lnet_delay_rule *rule, lnet_nid_t src,
- lnet_nid_t dst, unsigned int type, unsigned int portal,
- struct lnet_msg *msg)
+delay_rule_match(struct lnet_delay_rule *rule, struct lnet_nid *src,
+ struct lnet_nid *dst, unsigned int type, unsigned int portal,
+ struct lnet_msg *msg)
{
- struct lnet_fault_attr *attr = &rule->dl_attr;
- bool delay;
+ struct lnet_fault_attr *attr = &rule->dl_attr;
+ bool delay;
+ time64_t now = ktime_get_seconds();
- if (!lnet_fault_attr_match(attr, src, LNET_NID_ANY,
+ if (!lnet_fault_attr_match(attr, src, NULL,
dst, type, portal))
return false;
/* match this rule, check delay rate now */
spin_lock(&rule->dl_lock);
if (rule->dl_delay_time != 0) { /* time based delay */
- time64_t now = ktime_get_seconds();
-
rule->dl_stat.fs_count++;
delay = now >= rule->dl_delay_time;
if (delay) {
rule->dl_stat.u.delay.ls_delayed++;
list_add_tail(&msg->msg_list, &rule->dl_msg_list);
- msg->msg_delay_send = ktime_get_seconds() + attr->u.delay.la_latency;
+ msg->msg_delay_send = now + attr->u.delay.la_latency;
if (rule->dl_msg_send == -1) {
rule->dl_msg_send = msg->msg_delay_send;
mod_timer(&rule->dl_timer,
- jiffies + cfs_time_seconds(rule->dl_msg_send));
+ jiffies + cfs_time_seconds(attr->u.delay.la_latency));
}
spin_unlock(&rule->dl_lock);
lnet_delay_rule_match_locked(struct lnet_hdr *hdr, struct lnet_msg *msg)
{
struct lnet_delay_rule *rule;
- lnet_nid_t src = le64_to_cpu(hdr->src_nid);
- lnet_nid_t dst = le64_to_cpu(hdr->dest_nid);
- unsigned int typ = le32_to_cpu(hdr->type);
+ unsigned int typ = hdr->type;
unsigned int ptl = -1;
/* NB: called with hold of lnet_net_lock */
ptl = le32_to_cpu(hdr->msg.get.ptl_index);
list_for_each_entry(rule, &the_lnet.ln_delay_rules, dl_link) {
- if (delay_rule_match(rule, src, dst, typ, ptl, msg))
+ if (delay_rule_match(rule, &hdr->src_nid, &hdr->dest_nid,
+ typ, ptl, msg))
return true;
}
struct lnet_msg *tmp;
time64_t now = ktime_get_seconds();
- if (!all && cfs_time_seconds(rule->dl_msg_send) > now)
+ if (!all && rule->dl_msg_send > now)
return;
spin_lock(&rule->dl_lock);
struct lnet_msg, msg_list);
rule->dl_msg_send = msg->msg_delay_send;
mod_timer(&rule->dl_timer,
- jiffies + cfs_time_seconds(rule->dl_msg_send));
+ jiffies +
+ cfs_time_seconds(msg->msg_delay_send - now));
}
spin_unlock(&rule->dl_lock);
}
int rc;
msg = list_entry(msg_list->next, struct lnet_msg, msg_list);
+
+ if (msg->msg_sending) {
+ /* Delayed send */
+ list_del_init(&msg->msg_list);
+ ni = msg->msg_txni;
+ CDEBUG(D_NET, "TRACE: msg %p %s -> %s : %s\n", msg,
+ libcfs_nidstr(&ni->ni_nid),
+ libcfs_nidstr(&msg->msg_txpeer->lpni_nid),
+ lnet_msgtyp2str(msg->msg_type));
+ lnet_ni_send(ni, msg);
+ continue;
+ }
+
+ /* Delayed receive */
LASSERT(msg->msg_rxpeer != NULL);
LASSERT(msg->msg_rxni != NULL);
case LNET_CREDIT_OK:
lnet_ni_recv(ni, msg->msg_private, msg, 0,
0, msg->msg_len, msg->msg_len);
- /* fallthrough */
+ fallthrough;
case LNET_CREDIT_WAIT:
continue;
default: /* failures */
int
lnet_fault_init(void)
{
- BUILD_BUG_ON(LNET_PUT_BIT != 1 << LNET_MSG_PUT);
- BUILD_BUG_ON(LNET_ACK_BIT != 1 << LNET_MSG_ACK);
- BUILD_BUG_ON(LNET_GET_BIT != 1 << LNET_MSG_GET);
- BUILD_BUG_ON(LNET_REPLY_BIT != 1 << LNET_MSG_REPLY);
+ BUILD_BUG_ON(LNET_PUT_BIT != BIT(LNET_MSG_PUT));
+ BUILD_BUG_ON(LNET_ACK_BIT != BIT(LNET_MSG_ACK));
+ BUILD_BUG_ON(LNET_GET_BIT != BIT(LNET_MSG_GET));
+ BUILD_BUG_ON(LNET_REPLY_BIT != BIT(LNET_MSG_REPLY));
mutex_init(&delay_dd.dd_mutex);
spin_lock_init(&delay_dd.dd_lock);