From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754055AbeAQPbk (ORCPT + 1 other); Wed, 17 Jan 2018 10:31:40 -0500 Received: from casper.infradead.org ([85.118.1.10]:34022 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754007AbeAQP36 (ORCPT ); Wed, 17 Jan 2018 10:29:58 -0500 Date: Wed, 17 Jan 2018 15:29:52 +0000 (GMT) From: James Simmons To: NeilBrown cc: Oleg Drokin , Andreas Dilger , Greg Kroah-Hartman , lkml , lustre Subject: Re: [PATCH 07/19] staging: lustre: simplify l_wait_event when intr handler but no timeout. In-Reply-To: <151538209356.23920.9569196568216701164.stgit@noble> Message-ID: References: <151538168618.23920.8261096424342988792.stgit@noble> <151538209356.23920.9569196568216701164.stgit@noble> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180117_152952_228253_393D0180 X-CRM114-Status: GOOD ( 17.23 ) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: > If l_wait_event() is given a function to be called on a signal, > but no timeout or timeout handler, then the intr function is simply > called at the end if the wait was aborted by a signal. > So a simpler way to write the code (in the one place this case is > used) it to open-code the body of the function after the > wait_event, if -ERESTARTSYS was returned. Reviewed-by: James Simmons > Signed-off-by: NeilBrown > --- > drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 30 +++++------------------ > 1 file changed, 7 insertions(+), 23 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > index 657ab95091a0..411b540b96d9 100644 > --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c > @@ -310,24 +310,6 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req) > return LDLM_ITER_CONTINUE; > } > > -struct ldlm_flock_wait_data { > - struct ldlm_lock *fwd_lock; > -}; > - > -static void > -ldlm_flock_interrupted_wait(void *data) > -{ > - struct ldlm_lock *lock; > - > - lock = ((struct ldlm_flock_wait_data *)data)->fwd_lock; > - > - lock_res_and_lock(lock); > - > - /* client side - set flag to prevent lock from being put on LRU list */ > - ldlm_set_cbpending(lock); > - unlock_res_and_lock(lock); > -} > - > /** > * Flock completion callback function. > * > @@ -342,8 +324,6 @@ int > ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) > { > struct file_lock *getlk = lock->l_ast_data; > - struct ldlm_flock_wait_data fwd; > - struct l_wait_info lwi; > int rc = 0; > > OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CP_CB_WAIT2, 4); > @@ -372,13 +352,17 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) > > LDLM_DEBUG(lock, > "client-side enqueue returned a blocked lock, sleeping"); > - fwd.fwd_lock = lock; > - lwi = LWI_TIMEOUT_INTR(0, NULL, ldlm_flock_interrupted_wait, &fwd); > > /* Go to sleep until the lock is granted. */ > - rc = l_wait_event(lock->l_waitq, is_granted_or_cancelled(lock), &lwi); > + rc = l_wait_event_abortable(lock->l_waitq, is_granted_or_cancelled(lock)); > > if (rc) { > + lock_res_and_lock(lock); > + > + /* client side - set flag to prevent lock from being put on LRU list */ > + ldlm_set_cbpending(lock); > + unlock_res_and_lock(lock); > + > LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)", > rc); > return rc; > > >