*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*
* lnet/lnet/net_fault.c
*
!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
{
struct lnet_drop_rule *rule;
struct lnet_drop_rule *tmp;
- struct list_head zombies;
- int n = 0;
+ LIST_HEAD(zombies);
+ int n = 0;
ENTRY;
- INIT_LIST_HEAD(&zombies);
-
lnet_net_lock(LNET_LOCK_EX);
list_for_each_entry_safe(rule, tmp, &the_lnet.ln_drop_rules, dr_link) {
if (rule->dr_attr.fa_src != src && src != 0)
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;
lnet_nid_t 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,
dst, type, portal))
/* 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);
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_nid2str(ni->ni_nid),
+ libcfs_nid2str(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 */
case LNET_CREDIT_WAIT:
continue;
default: /* failures */
void
lnet_delay_rule_check(void)
{
- struct lnet_delay_rule *rule;
- struct list_head msgs;
+ struct lnet_delay_rule *rule;
+ LIST_HEAD(msgs);
- INIT_LIST_HEAD(&msgs);
while (1) {
if (list_empty(&delay_dd.dd_sched_rules))
break;
lnet_delay_rule_del(lnet_nid_t src, lnet_nid_t dst, bool shutdown)
{
struct lnet_delay_rule *rule;
- struct lnet_delay_rule *tmp;
- struct list_head rule_list;
- struct list_head msg_list;
- int n = 0;
- bool cleanup;
+ struct lnet_delay_rule *tmp;
+ LIST_HEAD(rule_list);
+ LIST_HEAD(msg_list);
+ int n = 0;
+ bool cleanup;
ENTRY;
- INIT_LIST_HEAD(&rule_list);
- INIT_LIST_HEAD(&msg_list);
-
if (shutdown)
src = dst = 0;
int
lnet_fault_init(void)
{
- CLASSERT(LNET_PUT_BIT == 1 << LNET_MSG_PUT);
- CLASSERT(LNET_ACK_BIT == 1 << LNET_MSG_ACK);
- CLASSERT(LNET_GET_BIT == 1 << LNET_MSG_GET);
- CLASSERT(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);