client: fix net io timeout

This commit is contained in:
Thomas Schoebel-Theuer 2012-08-21 13:43:56 +02:00 committed by Thomas Schoebel-Theuer
parent 2b20ff1b67
commit 5737198009
2 changed files with 24 additions and 9 deletions

View File

@ -370,6 +370,10 @@ static
void _do_timeout(struct client_output *output, struct list_head *anchor, bool force) void _do_timeout(struct client_output *output, struct list_head *anchor, bool force)
{ {
struct client_brick *brick = output->brick; struct client_brick *brick = output->brick;
int rounds = 0;
int io_timeout = brick->io_timeout;
if (io_timeout <= 0)
io_timeout = global_net_io_timeout;
while (!list_empty(anchor)) { while (!list_empty(anchor)) {
struct list_head *tmp; struct list_head *tmp;
@ -385,16 +389,17 @@ void _do_timeout(struct client_output *output, struct list_head *anchor, bool fo
mref_a = container_of(tmp, struct client_mref_aspect, io_head); mref_a = container_of(tmp, struct client_mref_aspect, io_head);
mref = mref_a->object; mref = mref_a->object;
if (!force) { if (!force &&
int io_timeout = brick->io_timeout; (io_timeout <= 0 || !time_is_before_jiffies(mref_a->submit_jiffies + io_timeout * HZ))) {
if (io_timeout <= 0) break;
io_timeout = global_net_io_timeout;
if (io_timeout <= 0 || !time_is_before_jiffies(mref_a->submit_jiffies + io_timeout * HZ)) {
break;
}
} }
MARS_DBG("signalling IO error at pos = %lld len = %d\n", mref->ref_pos, mref->ref_len); if (!rounds++) {
MARS_WRN("timeout after %d: signalling IO error at pos = %lld len = %d\n",
io_timeout,
mref->ref_pos,
mref->ref_len);
}
atomic_inc(&output->timeout_count); atomic_inc(&output->timeout_count);
hash_index = mref->ref_id % CLIENT_HASH_MAX; hash_index = mref->ref_id % CLIENT_HASH_MAX;
@ -439,9 +444,9 @@ static int sender_thread(void *data)
status = _connect(output, brick->brick_name); status = _connect(output, brick->brick_name);
MARS_IO("connect status = %d\n", status); MARS_IO("connect status = %d\n", status);
if (unlikely(status < 0)) { if (unlikely(status < 0)) {
msleep(3000);
_do_timeout(output, &output->wait_list, false); _do_timeout(output, &output->wait_list, false);
_do_timeout(output, &output->mref_list, false); _do_timeout(output, &output->mref_list, false);
msleep(3000);
continue; continue;
} }
do_kill = true; do_kill = true;
@ -455,6 +460,7 @@ static int sender_thread(void *data)
traced_lock(&output->lock, flags); traced_lock(&output->lock, flags);
_do_resubmit(output); _do_resubmit(output);
traced_unlock(&output->lock, flags); traced_unlock(&output->lock, flags);
_do_timeout(output, &output->mref_list, false);
} }
wait_event_interruptible_timeout(output->event, !list_empty(&output->mref_list) || output->get_info || kthread_should_stop(), 1 * HZ); wait_event_interruptible_timeout(output->event, !list_empty(&output->mref_list) || output->get_info || kthread_should_stop(), 1 * HZ);

View File

@ -219,6 +219,15 @@ ctl_table mars_table[] = {
.strategy = &sysctl_intvec, .strategy = &sysctl_intvec,
}, },
#endif #endif
{
.ctl_name = CTL_UNNUMBERED,
.procname = "network_io_timeout",
.data = &global_net_io_timeout,
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = &proc_dointvec,
.strategy = &sysctl_intvec,
},
{ {
.ctl_name = CTL_UNNUMBERED, .ctl_name = CTL_UNNUMBERED,
.procname = "network_traffic_limit_kb", .procname = "network_traffic_limit_kb",