Whamcloud - gitweb
LU-10467 ldlm: convert waiting in ldlm_flock_completion_ast() 84/35984/11
authorMr NeilBrown <neilb@suse.com>
Sat, 18 Jan 2020 14:19:29 +0000 (09:19 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 8 Feb 2020 04:00:05 +0000 (04:00 +0000)
The l_wait_event() call in ldlm_flock_completion_ast() sets no
timeout, and so always enables fatal signals.  So it can be converted
to l_wait_event_abortable().

It is passed an on_signal handler, so that needs to be called if
l_wait_event_abortable() returns a negative result.  As this is the
only place the handler is call, it can be inlined.  We already have an
'if' which captures the 'wait was interrupted' condition, so place the
signal handler code in there.

This makes struct ldlm_flock_wait_data redundant.  In fact the
fwd_genertion field in there was already unused.

Signed-off-by: Mr NeilBrown <neilb@suse.com>
Change-Id: I9cc3a3e8b593a66f46183584382dc13169ff9adf
Reviewed-on: https://review.whamcloud.com/35984
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ldlm/ldlm_flock.c

index 1cf3d88..b76638b 100644 (file)
@@ -629,31 +629,6 @@ restart:
        RETURN(LDLM_ITER_CONTINUE);
 }
 
        RETURN(LDLM_ITER_CONTINUE);
 }
 
-struct ldlm_flock_wait_data {
-       struct ldlm_lock *fwd_lock;
-       int               fwd_generation;
-};
-
-static void
-ldlm_flock_interrupted_wait(void *data)
-{
-       struct ldlm_lock *lock;
-       ENTRY;
-
-       lock = ((struct ldlm_flock_wait_data *)data)->fwd_lock;
-
-       /* take lock off the deadlock detection hash list.
-        */
-       lock_res_and_lock(lock);
-       ldlm_flock_blocking_unlink(lock);
-
-       /* client side - set flag to prevent lock from being put on LRU list */
-       ldlm_set_cbpending(lock);
-       unlock_res_and_lock(lock);
-
-       EXIT;
-}
-
 /**
  * Flock completion callback function.
  *
 /**
  * Flock completion callback function.
  *
@@ -670,8 +645,6 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
        struct file_lock *getlk = lock->l_ast_data;
        struct obd_device *obd;
        struct obd_import *imp = NULL;
        struct file_lock *getlk = lock->l_ast_data;
        struct obd_device *obd;
        struct obd_import *imp = NULL;
-       struct ldlm_flock_wait_data fwd;
-       struct l_wait_info lwi;
        enum ldlm_error err;
        int rc = 0;
        ENTRY;
        enum ldlm_error err;
        int rc = 0;
        ENTRY;
@@ -702,25 +675,26 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
 
        LDLM_DEBUG(lock,
                   "client-side enqueue returned a blocked lock, sleeping");
 
        LDLM_DEBUG(lock,
                   "client-side enqueue returned a blocked lock, sleeping");
-       fwd.fwd_lock = lock;
        obd = class_exp2obd(lock->l_conn_export);
 
        /* if this is a local lock, there is no import */
        if (obd)
                imp = obd->u.cli.cl_import;
 
        obd = class_exp2obd(lock->l_conn_export);
 
        /* if this is a local lock, there is no import */
        if (obd)
                imp = obd->u.cli.cl_import;
 
-       if (imp) {
-               spin_lock(&imp->imp_lock);
-               fwd.fwd_generation = imp->imp_generation;
-               spin_unlock(&imp->imp_lock);
-       }
-
-       lwi = LWI_TIMEOUT_INTR(0, NULL, ldlm_flock_interrupted_wait, &fwd);
-
        /* Go to sleep until the lock is granted. */
        /* 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 < 0) {
+               /* take lock off the deadlock detection hash list. */
+               lock_res_and_lock(lock);
+               ldlm_flock_blocking_unlink(lock);
+
+               /* client side - set flag to prevent lock from being
+                * put on LRU list
+                */
+               ldlm_set_cbpending(lock);
+               unlock_res_and_lock(lock);
 
 
-       if (rc) {
                LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)",
                           rc);
                RETURN(rc);
                LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)",
                           rc);
                RETURN(rc);