Whamcloud - gitweb
LU-4528 llog: don't write llog in 3-steps
[fs/lustre-release.git] / lustre / osp / osp_trans.c
index 896f2d0..8e77ecf 100644 (file)
@@ -35,7 +35,7 @@
 
 struct osp_async_update_args {
        struct dt_update_request *oaua_update;
-       unsigned int             oaua_fc:1;
+       bool                      oaua_flow_control;
 };
 
 struct osp_async_update_item {
@@ -82,13 +82,13 @@ static int osp_async_update_interpret(const struct lu_env *env,
        struct dt_update_request        *dt_update = oaua->oaua_update;
        struct osp_async_update_item    *oaui;
        struct osp_async_update_item    *next;
-       struct osp_device               *osp    = dt2osp_dev(dt_update->dur_dt);
        int                              count  = 0;
        int                              index  = 0;
        int                              rc1    = 0;
 
-       if (oaua->oaua_fc)
-               up(&osp->opd_async_fc_sem);
+       if (oaua->oaua_flow_control)
+               obd_put_request_slot(
+                               &dt2osp_dev(dt_update->dur_dt)->opd_obd->u.cli);
 
        if (rc == 0 || req->rq_repmsg != NULL) {
                reply = req_capsule_server_sized_get(&req->rq_pill,
@@ -119,7 +119,7 @@ static int osp_async_update_interpret(const struct lu_env *env,
                                rc1 = -EINVAL;
                }
 
-               oaui->oaui_interpterer(env, reply, oaui->oaui_obj,
+               oaui->oaui_interpterer(env, reply, req, oaui->oaui_obj,
                                       oaui->oaui_data, index, rc1);
                osp_async_update_item_fini(env, oaui);
                index++;
@@ -147,7 +147,7 @@ int osp_unplug_async_update(const struct lu_env *env,
                list_for_each_entry_safe(oaui, next,
                                         &update->dur_cb_items, oaui_list) {
                        list_del_init(&oaui->oaui_list);
-                       oaui->oaui_interpterer(env, NULL, oaui->oaui_obj,
+                       oaui->oaui_interpterer(env, NULL, NULL, oaui->oaui_obj,
                                               oaui->oaui_data, 0, rc);
                        osp_async_update_item_fini(env, oaui);
                }
@@ -269,7 +269,7 @@ out:
 
 static int osp_trans_trigger(const struct lu_env *env, struct osp_device *osp,
                             struct dt_update_request *dt_update,
-                            struct thandle *th, bool fc)
+                            struct thandle *th, bool flow_control)
 {
        struct thandle_update   *tu = th->th_update;
        int                     rc = 0;
@@ -288,7 +288,7 @@ static int osp_trans_trigger(const struct lu_env *env, struct osp_device *osp,
                if (rc == 0) {
                        args = ptlrpc_req_async_args(req);
                        args->oaua_update = dt_update;
-                       args->oaua_fc = !!fc;
+                       args->oaua_flow_control = flow_control;
                        req->rq_interpret_reply =
                                osp_async_update_interpret;
                        ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
@@ -349,6 +349,7 @@ int osp_trans_stop(const struct lu_env *env, struct dt_device *dt,
        int rc = 0;
 
        LASSERT(tu != NULL);
+        LASSERT(tu != LP_POISON);
        /* Check whether there are updates related with this OSP */
        dt_update = out_find_update(tu, dt);
        if (dt_update == NULL) {
@@ -365,24 +366,25 @@ int osp_trans_stop(const struct lu_env *env, struct dt_device *dt,
        if (is_only_remote_trans(th)) {
                if (th->th_result == 0) {
                        struct osp_device *osp = dt2osp_dev(th->th_dev);
+                       struct client_obd *cli = &osp->opd_obd->u.cli;
 
-                       do {
-                               if (!osp->opd_imp_active ||
-                                   osp->opd_got_disconnected) {
-                                       out_destroy_update_req(dt_update);
-                                       GOTO(put, rc = -ENOTCONN);
-                               }
+                       rc = obd_get_request_slot(cli);
+                       if (!osp->opd_imp_active || osp->opd_got_disconnected) {
+                               if (rc == 0)
+                                       obd_put_request_slot(cli);
 
-                               /* Get the semaphore to guarantee it has
-                                * free slot, which will be released via
-                                * osp_async_update_interpret(). */
-                               rc = down_timeout(&osp->opd_async_fc_sem, HZ);
-                       } while (rc != 0);
+                               rc = -ENOTCONN;
+                       }
+
+                       if (rc != 0) {
+                               out_destroy_update_req(dt_update);
+                               goto put;
+                       }
 
                        rc = osp_trans_trigger(env, dt2osp_dev(dt),
                                               dt_update, th, true);
                        if (rc != 0)
-                               up(&osp->opd_async_fc_sem);
+                               obd_put_request_slot(cli);
                } else {
                        rc = th->th_result;
                        out_destroy_update_req(dt_update);