Commit e75fb87f authored by Doug Oucharek's avatar Doug Oucharek Committed by Greg Kroah-Hartman

staging/lustre/lnet: Add LNet Router Priority parameter

This change adds a priority parameter to the route module settings.
This paramter can be >= 0. Like hops, the lower the prioirty number
the higher the priority.  So lower numbered priorities will be
selected over higher numbers.

Lustre-change: http://review.whamcloud.com/5663
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2934Signed-off-by: default avatarDoug Oucharek <doug.s.oucharek@intel.com>
Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Reviewed-by: default avatarAmir Shehata <amir.shehata@intel.com>
Reviewed-by: default avatarIsaac Huang <he.huang@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarPeng Tao <bergwolf@gmail.com>
Signed-off-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 32d3b6de
...@@ -69,6 +69,7 @@ struct libcfs_ioctl_data { ...@@ -69,6 +69,7 @@ struct libcfs_ioctl_data {
char ioc_bulk[0]; char ioc_bulk[0];
}; };
#define ioc_priority ioc_u32[0]
struct libcfs_ioctl_hdr { struct libcfs_ioctl_hdr {
__u32 ioc_len; __u32 ioc_len;
......
...@@ -650,12 +650,13 @@ extern lnet_ni_t *lnet_net2ni(__u32 net); ...@@ -650,12 +650,13 @@ extern lnet_ni_t *lnet_net2ni(__u32 net);
int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, cfs_time_t when); int lnet_notify(lnet_ni_t *ni, lnet_nid_t peer, int alive, cfs_time_t when);
void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, cfs_time_t when); void lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, cfs_time_t when);
int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway_nid); int lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway_nid,
unsigned int priority);
int lnet_check_routes(void); int lnet_check_routes(void);
int lnet_del_route(__u32 net, lnet_nid_t gw_nid); int lnet_del_route(__u32 net, lnet_nid_t gw_nid);
void lnet_destroy_routes(void); void lnet_destroy_routes(void);
int lnet_get_route(int idx, __u32 *net, __u32 *hops, int lnet_get_route(int idx, __u32 *net, __u32 *hops,
lnet_nid_t *gateway, __u32 *alive); lnet_nid_t *gateway, __u32 *alive, __u32 *priority);
void lnet_proc_init(void); void lnet_proc_init(void);
void lnet_proc_fini(void); void lnet_proc_fini(void);
int lnet_rtrpools_alloc(int im_a_router); int lnet_rtrpools_alloc(int im_a_router);
......
...@@ -478,7 +478,6 @@ typedef struct lnet_peer { ...@@ -478,7 +478,6 @@ typedef struct lnet_peer {
lnet_rc_data_t *lp_rcd; /* router checker state */ lnet_rc_data_t *lp_rcd; /* router checker state */
} lnet_peer_t; } lnet_peer_t;
/* peer hash size */ /* peer hash size */
#define LNET_PEER_HASH_BITS 9 #define LNET_PEER_HASH_BITS 9
#define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS) #define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS)
...@@ -504,6 +503,7 @@ typedef struct { ...@@ -504,6 +503,7 @@ typedef struct {
int lr_seq; /* sequence for round-robin */ int lr_seq; /* sequence for round-robin */
unsigned int lr_downis; /* number of down NIs */ unsigned int lr_downis; /* number of down NIs */
unsigned int lr_hops; /* how far I am */ unsigned int lr_hops; /* how far I am */
unsigned int lr_priority; /* route priority */
} lnet_route_t; } lnet_route_t;
#define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7) #define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)
......
...@@ -1436,7 +1436,7 @@ LNetCtl(unsigned int cmd, void *arg) ...@@ -1436,7 +1436,7 @@ LNetCtl(unsigned int cmd, void *arg)
case IOC_LIBCFS_ADD_ROUTE: case IOC_LIBCFS_ADD_ROUTE:
rc = lnet_add_route(data->ioc_net, data->ioc_count, rc = lnet_add_route(data->ioc_net, data->ioc_count,
data->ioc_nid); data->ioc_nid, data->ioc_priority);
return (rc != 0) ? rc : lnet_check_routes(); return (rc != 0) ? rc : lnet_check_routes();
case IOC_LIBCFS_DEL_ROUTE: case IOC_LIBCFS_DEL_ROUTE:
...@@ -1445,7 +1445,8 @@ LNetCtl(unsigned int cmd, void *arg) ...@@ -1445,7 +1445,8 @@ LNetCtl(unsigned int cmd, void *arg)
case IOC_LIBCFS_GET_ROUTE: case IOC_LIBCFS_GET_ROUTE:
return lnet_get_route(data->ioc_count, return lnet_get_route(data->ioc_count,
&data->ioc_net, &data->ioc_count, &data->ioc_net, &data->ioc_count,
&data->ioc_nid, &data->ioc_flags); &data->ioc_nid, &data->ioc_flags,
&data->ioc_priority);
case IOC_LIBCFS_NOTIFY_ROUTER: case IOC_LIBCFS_NOTIFY_ROUTER:
return lnet_notify(NULL, data->ioc_nid, data->ioc_flags, return lnet_notify(NULL, data->ioc_nid, data->ioc_flags,
cfs_time_current() - cfs_time_current() -
......
...@@ -603,6 +603,37 @@ lnet_parse_hops(char *str, unsigned int *hops) ...@@ -603,6 +603,37 @@ lnet_parse_hops(char *str, unsigned int *hops)
*hops > 0 && *hops < 256); *hops > 0 && *hops < 256);
} }
#define LNET_PRIORITY_SEPARATOR (':')
int
lnet_parse_priority(char *str, unsigned int *priority, char **token)
{
int nob;
char *sep;
int len;
sep = strchr(str, LNET_PRIORITY_SEPARATOR);
if (sep == NULL) {
*priority = 0;
return 0;
}
len = strlen(sep + 1);
if ((sscanf((sep+1), "%u%n", priority, &nob) < 1) || (len != nob)) {
/* Update the caller's token pointer so it treats the found
priority as the token to report in the error message. */
*token += sep - str + 1;
return -1;
}
CDEBUG(D_NET, "gateway %s, priority %d, nob %d\n", str, *priority, nob);
/*
* Change priority separator to \0 to be able to parse NID
*/
*sep = '\0';
return 0;
}
int int
lnet_parse_route(char *str, int *im_a_router) lnet_parse_route(char *str, int *im_a_router)
...@@ -624,6 +655,7 @@ lnet_parse_route(char *str, int *im_a_router) ...@@ -624,6 +655,7 @@ lnet_parse_route(char *str, int *im_a_router)
int myrc = -1; int myrc = -1;
unsigned int hops; unsigned int hops;
int got_hops = 0; int got_hops = 0;
unsigned int priority = 0;
INIT_LIST_HEAD(&gateways); INIT_LIST_HEAD(&gateways);
INIT_LIST_HEAD(&nets); INIT_LIST_HEAD(&nets);
...@@ -691,6 +723,11 @@ lnet_parse_route(char *str, int *im_a_router) ...@@ -691,6 +723,11 @@ lnet_parse_route(char *str, int *im_a_router)
LNET_NETTYP(net) == LOLND) LNET_NETTYP(net) == LOLND)
goto token_error; goto token_error;
} else { } else {
rc = lnet_parse_priority(ltb->ltb_text,
&priority, &token);
if (rc < 0)
goto token_error;
nid = libcfs_str2nid(ltb->ltb_text); nid = libcfs_str2nid(ltb->ltb_text);
if (nid == LNET_NID_ANY || if (nid == LNET_NID_ANY ||
LNET_NETTYP(LNET_NIDNET(nid)) == LOLND) LNET_NETTYP(LNET_NIDNET(nid)) == LOLND)
...@@ -720,7 +757,7 @@ lnet_parse_route(char *str, int *im_a_router) ...@@ -720,7 +757,7 @@ lnet_parse_route(char *str, int *im_a_router)
continue; continue;
} }
rc = lnet_add_route(net, hops, nid); rc = lnet_add_route(net, hops, nid, priority);
if (rc != 0) { if (rc != 0) {
CERROR("Can't create route to %s via %s\n", CERROR("Can't create route to %s via %s\n",
libcfs_net2str(net), libcfs_net2str(net),
......
...@@ -1074,6 +1074,12 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2) ...@@ -1074,6 +1074,12 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2)
lnet_peer_t *p1 = r1->lr_gateway; lnet_peer_t *p1 = r1->lr_gateway;
lnet_peer_t *p2 = r2->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) if (r1->lr_hops < r2->lr_hops)
return 1; return 1;
......
...@@ -301,7 +301,8 @@ lnet_add_route_to_rnet (lnet_remotenet_t *rnet, lnet_route_t *route) ...@@ -301,7 +301,8 @@ lnet_add_route_to_rnet (lnet_remotenet_t *rnet, lnet_route_t *route)
} }
int int
lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway) lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
unsigned int priority)
{ {
struct list_head *e; struct list_head *e;
lnet_remotenet_t *rnet; lnet_remotenet_t *rnet;
...@@ -311,8 +312,8 @@ lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway) ...@@ -311,8 +312,8 @@ lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway)
int add_route; int add_route;
int rc; int rc;
CDEBUG(D_NET, "Add route: net %s hops %u gw %s\n", CDEBUG(D_NET, "Add route: net %s hops %u priority %u gw %s\n",
libcfs_net2str(net), hops, libcfs_nid2str(gateway)); libcfs_net2str(net), hops, priority, libcfs_nid2str(gateway));
if (gateway == LNET_NID_ANY || if (gateway == LNET_NID_ANY ||
LNET_NETTYP(LNET_NIDNET(gateway)) == LOLND || LNET_NETTYP(LNET_NIDNET(gateway)) == LOLND ||
...@@ -342,6 +343,7 @@ lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway) ...@@ -342,6 +343,7 @@ lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway)
rnet->lrn_net = net; rnet->lrn_net = net;
route->lr_hops = hops; route->lr_hops = hops;
route->lr_net = net; route->lr_net = net;
route->lr_priority = priority;
lnet_net_lock(LNET_LOCK_EX); lnet_net_lock(LNET_LOCK_EX);
...@@ -552,7 +554,7 @@ lnet_destroy_routes (void) ...@@ -552,7 +554,7 @@ lnet_destroy_routes (void)
int int
lnet_get_route(int idx, __u32 *net, __u32 *hops, lnet_get_route(int idx, __u32 *net, __u32 *hops,
lnet_nid_t *gateway, __u32 *alive) lnet_nid_t *gateway, __u32 *alive, __u32 *priority)
{ {
struct list_head *e1; struct list_head *e1;
struct list_head *e2; struct list_head *e2;
...@@ -576,6 +578,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops, ...@@ -576,6 +578,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops,
if (idx-- == 0) { if (idx-- == 0) {
*net = rnet->lrn_net; *net = rnet->lrn_net;
*hops = route->lr_hops; *hops = route->lr_hops;
*priority = route->lr_priority;
*gateway = route->lr_gateway->lp_nid; *gateway = route->lr_gateway->lp_nid;
*alive = route->lr_gateway->lp_alive; *alive = route->lr_gateway->lp_alive;
lnet_net_unlock(cpt); lnet_net_unlock(cpt);
......
...@@ -174,8 +174,8 @@ int LL_PROC_PROTO(proc_lnet_routes) ...@@ -174,8 +174,8 @@ int LL_PROC_PROTO(proc_lnet_routes)
the_lnet.ln_routing ? "enabled" : "disabled"); the_lnet.ln_routing ? "enabled" : "disabled");
LASSERT(tmpstr + tmpsiz - s > 0); LASSERT(tmpstr + tmpsiz - s > 0);
s += snprintf(s, tmpstr + tmpsiz - s, "%-8s %4s %7s %s\n", s += snprintf(s, tmpstr + tmpsiz - s, "%-8s %4s %8s %7s %s\n",
"net", "hops", "state", "router"); "net", "hops", "priority", "state", "router");
LASSERT(tmpstr + tmpsiz - s > 0); LASSERT(tmpstr + tmpsiz - s > 0);
lnet_net_lock(0); lnet_net_lock(0);
...@@ -231,12 +231,14 @@ int LL_PROC_PROTO(proc_lnet_routes) ...@@ -231,12 +231,14 @@ int LL_PROC_PROTO(proc_lnet_routes)
if (route != NULL) { if (route != NULL) {
__u32 net = rnet->lrn_net; __u32 net = rnet->lrn_net;
unsigned int hops = route->lr_hops; unsigned int hops = route->lr_hops;
unsigned int priority = route->lr_priority;
lnet_nid_t nid = route->lr_gateway->lp_nid; lnet_nid_t nid = route->lr_gateway->lp_nid;
int alive = route->lr_gateway->lp_alive; int alive = route->lr_gateway->lp_alive;
s += snprintf(s, tmpstr + tmpsiz - s, s += snprintf(s, tmpstr + tmpsiz - s,
"%-8s %4u %7s %s\n", "%-8s %4u %8u %7s %s\n",
libcfs_net2str(net), hops, libcfs_net2str(net), hops,
priority,
alive ? "up" : "down", alive ? "up" : "down",
libcfs_nid2str(nid)); libcfs_nid2str(nid));
LASSERT(tmpstr + tmpsiz - s > 0); LASSERT(tmpstr + tmpsiz - s > 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