Whamcloud - gitweb
LU-80 lov: large stripe count support
[fs/lustre-release.git] / lustre / include / dt_object.h
index 160f47a..db232da 100644 (file)
  * 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.
  */
 /*
+ * Copyright (c) 2011 Whamcloud, Inc.
+ */
+/*
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
@@ -68,10 +71,32 @@ struct dt_object;
 struct dt_index_features;
 struct dt_quota_ctxt;
 
+typedef enum {
+        MNTOPT_USERXATTR        = 0x00000001,
+        MNTOPT_ACL              = 0x00000002,
+} mntopt_t;
+
 struct dt_device_param {
         unsigned           ddp_max_name_len;
         unsigned           ddp_max_nlink;
         unsigned           ddp_block_shift;
+        mntopt_t           ddp_mntopts;
+        unsigned           ddp_max_ea_size;
+};
+
+/**
+ * Per-transaction commit callback function
+ */
+struct dt_txn_commit_cb;
+typedef void (*dt_cb_t)(struct lu_env *env, struct thandle *th,
+                        struct dt_txn_commit_cb *cb, int err);
+/**
+ * Special per-transaction callback for cases when just commit callback
+ * is needed and per-device callback are not convenient to use
+ */
+struct dt_txn_commit_cb {
+        cfs_list_t dcb_linkage;
+        dt_cb_t    dcb_func;
 };
 
 /**
@@ -101,7 +126,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.
          */
@@ -114,6 +139,11 @@ struct dt_device_operations {
         void  (*dt_trans_stop)(const struct lu_env *env,
                                struct thandle *th);
         /**
+         * Add commit callback to the transaction.
+         */
+        int   (*dt_trans_cb_add)(struct thandle *th,
+                                 struct dt_txn_commit_cb *dcb);
+        /**
          * Return fid of root index object.
          */
         int   (*dt_root_get)(const struct lu_env *env,
@@ -257,6 +287,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
@@ -332,7 +364,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.
          *
@@ -455,6 +487,7 @@ struct dt_index_operations {
                  */
                 struct dt_it *(*init)(const struct lu_env *env,
                                       struct dt_object *dt,
+                                      __u32 attr,
                                       struct lustre_capa *capa);
                 void          (*fini)(const struct lu_env *env,
                                       struct dt_it *di);
@@ -469,8 +502,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,
@@ -487,7 +522,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);
@@ -524,8 +559,6 @@ static inline int dt_object_exists(const struct dt_object *dt)
 struct txn_param {
         /** number of blocks this transaction will modify */
         unsigned int tp_credits;
-        /** sync transaction is needed */
-        __u32        tp_sync:1;
 };
 
 static inline void txn_param_init(struct txn_param *p, unsigned int credits)
@@ -534,6 +567,12 @@ 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;
+}
+
 /**
  * This is the general purpose transaction handle.
  * 1. Transaction Life Cycle
@@ -558,6 +597,8 @@ struct thandle {
         /** the last operation result in this transaction.
          * this value is used in recovery */
         __s32             th_result;
+        /** whether we need sync commit */
+        int               th_sync;
 };
 
 /**
@@ -576,11 +617,10 @@ struct dt_txn_callback {
                              struct txn_param *param, void *cookie);
         int (*dtc_txn_stop)(const struct lu_env *env,
                             struct thandle *txn, void *cookie);
-        int (*dtc_txn_commit)(const struct lu_env *env,
-                              struct thandle *txn, void *cookie);
-        void            *dtc_cookie;
-        __u32            dtc_tag;
-        struct list_head dtc_linkage;
+        void (*dtc_txn_commit)(struct thandle *txn, void *cookie);
+        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);
@@ -589,7 +629,7 @@ void dt_txn_callback_del(struct dt_device *dev, struct dt_txn_callback *cb);
 int dt_txn_hook_start(const struct lu_env *env,
                       struct dt_device *dev, struct txn_param *param);
 int dt_txn_hook_stop(const struct lu_env *env, struct thandle *txn);
-int dt_txn_hook_commit(const struct lu_env *env, struct thandle *txn);
+void dt_txn_hook_commit(struct thandle *txn);
 
 int dt_try_as_dir(const struct lu_env *env, struct dt_object *obj);
 
@@ -646,11 +686,17 @@ static inline struct thandle *dt_trans_start(const struct lu_env *env,
 }
 
 static inline void dt_trans_stop(const struct lu_env *env,
-                                 struct dt_device *d,
-                                 struct thandle *th)
+                                 struct dt_device *d, struct thandle *th)
 {
         LASSERT(d->dd_ops->dt_trans_stop);
         return d->dd_ops->dt_trans_stop(env, th);
 }
+
+static inline int dt_trans_cb_add(struct thandle *th,
+                                  struct dt_txn_commit_cb *dcb)
+{
+        LASSERT(th->th_dev->dd_ops->dt_trans_cb_add);
+        return th->th_dev->dd_ops->dt_trans_cb_add(th, dcb);
+}
 /** @} dt */
 #endif /* __LUSTRE_DT_OBJECT_H */