Whamcloud - gitweb
LU-3540 lod: update recovery thread
[fs/lustre-release.git] / lustre / include / lustre_update.h
index 8a42fb8..1417804 100644 (file)
@@ -102,6 +102,23 @@ update_params_get_param(const struct update_params *params,
        return param;
 }
 
+static inline void*
+update_params_get_param_buf(const struct update_params *params, __u16 index,
+                           unsigned int param_count, __u16 *size)
+{
+       struct object_update_param *param;
+
+       param = update_params_get_param(params, (unsigned int)index,
+                                       param_count);
+       if (param == NULL)
+               return NULL;
+
+       if (size != NULL)
+               *size = param->oup_len;
+
+       return &param->oup_buf[0];
+}
+
 struct update_op {
        struct lu_fid uop_fid;
        __u16   uop_type;
@@ -377,6 +394,59 @@ struct sub_thandle {
        bool                    st_committed:1;
 };
 
+struct tx_arg;
+typedef int (*tx_exec_func_t)(const struct lu_env *env, struct thandle *th,
+                             struct tx_arg *ta);
+
+/* Structure for holding one update executation */
+struct tx_arg {
+       tx_exec_func_t           exec_fn;
+       tx_exec_func_t           undo_fn;
+       struct dt_object        *object;
+       const char              *file;
+       struct object_update_reply *reply;
+       int                      line;
+       int                      index;
+       union {
+               struct {
+                       struct dt_insert_rec     rec;
+                       const struct dt_key     *key;
+               } insert;
+               struct {
+               } ref;
+               struct {
+                       struct lu_attr   attr;
+               } attr_set;
+               struct {
+                       struct lu_buf    buf;
+                       const char      *name;
+                       int              flags;
+                       __u32            csum;
+               } xattr_set;
+               struct {
+                       struct lu_attr                  attr;
+                       struct dt_allocation_hint       hint;
+                       struct dt_object_format         dof;
+                       struct lu_fid                   fid;
+               } create;
+               struct {
+                       struct lu_buf   buf;
+                       loff_t          pos;
+               } write;
+               struct {
+                       struct ost_body     *body;
+               } destroy;
+       } u;
+};
+
+/* Structure for holding all update executations of one transaction */
+struct thandle_exec_args {
+       struct thandle          *ta_handle;
+       int                     ta_argno;   /* used args */
+       int                     ta_alloc_args; /* allocated args count */
+       struct tx_arg           **ta_args;
+};
+
 /* target/out_lib.c */
 int out_update_pack(const struct lu_env *env, struct object_update *update,
                    size_t max_update_size, enum update_type op,
@@ -466,6 +536,9 @@ static inline void top_multiple_thandle_put(struct top_multiple_thandle *tmt)
 
 struct sub_thandle *lookup_sub_thandle(struct top_multiple_thandle *tmt,
                                       struct dt_device *dt_dev);
+int sub_thandle_trans_create(const struct lu_env *env,
+                            struct top_thandle *top_th,
+                            struct sub_thandle *st);
 
 /* update_records.c */
 int update_records_create_pack(const struct lu_env *env,