staging: lustre: lnet: Replace semaphore ln_rc_signal with completion
authorBinoy Jayan <binoy.jayan@linaro.org>
Wed, 8 Jun 2016 07:50:42 +0000 (13:20 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Jun 2016 01:29:52 +0000 (18:29 -0700)
The semaphore ln_rc_signal is used as completion, so convert it to
struct completion.  Semaphores are going away in the future.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Acked-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/include/linux/lnet/lib-types.h
drivers/staging/lustre/lnet/lnet/router.c

index 24c4a08e6dc6f0495207e16cc35793158d8894d7..7967b013cbae9debaf06b29750937ec00457b6d5 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/kthread.h>
 #include <linux/uio.h>
 #include <linux/types.h>
+#include <linux/completion.h>
 
 #include "types.h"
 #include "lnetctl.h"
@@ -610,7 +611,7 @@ typedef struct {
        /* rcd ready for free */
        struct list_head                  ln_rcd_zombie;
        /* serialise startup/shutdown */
-       struct semaphore                  ln_rc_signal;
+       struct completion                 ln_rc_signal;
 
        struct mutex                      ln_api_mutex;
        struct mutex                      ln_lnd_mutex;
index b01dc424c514e0d5d48ca0f5e8dfafaf94dd7899..063543233035c599e395407d7b964b02e952a3b3 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #define DEBUG_SUBSYSTEM S_LNET
+#include <linux/completion.h>
 #include "../../include/linux/lnet/lib-lnet.h"
 
 #define LNET_NRB_TINY_MIN      512     /* min value for each CPT */
@@ -1065,7 +1066,7 @@ lnet_router_checker_start(void)
                return -EINVAL;
        }
 
-       sema_init(&the_lnet.ln_rc_signal, 0);
+       init_completion(&the_lnet.ln_rc_signal);
 
        rc = LNetEQAlloc(0, lnet_router_checker_event, &the_lnet.ln_rc_eqh);
        if (rc) {
@@ -1079,7 +1080,7 @@ lnet_router_checker_start(void)
                rc = PTR_ERR(task);
                CERROR("Can't start router checker thread: %d\n", rc);
                /* block until event callback signals exit */
-               down(&the_lnet.ln_rc_signal);
+               wait_for_completion(&the_lnet.ln_rc_signal);
                rc = LNetEQFree(the_lnet.ln_rc_eqh);
                LASSERT(!rc);
                the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
@@ -1112,7 +1113,7 @@ lnet_router_checker_stop(void)
        wake_up(&the_lnet.ln_rc_waitq);
 
        /* block until event callback signals exit */
-       down(&the_lnet.ln_rc_signal);
+       wait_for_completion(&the_lnet.ln_rc_signal);
        LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
 
        rc = LNetEQFree(the_lnet.ln_rc_eqh);
@@ -1295,7 +1296,7 @@ rescan:
        lnet_prune_rc_data(1); /* wait for UNLINK */
 
        the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
-       up(&the_lnet.ln_rc_signal);
+       complete(&the_lnet.ln_rc_signal);
        /* The unlink event callback will signal final completion */
        return 0;
 }