From 366959b8cba5b022b4c1ea9aaba47ac14d4fff7e Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Sat, 18 Jan 2020 09:17:51 -0500 Subject: [PATCH] LU-10467 ldlm: convert waiting in ldlm_completion_ast() ldlm_completion_ast() calls l_wait_event() in two slightly different ways depending on whether a timeout is defined. As a non-NULL _on_signal handler in passed, the non-timed-out portion of the wait allows signals (abortable). As the on_timeout handler return zero, the timed-out portion of the wait is always followed by a non-timedout portion. So if no timeout is defined, we can simply wait with l_wait_event_abortable(). If there is a timeout, we first wait with wait_event_idle_timeout() and if that times out, we call ldlm_expired_completion_wait(), then wait with l_wait_event_abortable(). Change-Id: I6874010085864764f2fc0e294dc0c67152cb2ad2 Signed-off-by: Mr NeilBrown Reviewed-on: https://review.whamcloud.com/35985 Tested-by: jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Petros Koutoupis Reviewed-by: Shaun Tancheff Reviewed-by: Oleg Drokin --- lustre/include/lustre_dlm.h | 1 - lustre/ldlm/ldlm_request.c | 39 +++++++++++++++++++-------------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 7f1fef3..4f69be739 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -1641,7 +1641,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *, } while (0) /* ldlm_request.c */ -int ldlm_expired_completion_wait(void *data); /** \defgroup ldlm_local_ast Default AST handlers for local locks * These AST handlers are typically used for server-side local locks and are * also used by client-side lock handlers to perform minimum level base diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 143d0a9..53791f2 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -71,10 +71,6 @@ MODULE_PARM_DESC(ldlm_enqueue_min, "lock enqueue timeout minimum"); /* in client side, whether the cached locks will be canceled before replay */ unsigned int ldlm_cancel_unused_locks_before_replay = 1; -static void interrupted_completion_wait(void *data) -{ -} - struct lock_wait_data { struct ldlm_lock *lwd_lock; __u32 lwd_conn_cnt; @@ -111,9 +107,8 @@ int ldlm_request_bufsize(int count, int type) return sizeof(struct ldlm_request) + avail; } -int ldlm_expired_completion_wait(void *data) +void ldlm_expired_completion_wait(struct lock_wait_data *lwd) { - struct lock_wait_data *lwd = data; struct ldlm_lock *lock = lwd->lwd_lock; struct obd_import *imp; struct obd_device *obd; @@ -135,7 +130,7 @@ int ldlm_expired_completion_wait(void *data) if (last_dump == 0) libcfs_debug_dumplog(); } - RETURN(0); + RETURN_EXIT; } obd = lock->l_conn_export->exp_obd; @@ -147,7 +142,7 @@ int ldlm_expired_completion_wait(void *data) (s64)(ktime_get_real_seconds() - lock->l_activity), obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid); - RETURN(0); + EXIT; } int is_granted_or_cancelled_nolock(struct ldlm_lock *lock) @@ -269,7 +264,6 @@ int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) struct lock_wait_data lwd; struct obd_device *obd; struct obd_import *imp = NULL; - struct l_wait_info lwi; time64_t timeout; int rc = 0; @@ -300,15 +294,6 @@ noreproc: lwd.lwd_lock = lock; lock->l_activity = ktime_get_real_seconds(); - if (ldlm_is_no_timeout(lock)) { - LDLM_DEBUG(lock, "waiting indefinitely because of NO_TIMEOUT"); - lwi = LWI_INTR(interrupted_completion_wait, &lwd); - } else { - lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(timeout), - ldlm_expired_completion_wait, - interrupted_completion_wait, &lwd); - } - if (imp != NULL) { spin_lock(&imp->imp_lock); lwd.lwd_conn_cnt = imp->imp_conn_cnt; @@ -322,8 +307,22 @@ noreproc: rc = -EINTR; } else { /* Go to sleep until the lock is granted or cancelled. */ - rc = l_wait_event(lock->l_waitq, - is_granted_or_cancelled(lock), &lwi); + if (ldlm_is_no_timeout(lock)) { + LDLM_DEBUG(lock, "waiting indefinitely because of NO_TIMEOUT"); + rc = l_wait_event_abortable( + lock->l_waitq, + is_granted_or_cancelled(lock)); + } else { + if (wait_event_idle_timeout( + lock->l_waitq, + is_granted_or_cancelled(lock), + cfs_time_seconds(timeout)) == 0) { + ldlm_expired_completion_wait(&lwd); + rc = l_wait_event_abortable( + lock->l_waitq, + is_granted_or_cancelled(lock)); + } + } } if (rc) { -- 1.8.3.1