Whamcloud - gitweb
LU-5519 lfsck: repair bad name hash for striped directory
[fs/lustre-release.git] / lustre / osp / osp_trans.c
index 39a42bc..25d92ea 100644 (file)
@@ -195,7 +195,7 @@ static int osp_async_update_interpret(const struct lu_env *env,
                index++;
        }
 
-       out_destroy_update_req(dt_update);
+       dt_update_request_destroy(dt_update);
 
        return 0;
 }
@@ -220,7 +220,7 @@ int osp_unplug_async_request(const struct lu_env *env,
        int                              rc;
 
        rc = out_prep_update_req(env, osp->opd_obd->u.cli.cl_import,
-                                update->dur_req, &req);
+                                update->dur_buf.ub_req, &req);
        if (rc != 0) {
                struct osp_async_request *oar;
                struct osp_async_request *next;
@@ -232,7 +232,7 @@ int osp_unplug_async_request(const struct lu_env *env,
                                               oar->oar_data, 0, rc);
                        osp_async_request_fini(env, oar);
                }
-               out_destroy_update_req(update);
+               dt_update_request_destroy(update);
        } else {
                LASSERT(list_empty(&update->dur_list));
 
@@ -265,7 +265,7 @@ osp_find_or_create_async_update_request(struct osp_device *osp)
        if (update != NULL)
                return update;
 
-       update = out_create_update_req(&osp->opd_dt_dev);
+       update = dt_update_request_create(&osp->opd_dt_dev);
        if (!IS_ERR(update))
                osp->opd_async_requests = update;
 
@@ -296,9 +296,9 @@ osp_find_or_create_async_update_request(struct osp_device *osp)
  * \retval                     0 for success
  * \retval                     negative error number on failure
  */
-int osp_insert_async_request(const struct lu_env *env,
-                            int op, struct osp_object *obj, int count,
-                            int *lens, const char **bufs, void *data,
+int osp_insert_async_request(const struct lu_env *env, enum update_type op,
+                            struct osp_object *obj, int count,
+                            __u16 *lens, const void **bufs, void *data,
                             osp_async_request_interpreter_t interpreter)
 {
        struct osp_async_request     *oar;
@@ -316,9 +316,10 @@ int osp_insert_async_request(const struct lu_env *env,
                GOTO(out, rc = PTR_ERR(update));
 
 again:
-       rc = out_insert_update(env, update, op, lu_object_fid(osp2lu_obj(obj)),
-                              count, lens, bufs);
        /* The queue is full. */
+       rc = out_update_pack(env, &update->dur_buf, op,
+                            lu_object_fid(osp2lu_obj(obj)), count, lens, bufs,
+                            0);
        if (rc == -E2BIG) {
                osp->opd_async_requests = NULL;
                mutex_unlock(&osp->opd_async_requests_mutex);
@@ -412,9 +413,9 @@ out:
 /**
  * Trigger the request for remote updates.
  *
- * If the transaction is a remote transaction, then related remote updates
- * will be sent asynchronously; otherwise, the cross MDTs transaction will
- * be synchronized.
+ * If the transaction is not a remote one or it is required to be sync mode
+ * (th->th_sync is set), then it will be sent synchronously; otherwise, the
+ * RPC will be sent asynchronously.
  *
  * Please refer to osp_trans_create() for transaction type.
  *
@@ -441,8 +442,16 @@ static int osp_trans_trigger(const struct lu_env *env, struct osp_device *osp,
                struct ptlrpc_request           *req;
 
                list_del_init(&dt_update->dur_list);
+               if (th->th_sync) {
+                       rc = out_remote_sync(env, osp->opd_obd->u.cli.cl_import,
+                                            dt_update, NULL);
+                       dt_update_request_destroy(dt_update);
+
+                       return rc;
+               }
+
                rc = out_prep_update_req(env, osp->opd_obd->u.cli.cl_import,
-                                        dt_update->dur_req, &req);
+                                        dt_update->dur_buf.ub_req, &req);
                if (rc == 0) {
                        args = ptlrpc_req_async_args(req);
                        args->oaua_update = dt_update;
@@ -451,7 +460,7 @@ static int osp_trans_trigger(const struct lu_env *env, struct osp_device *osp,
                                osp_async_update_interpret;
                        ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
                } else {
-                       out_destroy_update_req(dt_update);
+                       dt_update_request_destroy(dt_update);
                }
        } else {
                th->th_sync = 1;
@@ -537,6 +546,7 @@ int osp_trans_stop(const struct lu_env *env, struct dt_device *dt,
        struct thandle_update           *tu = th->th_update;
        struct dt_update_request        *dt_update;
        int                              rc = 0;
+       ENTRY;
 
        LASSERT(tu != NULL);
        LASSERT(tu != LP_POISON);
@@ -545,13 +555,15 @@ int osp_trans_stop(const struct lu_env *env, struct dt_device *dt,
        dt_update = out_find_update(tu, dt);
        if (dt_update == NULL) {
                if (!is_only_remote_trans(th))
-                       return rc;
-               goto put;
+                       RETURN(rc);
+
+               GOTO(put, rc);
        }
 
-       if (dt_update->dur_req->ourq_count == 0) {
-               out_destroy_update_req(dt_update);
-               goto put;
+       if (dt_update->dur_buf.ub_req == NULL ||
+           dt_update->dur_buf.ub_req->ourq_count == 0) {
+               dt_update_request_destroy(dt_update);
+               GOTO(put, rc);
        }
 
        if (is_only_remote_trans(th)) {
@@ -560,7 +572,7 @@ int osp_trans_stop(const struct lu_env *env, struct dt_device *dt,
                        struct client_obd *cli = &osp->opd_obd->u.cli;
 
                        rc = obd_get_request_slot(cli);
-                       if (!osp->opd_imp_active || osp->opd_got_disconnected) {
+                       if (!osp->opd_imp_active || !osp->opd_imp_connected) {
                                if (rc == 0)
                                        obd_put_request_slot(cli);
 
@@ -568,8 +580,8 @@ int osp_trans_stop(const struct lu_env *env, struct dt_device *dt,
                        }
 
                        if (rc != 0) {
-                               out_destroy_update_req(dt_update);
-                               goto put;
+                               dt_update_request_destroy(dt_update);
+                               GOTO(put, rc);
                        }
 
                        rc = osp_trans_trigger(env, dt2osp_dev(dt),
@@ -578,16 +590,18 @@ int osp_trans_stop(const struct lu_env *env, struct dt_device *dt,
                                obd_put_request_slot(cli);
                } else {
                        rc = th->th_result;
-                       out_destroy_update_req(dt_update);
+                       dt_update_request_destroy(dt_update);
                }
        } else {
                if (tu->tu_sent_after_local_trans)
                        rc = osp_trans_trigger(env, dt2osp_dev(dt),
                                               dt_update, th, false);
                rc = dt_update->dur_rc;
-               out_destroy_update_req(dt_update);
+               dt_update_request_destroy(dt_update);
        }
 
+       GOTO(put, rc);
+
 put:
        thandle_put(th);
        return rc;