X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lnet%2Flnet%2Fapi-ni.c;h=16465b533f3353abebec3cfb82124027e363500e;hb=19b33c5ed4a5c8296b0a2ba576de874e83faa8fd;hp=f75a507732b4b53b7952aca33ea5f3924f040a0f;hpb=40ae5dd2f2d0c6abe8e2f83ab9652873bee92485;p=fs%2Flustre-release.git diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index f75a507..16465b5 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -55,7 +55,7 @@ static int rnet_htable_size = LNET_REMOTE_NETS_HASH_DEFAULT; module_param(rnet_htable_size, int, 0444); MODULE_PARM_DESC(rnet_htable_size, "size of remote network hash table"); -static int lnet_ping(lnet_process_id_t id, int timeout_ms, +static int lnet_ping(lnet_process_id_t id, signed long timeout, lnet_process_id_t __user *ids, int n_ids); static char * @@ -2118,17 +2118,29 @@ LNetCtl(unsigned int cmd, void *arg) case IOC_LIBCFS_LNET_FAULT: return lnet_fault_ctl(data->ioc_flags, data); - case IOC_LIBCFS_PING: + case IOC_LIBCFS_PING: { + signed long timeout; + id.nid = data->ioc_nid; id.pid = data->ioc_u32[0]; - rc = lnet_ping(id, data->ioc_u32[1], /* timeout */ - data->ioc_pbuf1, - data->ioc_plen1/sizeof(lnet_process_id_t)); + + /* Don't block longer than 2 minutes */ + if (data->ioc_u32[1] > 120 * MSEC_PER_SEC) + return -EINVAL; + + /* If timestamp is negative then disable timeout */ + if ((s32)data->ioc_u32[1] < 0) + timeout = MAX_SCHEDULE_TIMEOUT; + else + timeout = msecs_to_jiffies(data->ioc_u32[1]); + + rc = lnet_ping(id, timeout, data->ioc_pbuf1, + data->ioc_plen1 / sizeof(lnet_process_id_t)); if (rc < 0) return rc; data->ioc_count = rc; return 0; - + } default: ni = lnet_net2ni(data->ioc_net); if (ni == NULL) @@ -2203,9 +2215,8 @@ LNetSnprintHandle(char *str, int len, lnet_handle_any_t h) } EXPORT_SYMBOL(LNetSnprintHandle); -static int -lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids, - int n_ids) +static int lnet_ping(lnet_process_id_t id, signed long timeout, + lnet_process_id_t __user *ids, int n_ids) { lnet_handle_eq_t eqh; lnet_handle_md_t mdh; @@ -2214,7 +2225,7 @@ lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids, int which; int unlinked = 0; int replied = 0; - const int a_long_time = 60000; /* mS */ + const signed long a_long_time = msecs_to_jiffies(60 * MSEC_PER_SEC); int infosz; struct lnet_ping_info *info; lnet_process_id_t tmpid; @@ -2226,10 +2237,8 @@ lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids, infosz = offsetof(struct lnet_ping_info, pi_ni[n_ids]); - if (n_ids <= 0 || - id.nid == LNET_NID_ANY || - timeout_ms > 500000 || /* arbitrary limit! */ - n_ids > 20) /* arbitrary limit! */ + /* n_ids limit is arbitrary */ + if (n_ids <= 0 || n_ids > 20 || id.nid == LNET_NID_ANY) return -EINVAL; if (id.pid == LNET_PID_ANY) @@ -2273,7 +2282,7 @@ lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids, /* NB must wait for the UNLINK event below... */ unlinked = 1; - timeout_ms = a_long_time; + timeout = a_long_time; } do { @@ -2281,7 +2290,7 @@ lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids, if (unlinked) blocked = cfs_block_allsigs(); - rc2 = LNetEQPoll(&eqh, 1, timeout_ms, &event, &which); + rc2 = LNetEQPoll(&eqh, 1, timeout, &event, &which); if (unlinked) cfs_restore_sigs(blocked); @@ -2305,7 +2314,7 @@ lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t __user *ids, LNetMDUnlink(mdh); /* No assertion (racing with network) */ unlinked = 1; - timeout_ms = a_long_time; + timeout = a_long_time; } else if (rc2 == 0) { /* timed out waiting for unlink */ CWARN("ping %s: late network completion\n",