Whamcloud - gitweb
LU-3336 lfsck: use rbtree to record OST-object accessing
[fs/lustre-release.git] / lustre / target / tgt_internal.h
index 02cc499..7241a3e 100644 (file)
 #include <lustre_req_layout.h>
 #include <lustre_sec.h>
 
-extern struct lu_context_key tgt_thread_key;
+extern int (*tgt_lfsck_in_notify)(const struct lu_env *env,
+                                 struct dt_device *key,
+                                 struct lfsck_request *lr);
+
+struct tx_arg;
+typedef int (*tx_exec_func_t)(const struct lu_env *env, struct thandle *th,
+                             struct tx_arg *ta);
+
+struct tx_arg {
+       tx_exec_func_t           exec_fn;
+       tx_exec_func_t           undo_fn;
+       struct dt_object        *object;
+       char                    *file;
+       struct update_reply     *reply;
+       int                      line;
+       int                      index;
+       union {
+               struct {
+                       const struct dt_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;
+};
+
+#define TX_MAX_OPS       10
+struct thandle_exec_args {
+       struct thandle          *ta_handle;
+       struct dt_device        *ta_dev;
+       struct tx_arg            ta_args[TX_MAX_OPS];
+       int                      ta_err;
+       int                      ta_argno;   /* used args */
+};
 
 /**
  * Common data shared by tg-level handlers. This is allocated per-thread to
@@ -55,8 +110,38 @@ struct tgt_thread_info {
        struct lsd_client_data   tti_lcd;
        struct lu_buf            tti_buf;
        loff_t                   tti_off;
+
+       struct lu_attr           tti_attr;
+       struct lu_fid            tti_fid1;
+
+       /* transno storage during last_rcvd update */
+       __u64                    tti_transno;
+       __u32                    tti_has_trans:1,
+                                tti_mult_trans:1;
+
+       /* Updates data for OUT target */
+       struct thandle_exec_args tti_tea;
+       union {
+               struct {
+                       /* for tgt_readpage()      */
+                       struct lu_rdpg     tti_rdpg;
+                       /* for tgt_sendpage()      */
+                       struct l_wait_info tti_wait_info;
+               } rdpg;
+               struct {
+                       struct dt_object_format  tti_update_dof;
+                       struct update_reply     *tti_update_reply;
+                       struct update           *tti_update;
+                       int                      tti_update_reply_index;
+                       struct obdo              tti_obdo;
+                       struct dt_object        *tti_dt_object;
+               } update;
+       } tti_u;
+       struct lfsck_request tti_lr;
 };
 
+extern struct lu_context_key tgt_thread_key;
+
 static inline struct tgt_thread_info *tgt_th_info(const struct lu_env *env)
 {
        struct tgt_thread_info *tti;
@@ -80,4 +165,53 @@ static inline int req_xid_is_last(struct ptlrpc_request *req)
                req->rq_xid == lcd->lcd_last_close_xid);
 }
 
+static inline char *dt_obd_name(struct dt_device *dt)
+{
+       return dt->dd_lu_dev.ld_obd->obd_name;
+}
+
+/* Update handlers */
+int out_handle(struct tgt_session_info *tsi);
+
+#define out_tx_create(info, obj, attr, fid, dof, th, reply, idx) \
+       __out_tx_create(info, obj, attr, fid, dof, th, reply, idx, \
+                       __FILE__, __LINE__)
+
+#define out_tx_attr_set(info, obj, attr, th, reply, idx) \
+       __out_tx_attr_set(info, obj, attr, th, reply, idx, \
+                         __FILE__, __LINE__)
+
+#define out_tx_xattr_set(info, obj, buf, name, fl, th, reply, idx)     \
+       __out_tx_xattr_set(info, obj, buf, name, fl, th, reply, idx,    \
+                          __FILE__, __LINE__)
+
+#define out_tx_ref_add(info, obj, th, reply, idx) \
+       __out_tx_ref_add(info, obj, th, reply, idx, __FILE__, __LINE__)
+
+#define out_tx_ref_del(info, obj, th, reply, idx) \
+       __out_tx_ref_del(info, obj, th, reply, idx, __FILE__, __LINE__)
+
+#define out_tx_index_insert(info, obj, th, name, fid, reply, idx) \
+       __out_tx_index_insert(info, obj, th, name, fid, reply, idx, \
+                             __FILE__, __LINE__)
+
+#define out_tx_index_delete(info, obj, th, name, reply, idx) \
+       __out_tx_index_delete(info, obj, th, name, reply, idx, \
+                             __FILE__, __LINE__)
+
+#define out_tx_destroy(info, obj, th, reply, idx) \
+       __out_tx_destroy(info, obj, th, reply, idx, __FILE__, __LINE__)
+
+extern struct page *tgt_page_to_corrupt;
+
+struct tgt_thread_big_cache {
+       struct niobuf_local     local[PTLRPC_MAX_BRW_PAGES];
+};
+
+int tgt_server_data_init(const struct lu_env *env, struct lu_target *tgt);
+int tgt_txn_start_cb(const struct lu_env *env, struct thandle *th,
+                    void *cookie);
+int tgt_txn_stop_cb(const struct lu_env *env, struct thandle *th,
+                   void *cookie);
+
 #endif /* _TG_INTERNAL_H */