From: Mr NeilBrown Date: Tue, 27 Aug 2019 22:47:09 +0000 (+1000) Subject: LU-10467 ptlrpc: convert final users of LWI_TIMEOUT_INTERVAL X-Git-Tag: 2.13.53~226 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c30da8bfa199205194eefca2c5d2e6843a29a34b LU-10467 ptlrpc: convert final users of LWI_TIMEOUT_INTERVAL LWI_TIMEOUT_INTERVAL causes l_wait_event to perform a slow poll loop. This is only needed if the event can happen without triggering a wakeup on the wait-queue. On this case, the event is a counter reaching zero, and we can easily ensure a wakeup is sent whenever that counter becomes zero. So let's add those wake_ups, and change this to a simple wait_event_idle_timeout(). At the same time, change all wake_up_all() calls on this wait queue to simple wake_up(). wake_up_all() is only needed where there are exclusive waiters, and this queue has no exclusive waiters. Change-Id: I2bea069150f21b725025bacc7a4fa0cf4d95ab20 Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/35979 Reviewed-by: Andreas Dilger Tested-by: jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 617c31c..5064a6f 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -1740,7 +1740,8 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) spin_lock(&imp->imp_lock); if (!list_empty(&req->rq_list)) { list_del_init(&req->rq_list); - atomic_dec(&req->rq_import->imp_inflight); + if (atomic_dec_and_test(&req->rq_import->imp_inflight)) + wake_up(&req->rq_import->imp_recovery_waitq); } spin_unlock(&imp->imp_lock); ptlrpc_rqphase_move(req, RQ_PHASE_NEW); @@ -2196,13 +2197,14 @@ interpret: */ if (!list_empty(&req->rq_list)) { list_del_init(&req->rq_list); - atomic_dec(&imp->imp_inflight); + if (atomic_dec_and_test(&imp->imp_inflight)) + wake_up(&imp->imp_recovery_waitq); } list_del_init(&req->rq_unreplied_list); spin_unlock(&imp->imp_lock); atomic_dec(&set->set_remaining); - wake_up_all(&imp->imp_recovery_waitq); + wake_up(&imp->imp_recovery_waitq); if (set->set_producer) { /* produce a new request if possible */ diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 3a4a48a..4b4bcab 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -301,7 +301,6 @@ void ptlrpc_invalidate_import(struct obd_import *imp) { struct list_head *tmp, *n; struct ptlrpc_request *req; - struct l_wait_info lwi; time64_t timeout; int rc; @@ -348,18 +347,16 @@ void ptlrpc_invalidate_import(struct obd_import *imp) * have been locally cancelled by ptlrpc_abort_inflight. */ timeout_jiffies = max_t(long, cfs_time_seconds(timeout), 1); - lwi = LWI_TIMEOUT_INTERVAL(timeout_jiffies, - (timeout > 1) ? cfs_time_seconds(1) : - cfs_time_seconds(1) / 2, - NULL, NULL); - rc = l_wait_event(imp->imp_recovery_waitq, - (atomic_read(&imp->imp_inflight) == 0), - &lwi); - if (rc) { + rc = wait_event_idle_timeout( + imp->imp_recovery_waitq, + (atomic_read(&imp->imp_inflight) == 0), + timeout_jiffies); + + if (rc == 0) { const char *cli_tgt = obd2cli_tgt(imp->imp_obd); - CERROR("%s: rc = %d waiting for callback (%d != 0)\n", - cli_tgt, rc, atomic_read(&imp->imp_inflight)); + CERROR("%s: timeout waiting for callback (%d != 0)\n", + cli_tgt, atomic_read(&imp->imp_inflight)); spin_lock(&imp->imp_lock); if (atomic_read(&imp->imp_inflight) == 0) { @@ -377,7 +374,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp) /* Let's save one loop as soon as inflight have * dropped to zero. No new inflights possible at * this point. */ - rc = 0; + rc = 1; } else { list_for_each_safe(tmp, n, &imp->imp_sending_list) { @@ -403,7 +400,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp) } spin_unlock(&imp->imp_lock); } - } while (rc != 0); + } while (rc == 0); /* * Let's additionally check that no new rpcs added to import in @@ -414,7 +411,7 @@ void ptlrpc_invalidate_import(struct obd_import *imp) sptlrpc_import_flush_all_ctx(imp); atomic_dec(&imp->imp_inval_count); - wake_up_all(&imp->imp_recovery_waitq); + wake_up(&imp->imp_recovery_waitq); } EXPORT_SYMBOL(ptlrpc_invalidate_import); @@ -1405,7 +1402,7 @@ out: spin_unlock(&imp->imp_lock); } - wake_up_all(&imp->imp_recovery_waitq); + wake_up(&imp->imp_recovery_waitq); RETURN(rc); } @@ -1621,7 +1618,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) } if (imp->imp_state == LUSTRE_IMP_FULL) { - wake_up_all(&imp->imp_recovery_waitq); + wake_up(&imp->imp_recovery_waitq); ptlrpc_wake_delayed(imp); }