Whamcloud - gitweb
LU-3536 lod: Separate thandle to different layers.
[fs/lustre-release.git] / lustre / include / lustre_update.h
index c75e4fb..861d631 100644 (file)
 #ifndef _LUSTRE_UPDATE_H
 #define _LUSTRE_UPDATE_H
 #include <lustre_net.h>
+#include <dt_object.h>
 
 #define OUT_UPDATE_INIT_BUFFER_SIZE    4096
 #define OUT_UPDATE_REPLY_SIZE          8192
 
-struct dt_object;
-struct dt_object_hint;
-struct dt_object_format;
-struct dt_allocation_hint;
 struct dt_key;
 struct dt_rec;
-struct thandle;
 
 struct update_buffer {
        struct object_update_request    *ub_req;
        size_t                          ub_req_size;
 };
 
+#define TOP_THANDLE_MAGIC      0x20140917
+/* {top,sub}_thandle are used to manage distributed transactions which
+ * include updates on several nodes. A top_handle represents the
+ * whole operation, and sub_thandle represents updates on each node. */
+struct top_thandle {
+       struct thandle          tt_super;
+       __u32                   tt_magic;
+       /* The master sub transaction. */
+       struct thandle          *tt_master_sub_thandle;
+
+       /* Other sub thandle will be listed here. */
+       struct list_head        tt_sub_thandle_list;
+};
+
+struct sub_thandle {
+       /* point to the osd/osp_thandle */
+       struct thandle          *st_sub_th;
+       struct list_head        st_sub_list;
+};
+
 /**
  * Tracking the updates being executed on this dt_device.
  */
 struct dt_update_request {
        struct dt_device                *dur_dt;
        /* attached itself to thandle */
-       struct list_head                dur_list;
        int                             dur_flags;
        /* update request result */
        int                             dur_rc;
@@ -167,13 +182,9 @@ static inline void update_inc_batchid(struct dt_update_request *update)
 }
 
 /* target/out_lib.c */
-struct thandle_update;
-struct dt_update_request *out_find_update(struct thandle_update *tu,
-                                         struct dt_device *dt_dev);
 void dt_update_request_destroy(struct dt_update_request *update);
 struct dt_update_request *dt_update_request_create(struct dt_device *dt);
-struct dt_update_request *dt_update_request_find_or_create(struct thandle *th,
-                                                         struct dt_object *dt);
+
 int out_update_pack(const struct lu_env *env, struct update_buffer *ubuf,
                    enum update_type op, const struct lu_fid *fid,
                    int params_count, __u16 *param_sizes, const void **bufs,
@@ -214,4 +225,27 @@ int out_index_lookup_pack(const struct lu_env *env, struct update_buffer *ubuf,
                          const struct dt_key *key);
 int out_xattr_get_pack(const struct lu_env *env, struct update_buffer *ubuf,
                       const struct lu_fid *fid, const char *name);
+
+/* target/update_trans.c */
+struct thandle *thandle_get_sub_by_dt(const struct lu_env *env,
+                                     struct thandle *th,
+                                     struct dt_device *sub_dt);
+
+static inline struct thandle *
+thandle_get_sub(const struct lu_env *env, struct thandle *th,
+                const struct dt_object *sub_obj)
+{
+       return thandle_get_sub_by_dt(env, th, lu2dt_dev(sub_obj->do_lu.lo_dev));
+}
+
+struct thandle *
+top_trans_create(const struct lu_env *env, struct dt_device *master_dev);
+
+int top_trans_start(const struct lu_env *env, struct dt_device *master_dev,
+                   struct thandle *th);
+
+int top_trans_stop(const struct lu_env *env, struct dt_device *master_dev,
+                  struct thandle *th);
+
+void top_thandle_destroy(struct top_thandle *top_th);
 #endif