From 98a0e329b7dbd75e2990176d40e0501feb179fc1 Mon Sep 17 00:00:00 2001 From: eeb Date: Tue, 21 Oct 2003 16:28:03 +0000 Subject: [PATCH] * Stopped outputting error messages on lctl set_route, when isn't know. This was a no-op, now it's a silent no-op. * Fixed help string in lctl. * Fixed lctl set_route date+time parsing bug. --- lnet/libcfs/module.c | 5 ++++- lnet/router/router.c | 22 +++++++++++----------- lnet/utils/portals.c | 4 ++-- lustre/portals/libcfs/module.c | 5 ++++- lustre/portals/router/router.c | 22 +++++++++++----------- lustre/portals/utils/portals.c | 4 ++-- lustre/utils/lctl.c | 2 +- 7 files changed, 35 insertions(+), 29 deletions(-) diff --git a/lnet/libcfs/module.c b/lnet/libcfs/module.c index 11e4f4c..586b675 100644 --- a/lnet/libcfs/module.c +++ b/lnet/libcfs/module.c @@ -162,9 +162,12 @@ kportal_notify_router (int gw_nalid, ptl_nid_t gw_nid, int rc; kpr_control_interface_t *ci; + /* No error if router not preset. Sysadmin is allowed to notify + * _everywhere_ when a NID boots or crashes, even if they know + * nothing of the peer. */ ci = (kpr_control_interface_t *)PORTAL_SYMBOL_GET(kpr_control_interface); if (ci == NULL) - return (-ENODEV); + return (0); rc = ci->kprci_notify (gw_nalid, gw_nid, alive, when); diff --git a/lnet/router/router.c b/lnet/router/router.c index 32f741f..f082415 100644 --- a/lnet/router/router.c +++ b/lnet/router/router.c @@ -149,14 +149,14 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, int alive, time_t when) { unsigned long flags; - int rc = -ENOENT; + int found; kpr_nal_entry_t *ne = NULL; kpr_gateway_entry_t *ge = NULL; struct timeval now; struct list_head *e; struct list_head *n; - CDEBUG (D_ERROR, "%s notifying [%d] "LPX64": %s\n", + CDEBUG (D_NET, "%s notifying [%d] "LPX64": %s\n", byNal ? "NAL" : "userspace", gateway_nalid, gateway_nid, alive ? "up" : "down"); @@ -177,6 +177,7 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, /* Serialise with lookups (i.e. write lock) */ write_lock_irqsave(&kpr_rwlock, flags); + found = 0; list_for_each_safe (e, n, &kpr_gateways) { ge = list_entry(e, kpr_gateway_entry_t, kpge_list); @@ -185,15 +186,15 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, ge->kpge_nid != gateway_nid) continue; - rc = 0; + found = 1; break; } - if (rc != 0) { + if (!found) { /* gateway not found */ write_unlock_irqrestore(&kpr_rwlock, flags); CDEBUG (D_NET, "Gateway not found\n"); - return (rc); + return (0); } if (when < ge->kpge_timestamp) { @@ -226,25 +227,24 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, } } + found = 0; if (!byNal) { /* userland notified me: notify NAL? */ ne = kpr_find_nal_entry_locked (ge->kpge_nalid); if (ne != NULL) { - if (ne->kpne_shutdown || - ne->kpne_interface.kprni_notify == NULL) { - /* no need to notify */ - ne = NULL; - } else { + if (!ne->kpne_shutdown && + ne->kpne_interface.kprni_notify != NULL) { /* take a ref on this NAL until notifying * it has completed... */ atomic_inc (&ne->kpne_refcount); + found = 1; } } } write_unlock_irqrestore(&kpr_rwlock, flags); - if (ne != NULL) { + if (found) { ne->kpne_interface.kprni_notify (ne->kpne_interface.kprni_arg, gateway_nid, alive); /* 'ne' can disappear now... */ diff --git a/lnet/utils/portals.c b/lnet/utils/portals.c index 2d1a0b5..eb53305 100644 --- a/lnet/utils/portals.c +++ b/lnet/utils/portals.c @@ -154,7 +154,7 @@ ptl_parse_time (time_t *t, char *str) return (0); memset (&tm, 0, sizeof (tm)); - n = sscanf (str, "%d-%d-%d %d:%d:%d", + n = sscanf (str, "%d-%d-%d-%d:%d:%d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec); if (n != 6) @@ -1338,7 +1338,7 @@ jt_ptl_notify_router (int argc, char **argv) when = now.tv_sec; } else if (ptl_parse_time (&when, argv[3]) != 0) { fprintf(stderr, "Can't parse time %s\n" - "Please specify either 'YYYY-MM-DD HH:MM:SS'\n" + "Please specify either 'YYYY-MM-DD-HH:MM:SS'\n" "or an absolute unix time in seconds\n", argv[3]); return (-1); } else if (when > now.tv_sec) { diff --git a/lustre/portals/libcfs/module.c b/lustre/portals/libcfs/module.c index 11e4f4c..586b675 100644 --- a/lustre/portals/libcfs/module.c +++ b/lustre/portals/libcfs/module.c @@ -162,9 +162,12 @@ kportal_notify_router (int gw_nalid, ptl_nid_t gw_nid, int rc; kpr_control_interface_t *ci; + /* No error if router not preset. Sysadmin is allowed to notify + * _everywhere_ when a NID boots or crashes, even if they know + * nothing of the peer. */ ci = (kpr_control_interface_t *)PORTAL_SYMBOL_GET(kpr_control_interface); if (ci == NULL) - return (-ENODEV); + return (0); rc = ci->kprci_notify (gw_nalid, gw_nid, alive, when); diff --git a/lustre/portals/router/router.c b/lustre/portals/router/router.c index 32f741f..f082415 100644 --- a/lustre/portals/router/router.c +++ b/lustre/portals/router/router.c @@ -149,14 +149,14 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, int alive, time_t when) { unsigned long flags; - int rc = -ENOENT; + int found; kpr_nal_entry_t *ne = NULL; kpr_gateway_entry_t *ge = NULL; struct timeval now; struct list_head *e; struct list_head *n; - CDEBUG (D_ERROR, "%s notifying [%d] "LPX64": %s\n", + CDEBUG (D_NET, "%s notifying [%d] "LPX64": %s\n", byNal ? "NAL" : "userspace", gateway_nalid, gateway_nid, alive ? "up" : "down"); @@ -177,6 +177,7 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, /* Serialise with lookups (i.e. write lock) */ write_lock_irqsave(&kpr_rwlock, flags); + found = 0; list_for_each_safe (e, n, &kpr_gateways) { ge = list_entry(e, kpr_gateway_entry_t, kpge_list); @@ -185,15 +186,15 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, ge->kpge_nid != gateway_nid) continue; - rc = 0; + found = 1; break; } - if (rc != 0) { + if (!found) { /* gateway not found */ write_unlock_irqrestore(&kpr_rwlock, flags); CDEBUG (D_NET, "Gateway not found\n"); - return (rc); + return (0); } if (when < ge->kpge_timestamp) { @@ -226,25 +227,24 @@ kpr_do_notify (int byNal, int gateway_nalid, ptl_nid_t gateway_nid, } } + found = 0; if (!byNal) { /* userland notified me: notify NAL? */ ne = kpr_find_nal_entry_locked (ge->kpge_nalid); if (ne != NULL) { - if (ne->kpne_shutdown || - ne->kpne_interface.kprni_notify == NULL) { - /* no need to notify */ - ne = NULL; - } else { + if (!ne->kpne_shutdown && + ne->kpne_interface.kprni_notify != NULL) { /* take a ref on this NAL until notifying * it has completed... */ atomic_inc (&ne->kpne_refcount); + found = 1; } } } write_unlock_irqrestore(&kpr_rwlock, flags); - if (ne != NULL) { + if (found) { ne->kpne_interface.kprni_notify (ne->kpne_interface.kprni_arg, gateway_nid, alive); /* 'ne' can disappear now... */ diff --git a/lustre/portals/utils/portals.c b/lustre/portals/utils/portals.c index 2d1a0b5..eb53305 100644 --- a/lustre/portals/utils/portals.c +++ b/lustre/portals/utils/portals.c @@ -154,7 +154,7 @@ ptl_parse_time (time_t *t, char *str) return (0); memset (&tm, 0, sizeof (tm)); - n = sscanf (str, "%d-%d-%d %d:%d:%d", + n = sscanf (str, "%d-%d-%d-%d:%d:%d", &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec); if (n != 6) @@ -1338,7 +1338,7 @@ jt_ptl_notify_router (int argc, char **argv) when = now.tv_sec; } else if (ptl_parse_time (&when, argv[3]) != 0) { fprintf(stderr, "Can't parse time %s\n" - "Please specify either 'YYYY-MM-DD HH:MM:SS'\n" + "Please specify either 'YYYY-MM-DD-HH:MM:SS'\n" "or an absolute unix time in seconds\n", argv[3]); return (-1); } else if (when > now.tv_sec) { diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 2c5852b..322ad63 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -101,7 +101,7 @@ command_t cmdlist[] = { "usage: del_route [] []"}, {"set_route", jt_ptl_notify_router, 0, "enable/disable routes via the given gateway in the portals routing table\n" - "usage: set_gw [