Whamcloud - gitweb
LU-3336 lfsck: use rbtree to record OST-object accessing
[fs/lustre-release.git] / lustre / include / dt_object.h
index 6a09b34..cdd321a 100644 (file)
@@ -49,7 +49,7 @@
  * @{
  */
 
-
+#include <obd_support.h>
 /*
  * super-class definitions.
  */
@@ -130,11 +130,11 @@ struct dt_device_operations {
          */
         int   (*dt_trans_start)(const struct lu_env *env,
                                 struct dt_device *dev, struct thandle *th);
-        /**
-         * Finish previously started transaction.
-         */
-        int   (*dt_trans_stop)(const struct lu_env *env,
-                               struct thandle *th);
+       /**
+        * Finish previously started transaction.
+        */
+       int   (*dt_trans_stop)(const struct lu_env *env, struct dt_device *dev,
+                              struct thandle *th);
         /**
          * Add commit callback to the transaction.
          */
@@ -229,8 +229,10 @@ extern const struct dt_index_features dt_quota_slv_features;
  * It can contain any allocation hint in the future.
  */
 struct dt_allocation_hint {
-        struct dt_object           *dah_parent;
-        __u32                       dah_mode;
+       struct dt_object        *dah_parent;
+       const void              *dah_eadata;
+       int                     dah_eadata_len;
+       __u32                   dah_mode;
 };
 
 /**
@@ -669,6 +671,7 @@ struct dt_device {
          * single-threaded start-up shut-down procedures.
          */
         cfs_list_t                         dd_txn_callbacks;
+       unsigned int                       dd_record_fid_accessed:1;
 };
 
 int  dt_device_init(struct dt_device *dev, struct lu_device_type *t);
@@ -742,6 +745,19 @@ static inline struct dt_object *lu2dt_obj(struct lu_object *o)
        return container_of0(o, struct dt_object, do_lu);
 }
 
+struct thandle_update {
+       /* In DNE, one transaction can be disassembled into
+        * updates on several different MDTs, and these updates
+        * will be attached to tu_remote_update_list per target.
+        * Only single thread will access the list, no need lock
+        */
+       struct list_head        tu_remote_update_list;
+
+       /* sent after or before local transaction */
+       unsigned int            tu_sent_after_local_trans:1,
+                               tu_only_remote_trans:1;
+};
+
 /**
  * This is the general purpose transaction handle.
  * 1. Transaction Life Cycle
@@ -760,6 +776,10 @@ struct thandle {
        /** the dt device on which the transactions are executed */
        struct dt_device *th_dev;
 
+       atomic_t        th_refc;
+       /* the size of transaction */
+       int             th_alloc_size;
+
        /** context for this transaction, tag is LCT_TX_HANDLE */
        struct lu_context th_ctx;
 
@@ -776,15 +796,22 @@ struct thandle {
        /* local transation, no need to inform other layers */
        unsigned int            th_local:1;
 
-       /* In DNE, one transaction can be disassemblied into
-        * updates on several different MDTs, and these updates
-        * will be attached to th_remote_update_list per target.
-        * Only single thread will access the list, no need lock
-        */
-       cfs_list_t              th_remote_update_list;
-       struct update_request   *th_current_request;
+       struct thandle_update   *th_update;
 };
 
+static inline void thandle_get(struct thandle *thandle)
+{
+       atomic_inc(&thandle->th_refc);
+}
+
+static inline void thandle_put(struct thandle *thandle)
+{
+       if (atomic_dec_and_test(&thandle->th_refc)) {
+               if (thandle->th_update != NULL)
+                       OBD_FREE_PTR(thandle->th_update);
+               OBD_FREE(thandle, thandle->th_alloc_size);
+       }
+}
 /**
  * Transaction call-backs.
  *
@@ -978,8 +1005,8 @@ static inline int dt_trans_start_local(const struct lu_env *env,
 static inline int dt_trans_stop(const struct lu_env *env,
                                 struct dt_device *d, struct thandle *th)
 {
-        LASSERT(d->dd_ops->dt_trans_stop);
-        return d->dd_ops->dt_trans_stop(env, th);
+       LASSERT(d->dd_ops->dt_trans_stop);
+       return d->dd_ops->dt_trans_stop(env, d, th);
 }
 
 static inline int dt_trans_cb_add(struct thandle *th,