Whamcloud - gitweb
LU-9330 osp: make variables match proc tunables
[fs/lustre-release.git] / lustre / osp / osp_trans.c
index ccc8d52..498ed18 100644 (file)
@@ -20,7 +20,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2014, 2015, Intel Corporation.
+ * Copyright (c) 2014, 2016, Intel Corporation.
  */
 /*
  * lustre/osp/osp_trans.c
@@ -240,7 +240,7 @@ void osp_update_request_destroy(const struct lu_env *env,
                        list_del_init(&obj->opo_invalidate_cb_list);
                        spin_unlock(&obj->opo_lock);
 
-                       lu_object_put(env, &obj->opo_obj.do_lu);
+                       dt_object_put(env, &obj->opo_obj);
                }
 
                if (env == &lenv)
@@ -264,7 +264,7 @@ object_update_request_dump(const struct object_update_request *ourq,
                update = object_update_request_get(ourq, i, &size);
                LASSERT(update != NULL);
                CDEBUG(mask, "i = %u fid = "DFID" op = %s "
-                      "params = %d batchid = "LPU64" size = %zu repsize %u\n",
+                      "params = %d batchid = %llu size = %zu repsize %u\n",
                       i, PFID(&update->ou_fid),
                       update_op_str(update->ou_type),
                       update->ou_params_count,
@@ -484,10 +484,7 @@ int osp_remote_sync(const struct lu_env *env, struct osp_device *osp,
        if (rc != 0)
                RETURN(rc);
 
-       /* This will only be called with read-only update, and these updates
-        * might be used to retrieve update log during recovery process, so
-        * it will be allowed to send during recovery process */
-       req->rq_allow_replay = 1;
+       osp_set_req_replay(osp, req);
        req->rq_allow_intr = 1;
 
        /* Note: some dt index api might return non-zero result here, like
@@ -530,7 +527,7 @@ static void osp_thandle_invalidate_object(const struct lu_env *env,
                list_del_init(&obj->opo_invalidate_cb_list);
                spin_unlock(&obj->opo_lock);
 
-               lu_object_put(env, &obj->opo_obj.do_lu);
+               dt_object_put(env, &obj->opo_obj);
        }
 }
 
@@ -1048,7 +1045,7 @@ static void osp_request_commit_cb(struct ptlrpc_request *req)
                last_committed_transno =
                        req->rq_import->imp_peer_committed_transno;
 
-       CDEBUG(D_HA, "trans no "LPU64" committed transno "LPU64"\n",
+       CDEBUG(D_HA, "trans no %llu committed transno %llu\n",
               req->rq_transno, last_committed_transno);
 
        /* If the transaction is not really committed, mark result = 1 */
@@ -1117,7 +1114,6 @@ static int osp_send_update_req(const struct lu_env *env,
 {
        struct osp_update_args  *args;
        struct ptlrpc_request   *req;
-       struct lu_device *top_device;
        struct osp_thandle      *oth = our->our_th;
        int     rc = 0;
        ENTRY;
@@ -1155,7 +1151,7 @@ static int osp_send_update_req(const struct lu_env *env,
                if (!osp->opd_connect_mdt) {
                        down_read(&osp->opd_async_updates_rwsem);
                        args->oaua_count = &osp->opd_async_updates_count;
-                       args->oaua_waitq = &osp->opd_syn_barrier_waitq;
+                       args->oaua_waitq = &osp->opd_sync_barrier_waitq;
                        up_read(&osp->opd_async_updates_rwsem);
                        atomic_inc(args->oaua_count);
                }
@@ -1174,9 +1170,7 @@ static int osp_send_update_req(const struct lu_env *env,
                 * status, in case the other target is being recoveried
                 * at the same time, and if we wait here for the import
                 * to be recoveryed, it might cause deadlock */
-               top_device = osp->opd_dt_dev.dd_lu_dev.ld_site->ls_top_dev;
-               if (top_device->ld_obd->obd_recovering)
-                       req->rq_allow_replay = 1;
+               osp_set_req_replay(osp, req);
 
                /* Because this req will be synchronus, i.e. it will be called
                 * in the same thread, so it will be safe to use current
@@ -1214,7 +1208,7 @@ out:
  * Get local thandle for osp_thandle
  *
  * Get the local OSD thandle from the OSP thandle. Currently, there
- * are a few OSP API (osp_object_create() and osp_sync_add()) needs
+ * are a few OSP API (osp_create() and osp_sync_add()) needs
  * to update the object on local OSD device.
  *
  * If the osp_thandle comes from normal stack (MDD->LOD->OSP), then
@@ -1264,7 +1258,7 @@ struct thandle *osp_get_storage_thandle(const struct lu_env *env,
  *
  * Set the version for the transaction and add the request to
  * the sending list, then after transaction stop, the request
- * will be picked in the order of version, by sending thread.
+ * will be sent in the order of version by the sending thread.
  *
  * \param [in] oth     osp thandle to be set version.
  *
@@ -1294,6 +1288,7 @@ int osp_check_and_set_rpc_version(struct osp_thandle *oth,
        /* Assign the version and add it to the sending list */
        osp_thandle_get(oth);
        oth->ot_our->our_version = ou->ou_version++;
+       oth->ot_our->our_generation = ou->ou_generation;
        list_add_tail(&oth->ot_our->our_list,
                      &osp->opd_update->ou_list);
        oth->ot_our->our_req_ready = 0;
@@ -1301,8 +1296,8 @@ int osp_check_and_set_rpc_version(struct osp_thandle *oth,
        spin_unlock(&ou->ou_lock);
 
        LASSERT(oth->ot_super.th_wait_submit == 1);
-       CDEBUG(D_INFO, "%s: version "LPU64" oth:version %p:"LPU64"\n",
-              osp->opd_obd->obd_name, ou->ou_version, oth,
+       CDEBUG(D_INFO, "%s: version %llu gen %llu oth:version %p:%llu\n",
+              osp->opd_obd->obd_name, ou->ou_version, ou->ou_generation, oth,
               oth->ot_our->our_version);
 
        return 0;
@@ -1331,7 +1326,7 @@ osp_get_next_request(struct osp_updates *ou, struct osp_update_request **ourp)
        spin_lock(&ou->ou_lock);
        list_for_each_entry_safe(our, tmp, &ou->ou_list, our_list) {
                LASSERT(our->our_th != NULL);
-               CDEBUG(D_HA, "ou %p version "LPU64" rpc_version "LPU64"\n",
+               CDEBUG(D_HA, "ou %p version %llu rpc_version %llu\n",
                       ou, our->our_version, ou->ou_rpc_version);
                spin_lock(&our->our_list_lock);
                /* Find next osp_update_request in the list */
@@ -1378,6 +1373,11 @@ void osp_invalidate_request(struct osp_device *osp)
        if (rc < 0) {
                CERROR("%s: init env error: rc = %d\n", osp->opd_obd->obd_name,
                       rc);
+
+               spin_lock(&ou->ou_lock);
+               ou->ou_generation++;
+               spin_unlock(&ou->ou_lock);
+
                return;
        }
 
@@ -1403,6 +1403,9 @@ void osp_invalidate_request(struct osp_device *osp)
                       our);
        }
 
+       /* Increase the generation, then the update request with old generation
+        * will fail with -EIO. */
+       ou->ou_generation++;
        spin_unlock(&ou->ou_lock);
 
        /* invalidate all of request in the sending list */
@@ -1470,7 +1473,8 @@ int osp_send_update_thread(void *arg)
                        osp_trans_callback(&env, our->our_th,
                                our->our_th->ot_super.th_result);
                        rc = our->our_th->ot_super.th_result;
-               } else if (OBD_FAIL_CHECK(OBD_FAIL_INVALIDATE_UPDATE)) {
+               } else if (ou->ou_generation != our->our_generation ||
+                          OBD_FAIL_CHECK(OBD_FAIL_INVALIDATE_UPDATE)) {
                        rc = -EIO;
                        osp_trans_callback(&env, our->our_th, rc);
                } else {
@@ -1583,7 +1587,7 @@ int osp_trans_stop(const struct lu_env *env, struct dt_device *dt,
                GOTO(out, rc = -EIO);
        }
 
-       CDEBUG(D_HA, "%s: add oth %p with version "LPU64"\n",
+       CDEBUG(D_HA, "%s: add oth %p with version %llu\n",
               osp->opd_obd->obd_name, oth, our->our_version);
 
        LASSERT(our->our_req_ready == 0);