Whamcloud - gitweb
LU-103 Add support for test groups.
[fs/lustre-release.git] / lustre / include / dt_object.h
index 4d33e83..a45cd28 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
@@ -101,7 +101,7 @@ struct dt_device_operations {
          * Return device-wide statistics.
          */
         int   (*dt_statfs)(const struct lu_env *env,
-                           struct dt_device *dev, struct kstatfs *sfs);
+                           struct dt_device *dev, cfs_kstatfs_t *sfs);
         /**
          * Start transaction, described by \a param.
          */
@@ -242,6 +242,9 @@ struct dt_object_format {
 
 enum dt_format_type dt_mode_to_dft(__u32 mode);
 
+/** Version type. May differ in DMU and ldiskfs */
+typedef __u64 dt_obj_version_t;
+
 /**
  * Per-dt-object operations.
  */
@@ -254,6 +257,8 @@ struct dt_object_operations {
                                 struct dt_object *dt);
         void  (*do_write_unlock)(const struct lu_env *env,
                                  struct dt_object *dt);
+        int  (*do_write_locked)(const struct lu_env *env,
+                                struct dt_object *dt);
         /**
          * Note: following ->do_{x,}attr_{set,get}() operations are very
          * similar to ->moo_{x,}attr_{set,get}() operations in struct
@@ -329,7 +334,7 @@ struct dt_object_operations {
         void  (*do_ah_init)(const struct lu_env *env,
                             struct dt_allocation_hint *ah,
                             struct dt_object *parent,
-                            umode_t child_mode);
+                            cfs_umode_t child_mode);
         /**
          * Create new object on this device.
          *
@@ -371,6 +376,10 @@ struct dt_object_operations {
                                         struct lustre_capa *old,
                                         __u64 opc);
         int (*do_object_sync)(const struct lu_env *, struct dt_object *);
+        dt_obj_version_t (*do_version_get)(const struct lu_env *env,
+                                           struct dt_object *dt);
+        void (*do_version_set)(const struct lu_env *env, struct dt_object *dt,
+                               dt_obj_version_t new_version);
         /**
          * Get object info of next level. Currently, only get inode from osd.
          * This is only used by quota b=16542
@@ -462,8 +471,10 @@ struct dt_index_operations {
                                       const struct dt_it *di);
                 int       (*key_size)(const struct lu_env *env,
                                       const struct dt_it *di);
-                struct dt_rec *(*rec)(const struct lu_env *env,
-                                      const struct dt_it *di);
+                int            (*rec)(const struct lu_env *env,
+                                      const struct dt_it *di,
+                                      struct lu_dirent *lde,
+                                      __u32 attr);
                 __u64        (*store)(const struct lu_env *env,
                                       const struct dt_it *di);
                 int           (*load)(const struct lu_env *env,
@@ -480,7 +491,7 @@ struct dt_device {
          * way, because callbacks are supposed to be added/deleted only during
          * single-threaded start-up shut-down procedures.
          */
-        struct list_head                   dd_txn_callbacks;
+        cfs_list_t                         dd_txn_callbacks;
 };
 
 int  dt_device_init(struct dt_device *dev, struct lu_device_type *t);
@@ -527,6 +538,17 @@ static inline void txn_param_init(struct txn_param *p, unsigned int credits)
         p->tp_credits = credits;
 }
 
+static inline void txn_param_credit_add(struct txn_param *p,
+                                        unsigned int credits)
+{
+        p->tp_credits += credits;
+}
+
+static inline void txn_param_sync(struct txn_param *p)
+{
+        p->tp_sync = 1;
+}
+
 /**
  * This is the general purpose transaction handle.
  * 1. Transaction Life Cycle
@@ -571,8 +593,9 @@ struct dt_txn_callback {
                             struct thandle *txn, void *cookie);
         int (*dtc_txn_commit)(const struct lu_env *env,
                               struct thandle *txn, void *cookie);
-        void            *dtc_cookie;
-        struct list_head dtc_linkage;
+        void                *dtc_cookie;
+        __u32                dtc_tag;
+        cfs_list_t           dtc_linkage;
 };
 
 void dt_txn_callback_add(struct dt_device *dev, struct dt_txn_callback *cb);
@@ -609,5 +632,40 @@ struct dt_object *dt_locate(const struct lu_env *env,
                             struct dt_device *dev,
                             const struct lu_fid *fid);
 
+static inline dt_obj_version_t do_version_get(const struct lu_env *env,
+                                              struct dt_object *o)
+{
+        LASSERT(o->do_ops->do_version_get);
+        return o->do_ops->do_version_get(env, o);
+}
+
+static inline void do_version_set(const struct lu_env *env,
+                                  struct dt_object *o, dt_obj_version_t v)
+{
+        LASSERT(o->do_ops->do_version_set);
+        return o->do_ops->do_version_set(env, o, v);
+}
+
+int dt_record_read(const struct lu_env *env, struct dt_object *dt,
+                   struct lu_buf *buf, loff_t *pos);
+int dt_record_write(const struct lu_env *env, struct dt_object *dt,
+                    const struct lu_buf *buf, loff_t *pos, struct thandle *th);
+
+
+static inline struct thandle *dt_trans_start(const struct lu_env *env,
+                                             struct dt_device *d,
+                                             struct txn_param *p)
+{
+        LASSERT(d->dd_ops->dt_trans_start);
+        return d->dd_ops->dt_trans_start(env, d, p);
+}
+
+static inline void 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);
+}
 /** @} dt */
 #endif /* __LUSTRE_DT_OBJECT_H */