From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755520AbeAHDaa (ORCPT + 1 other); Sun, 7 Jan 2018 22:30:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:55761 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755175AbeAHDa3 (ORCPT ); Sun, 7 Jan 2018 22:30:29 -0500 From: NeilBrown To: Oleg Drokin , James Simmons , Andreas Dilger , Greg Kroah-Hartman Date: Mon, 08 Jan 2018 14:28:13 +1100 Subject: [PATCH 11/19] staging: lustre: remove back_to_sleep() Cc: lkml , lustre Message-ID: <151538209372.23920.9644158038491397506.stgit@noble> In-Reply-To: <151538168618.23920.8261096424342988792.stgit@noble> References: <151538168618.23920.8261096424342988792.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: When 'back_to_sleep()' is passed as the 'timeout' function, the effect is to wait indefinitely for the event, polling once after the timeout. If LWI_ON_SIGNAL_NOOP is given, then after the timeout we allow fatal signals to interrupt the wait. Make this more obvious in both places "back_to_sleep()" is used but using two explicit sleeps. The code in ptlrpcd_add_req() looks odd - why not just have one wait_event_idle()? However I believe this is a faithful transformation of the existing code. Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/include/lustre_lib.h | 4 ---- drivers/staging/lustre/lustre/ptlrpc/import.c | 11 ++++++----- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 9 +++++---- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index b2a64d0e682c..1939e959b92a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -140,10 +140,6 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id); * XXX nikita: some ptlrpc daemon threads have races of that sort. * */ -static inline int back_to_sleep(void *arg) -{ - return 0; -} #define LWI_ON_SIGNAL_NOOP ((void (*)(void *))(-1)) diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 5d62c9de27eb..faf0f606f013 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -1496,7 +1496,6 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) } if (ptlrpc_import_in_recovery(imp)) { - struct l_wait_info lwi; long timeout; if (AT_OFF) { @@ -1510,10 +1509,12 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) timeout = at_get(&imp->imp_at.iat_service_estimate[idx]) * HZ; } - lwi = LWI_TIMEOUT_INTR(cfs_timeout_cap(timeout), - back_to_sleep, LWI_ON_SIGNAL_NOOP, NULL); - rc = l_wait_event(imp->imp_recovery_waitq, - !ptlrpc_import_in_recovery(imp), &lwi); + if (wait_event_idle_timeout(imp->imp_recovery_waitq, + !ptlrpc_import_in_recovery(imp), + cfs_timeout_cap(timeout)) == 0) + l_wait_event_abortable( + imp->imp_recovery_waitq, + !ptlrpc_import_in_recovery(imp)); } spin_lock(&imp->imp_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index dad2f9290f70..437b4b2a9072 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -230,12 +230,13 @@ void ptlrpcd_add_req(struct ptlrpc_request *req) spin_lock(&req->rq_lock); if (req->rq_invalid_rqset) { - struct l_wait_info lwi = LWI_TIMEOUT(5 * HZ, - back_to_sleep, NULL); - req->rq_invalid_rqset = 0; spin_unlock(&req->rq_lock); - l_wait_event(req->rq_set_waitq, !req->rq_set, &lwi); + if (wait_event_idle_timeout(req->rq_set_waitq, + !req->rq_set, + 5 * HZ) == 0) + wait_event_idle(req->rq_set_waitq, + !req->rq_set); } else if (req->rq_set) { /* If we have a valid "rq_set", just reuse it to avoid double * linked.