Whamcloud - gitweb
LU-13005 lnet: eq: discard struct lnet_handle_eq
[fs/lustre-release.git] / lnet / lnet / api-ni.c
index f580a89..2ee5970 100644 (file)
@@ -979,10 +979,7 @@ lnet_res_container_cleanup(struct lnet_res_container *rec)
                struct list_head *e = rec->rec_active.next;
 
                list_del_init(e);
-               if (rec->rec_type == LNET_COOKIE_TYPE_EQ) {
-                       lnet_eq_free(list_entry(e, struct lnet_eq, eq_list));
-
-               } else if (rec->rec_type == LNET_COOKIE_TYPE_MD) {
+               if (rec->rec_type == LNET_COOKIE_TYPE_MD) {
                        lnet_md_free(list_entry(e, struct lnet_libmd, md_list));
 
                } else { /* NB: Active MEs should be attached on portals */
@@ -1170,7 +1167,7 @@ lnet_prepare(lnet_pid_t requested_pid)
        INIT_LIST_HEAD(&the_lnet.ln_mt_localNIRecovq);
        INIT_LIST_HEAD(&the_lnet.ln_mt_peerNIRecovq);
        init_waitqueue_head(&the_lnet.ln_dc_waitq);
-       LNetInvalidateEQHandle(&the_lnet.ln_mt_eqh);
+       the_lnet.ln_mt_eq = NULL;
        init_completion(&the_lnet.ln_started);
 
        rc = lnet_slab_setup();
@@ -1256,9 +1253,9 @@ lnet_unprepare (void)
                the_lnet.ln_mt_zombie_rstqs = NULL;
        }
 
-       if (!LNetEQHandleIsInvalid(the_lnet.ln_mt_eqh)) {
-               rc = LNetEQFree(the_lnet.ln_mt_eqh);
-               LNetInvalidateEQHandle(&the_lnet.ln_mt_eqh);
+       if (the_lnet.ln_mt_eq) {
+               rc = LNetEQFree(the_lnet.ln_mt_eq);
+               the_lnet.ln_mt_eq = NULL;
                LASSERT(rc == 0);
        }
 
@@ -1683,9 +1680,10 @@ lnet_ping_target_setup(struct lnet_ping_buffer **ppbuf,
        int rc, rc2;
 
        if (set_eq) {
-               rc = LNetEQAlloc(0, lnet_ping_target_event_handler,
-                                &the_lnet.ln_ping_target_eq);
-               if (rc != 0) {
+               the_lnet.ln_ping_target_eq =
+                       LNetEQAlloc(0, lnet_ping_target_event_handler);
+               if (IS_ERR(the_lnet.ln_ping_target_eq)) {
+                       rc = PTR_ERR(the_lnet.ln_ping_target_eq);
                        CERROR("Can't allocate ping buffer EQ: %d\n", rc);
                        return rc;
                }
@@ -1948,9 +1946,10 @@ static int lnet_push_target_init(void)
        if (the_lnet.ln_push_target)
                return -EALREADY;
 
-       rc = LNetEQAlloc(0, lnet_push_target_event_handler,
-                        &the_lnet.ln_push_target_eq);
-       if (rc) {
+       the_lnet.ln_push_target_eq =
+               LNetEQAlloc(0, lnet_push_target_event_handler);
+       if (IS_ERR(the_lnet.ln_push_target_eq)) {
+               rc = PTR_ERR(the_lnet.ln_push_target_eq);
                CERROR("Can't allocated push target EQ: %d\n", rc);
                return rc;
        }
@@ -1962,7 +1961,7 @@ static int lnet_push_target_init(void)
 
        if (rc) {
                LNetEQFree(the_lnet.ln_push_target_eq);
-               LNetInvalidateEQHandle(&the_lnet.ln_push_target_eq);
+               the_lnet.ln_push_target_eq = NULL;
        }
 
        return rc;
@@ -1989,7 +1988,7 @@ static void lnet_push_target_fini(void)
        the_lnet.ln_push_target_nnis = 0;
 
        LNetEQFree(the_lnet.ln_push_target_eq);
-       LNetInvalidateEQHandle(&the_lnet.ln_push_target_eq);
+       the_lnet.ln_push_target_eq = NULL;
 }
 
 static int
@@ -2649,8 +2648,9 @@ LNetNIInit(lnet_pid_t requested_pid)
 
        lnet_ping_target_update(pbuf, ping_mdh);
 
-       rc = LNetEQAlloc(0, lnet_mt_event_handler, &the_lnet.ln_mt_eqh);
-       if (rc != 0) {
+       the_lnet.ln_mt_eq = LNetEQAlloc(0, lnet_mt_event_handler);
+       if (IS_ERR(the_lnet.ln_mt_eq)) {
+               rc = PTR_ERR(the_lnet.ln_mt_eq);
                CERROR("Can't allocate monitor thread EQ: %d\n", rc);
                goto err_stop_ping;
        }
@@ -4082,7 +4082,7 @@ EXPORT_SYMBOL(LNetGetId);
 static int lnet_ping(struct lnet_process_id id, signed long timeout,
                     struct lnet_process_id __user *ids, int n_ids)
 {
-       struct lnet_handle_eq eqh;
+       struct lnet_eq *eq;
        struct lnet_handle_md mdh;
        struct lnet_event event;
        struct lnet_md md = { NULL };
@@ -4117,8 +4117,9 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
                return -ENOMEM;
 
        /* NB 2 events max (including any unlink event) */
-       rc = LNetEQAlloc(2, LNET_EQ_HANDLER_NONE, &eqh);
-       if (rc != 0) {
+       eq = LNetEQAlloc(2, LNET_EQ_HANDLER_NONE);
+       if (IS_ERR(eq)) {
+               rc = PTR_ERR(eq);
                CERROR("Can't allocate EQ: %d\n", rc);
                goto fail_ping_buffer_decref;
        }
@@ -4130,7 +4131,7 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
        md.max_size  = 0;
        md.options   = LNET_MD_TRUNCATE;
        md.user_ptr  = NULL;
-       md.eq_handle = eqh;
+       md.eq_handle = eq;
 
        rc = LNetMDBind(md, LNET_UNLINK, &mdh);
        if (rc != 0) {
@@ -4161,7 +4162,7 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
                        sigprocmask(SIG_SETMASK, &set, &blocked);
                }
 
-               rc2 = LNetEQPoll(&eqh, 1, timeout, &event, &which);
+               rc2 = LNetEQPoll(&eq, 1, timeout, &event, &which);
 
                if (unlinked)
                        cfs_restore_sigs(blocked);
@@ -4259,7 +4260,7 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
        rc = pbuf->pb_info.pi_nnis;
 
  fail_free_eq:
-       rc2 = LNetEQFree(eqh);
+       rc2 = LNetEQFree(eq);
        if (rc2 != 0)
                CERROR("rc2 %d\n", rc2);
        LASSERT(rc2 == 0);