Whamcloud - gitweb
LU-3536 lod: record update for cross-MDT operation
[fs/lustre-release.git] / lustre / target / update_trans.c
index b57fbe8..8ecf3a6 100644 (file)
@@ -53,6 +53,7 @@
 #include <lustre_update.h>
 #include <obd.h>
 #include <obd_class.h>
+#include <tgt_internal.h>
 
 /**
  * Create the top transaction.
@@ -85,8 +86,10 @@ top_trans_create(const struct lu_env *env, struct dt_device *master_dev)
        top_th->tt_magic = TOP_THANDLE_MAGIC;
        top_th->tt_master_sub_thandle = child_th;
        child_th->th_top = &top_th->tt_super;
-       INIT_LIST_HEAD(&top_th->tt_sub_thandle_list);
+
+       top_th->tt_update_records = NULL;
        top_th->tt_super.th_top = &top_th->tt_super;
+       INIT_LIST_HEAD(&top_th->tt_sub_thandle_list);
 
        return &top_th->tt_super;
 }
@@ -110,7 +113,11 @@ int top_trans_start(const struct lu_env *env, struct dt_device *master_dev,
        struct top_thandle      *top_th = container_of(th, struct top_thandle,
                                                       tt_super);
        struct sub_thandle      *lst;
-       int                     rc = 0;
+       int                     rc;
+
+       rc = check_and_prepare_update_record(env, th);
+       if (rc < 0)
+               return rc;
 
        LASSERT(top_th->tt_magic == TOP_THANDLE_MAGIC);
        list_for_each_entry(lst, &top_th->tt_sub_thandle_list, st_sub_list) {
@@ -148,11 +155,22 @@ int top_trans_stop(const struct lu_env *env, struct dt_device *master_dev,
        struct sub_thandle      *lst;
        struct top_thandle      *top_th = container_of(th, struct top_thandle,
                                                       tt_super);
+       struct thandle_update_records *tur = top_th->tt_update_records;
        int                     rc;
        ENTRY;
 
        /* Note: we always need walk through all of sub_transaction to do
         * transaction stop to release the resource here */
+       if (tur != NULL) {
+               rc = merge_params_updates_buf(env, tur);
+               if (rc == 0) {
+                       struct update_records *record;
+
+                       record = &tur->tur_update_records->lur_update_rec;
+                       update_records_dump(record, D_INFO, false);
+               }
+       }
+
        LASSERT(top_th->tt_magic == TOP_THANDLE_MAGIC);
 
        top_th->tt_master_sub_thandle->th_local = th->th_local;
@@ -233,6 +251,7 @@ struct thandle *thandle_get_sub_by_dt(const struct lu_env *env,
        INIT_LIST_HEAD(&lst->st_sub_list);
        lst->st_sub_th = sub_th;
        list_add(&lst->st_sub_list, &top_th->tt_sub_thandle_list);
+       lst->st_record_update = 1;
 
        RETURN(sub_th);
 }