]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
staging: lustre: simplify l_wait_event when intr handler but no timeout.
authorNeilBrown <neilb@suse.com>
Mon, 12 Feb 2018 21:22:36 +0000 (08:22 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Feb 2018 14:19:10 +0000 (15:19 +0100)
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 <jsimmons@infradead.org>
Signed-off-by: NeilBrown <neilb@suse.com>
Reviewed-by: Patrick Farrell <paf@cray.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/ldlm/ldlm_flock.c

index 657ab95091a00dd433135b9d18e86cd726a647fb..411b540b96d96cce8b82c7ebb799d0288e8c79ee 100644 (file)
@@ -310,24 +310,6 @@ reprocess:
        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;