Whamcloud - gitweb
LU-3536 lod: Separate thandle to different layers.
[fs/lustre-release.git] / lustre / osp / osp_md_object.c
index c031457..a587b57 100644 (file)
@@ -85,13 +85,8 @@ static int __osp_md_declare_object_create(const struct lu_env *env,
        struct dt_update_request        *update;
        int                             rc;
 
-       update = dt_update_request_find_or_create(th, dt);
-       if (IS_ERR(update)) {
-               CERROR("%s: Get OSP update buf failed: rc = %d\n",
-                      dt->do_lu.lo_dev->ld_obd->obd_name,
-                      (int)PTR_ERR(update));
-               return PTR_ERR(update);
-       }
+       update = thandle_to_dt_update_request(th);
+       LASSERT(update != NULL);
 
        if (lu_object_exists(&dt->do_lu)) {
                /* If the object already exists, we needs to destroy
@@ -245,13 +240,8 @@ static int __osp_md_ref_del(const struct lu_env *env, struct dt_object *dt,
        struct dt_update_request        *update;
        int                             rc;
 
-       update = dt_update_request_find_or_create(th, dt);
-       if (IS_ERR(update)) {
-               CERROR("%s: Get OSP update buf failed: rc = %d\n",
-                      dt->do_lu.lo_dev->ld_obd->obd_name,
-                     (int)PTR_ERR(update));
-               return PTR_ERR(update);
-       }
+       update = thandle_to_dt_update_request(th);
+       LASSERT(update != NULL);
 
        rc = out_ref_del_pack(env, &update->dur_buf,
                              lu_object_fid(&dt->do_lu),
@@ -330,13 +320,8 @@ static int __osp_md_ref_add(const struct lu_env *env, struct dt_object *dt,
        struct dt_update_request        *update;
        int                             rc;
 
-       update = dt_update_request_find_or_create(th, dt);
-       if (IS_ERR(update)) {
-               CERROR("%s: Get OSP update buf failed: rc = %d\n",
-                      dt->do_lu.lo_dev->ld_obd->obd_name,
-                      (int)PTR_ERR(update));
-               return PTR_ERR(update);
-       }
+       update = thandle_to_dt_update_request(th);
+       LASSERT(update != NULL);
 
        rc = out_ref_add_pack(env, &update->dur_buf,
                              lu_object_fid(&dt->do_lu),
@@ -443,13 +428,8 @@ int __osp_md_attr_set(const struct lu_env *env, struct dt_object *dt,
        struct dt_update_request        *update;
        int                             rc;
 
-       update = dt_update_request_find_or_create(th, dt);
-       if (IS_ERR(update)) {
-               CERROR("%s: Get OSP update buf failed: %d\n",
-                      dt->do_lu.lo_dev->ld_obd->obd_name,
-                      (int)PTR_ERR(update));
-               return PTR_ERR(update);
-       }
+       update = thandle_to_dt_update_request(th);
+       LASSERT(update != NULL);
 
        rc = out_attr_set_pack(env, &update->dur_buf,
                               lu_object_fid(&dt->do_lu), attr,
@@ -722,20 +702,23 @@ static int __osp_md_index_insert(const struct lu_env *env,
                                 const struct dt_key *key,
                                 struct thandle *th)
 {
-       struct dt_update_request *update;
+       struct osp_thandle       *oth = thandle_to_osp_thandle(th);
+       struct dt_update_request *update = oth->ot_dur;
        int                      rc;
 
-       update = dt_update_request_find_or_create(th, dt);
-       if (IS_ERR(update)) {
-               CERROR("%s: Get OSP update buf failed: rc = %d\n",
-                      dt->do_lu.lo_dev->ld_obd->obd_name,
-                      (int)PTR_ERR(update));
-               return PTR_ERR(update);
-       }
 
        rc = out_index_insert_pack(env, &update->dur_buf,
                                   lu_object_fid(&dt->do_lu), rec, key,
                                   update->dur_batchid);
+       if (rc != 0)
+               return rc;
+
+       /* Before async update is allowed, if it will insert remote
+        * name entry, it should make sure the local object is created,
+        * i.e. the remote update RPC should be sent after local
+        * update(create object) */
+       oth->ot_send_updates_after_local_trans = true;
+
        return rc;
 }
 
@@ -829,13 +812,8 @@ static int __osp_md_index_delete(const struct lu_env *env,
        struct dt_update_request *update;
        int                      rc;
 
-       update = dt_update_request_find_or_create(th, dt);
-       if (IS_ERR(update)) {
-               CERROR("%s: Get OSP update buf failed: rc = %d\n",
-                      dt->do_lu.lo_dev->ld_obd->obd_name,
-                      (int)PTR_ERR(update));
-               return PTR_ERR(update);
-       }
+       update = thandle_to_dt_update_request(th);
+       LASSERT(update != NULL);
 
        rc = out_index_delete_pack(env, &update->dur_buf,
                                   lu_object_fid(&dt->do_lu), key,
@@ -1226,13 +1204,8 @@ static ssize_t osp_md_declare_write(const struct lu_env *env,
        struct dt_update_request  *update;
        ssize_t                   rc;
 
-       update = dt_update_request_find_or_create(th, dt);
-       if (IS_ERR(update)) {
-               CERROR("%s: Get OSP update buf failed: rc = %d\n",
-                      dt->do_lu.lo_dev->ld_obd->obd_name,
-                      (int)PTR_ERR(update));
-               return PTR_ERR(update);
-       }
+       update = thandle_to_dt_update_request(th);
+       LASSERT(update != NULL);
 
        rc = out_write_pack(env, &update->dur_buf, lu_object_fid(&dt->do_lu),
                            buf, pos, update->dur_batchid);