Whamcloud - gitweb
LU-1795 lustre: remove LASSERT in dt_fiemap_get()
[fs/lustre-release.git] / lustre / include / dt_object.h
index 7e41e6c..c57fc00 100644 (file)
@@ -102,9 +102,14 @@ typedef void (*dt_cb_t)(struct lu_env *env, struct thandle *th,
  * Special per-transaction callback for cases when just commit callback
  * is needed and per-device callback are not convenient to use
  */
+#define TRANS_COMMIT_CB_MAGIC  0xa0a00a0a
+#define MAX_COMMIT_CB_STR_LEN  32
+
 struct dt_txn_commit_cb {
-        cfs_list_t dcb_linkage;
-        dt_cb_t    dcb_func;
+       cfs_list_t      dcb_linkage;
+       dt_cb_t         dcb_func;
+       __u32           dcb_magic;
+       char            dcb_name[MAX_COMMIT_CB_STR_LEN];
 };
 
 /**
@@ -213,6 +218,10 @@ enum dt_index_flags {
  * names to fids).
  */
 extern const struct dt_index_features dt_directory_features;
+extern const struct dt_index_features dt_otable_features;
+
+/* index features supported by the accounting objects */
+extern const struct dt_index_features dt_acct_features;
 
 /**
  * This is a general purpose dt allocation hint.
@@ -600,6 +609,32 @@ struct dt_index_operations {
         } dio_it;
 };
 
+enum dt_otable_it_valid {
+       DOIV_ERROR_HANDLE       = 0x0001,
+};
+
+enum dt_otable_it_flags {
+       /* Exit when fail. */
+       DOIF_FAILOUT    = 0x0001,
+
+       /* Reset iteration position to the device beginning. */
+       DOIF_RESET      = 0x0002,
+
+       /* There is up layer component uses the iteration. */
+       DOIF_OUTUSED    = 0x0004,
+};
+
+/* otable based iteration needs to use the common DT interation APIs.
+ * To initialize the iteration, it needs call dio_it::init() firstly.
+ * Here is how the otable based iteration should prepare arguments to
+ * call dt_it_ops::init().
+ *
+ * For otable based iteration, the 32-bits 'attr' for dt_it_ops::init()
+ * is composed of two parts:
+ * low 16-bits is for valid bits, high 16-bits is for flags bits. */
+#define DT_OTABLE_IT_FLAGS_SHIFT       16
+#define DT_OTABLE_IT_FLAGS_MASK        0xffff0000
+
 struct dt_device {
         struct lu_device                   dd_lu_dev;
         const struct dt_device_operations *dd_ops;
@@ -800,10 +835,11 @@ static inline int dt_trans_stop(const struct lu_env *env,
 }
 
 static inline int dt_trans_cb_add(struct thandle *th,
-                                  struct dt_txn_commit_cb *dcb)
+                                 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);
+       LASSERT(th->th_dev->dd_ops->dt_trans_cb_add);
+       dcb->dcb_magic = TRANS_COMMIT_CB_MAGIC;
+       return th->th_dev->dd_ops->dt_trans_cb_add(th, dcb);
 }
 /** @} dt */
 
@@ -1078,7 +1114,8 @@ static inline int dt_fiemap_get(const struct lu_env *env, struct dt_object *d,
         LASSERT(d);
         if (d->do_body_ops == NULL)
                 return -EPROTO;
-        LASSERT(d->do_body_ops->dbo_fiemap_get);
+       if (d->do_body_ops->dbo_fiemap_get == NULL)
+               return -EOPNOTSUPP;
         return d->do_body_ops->dbo_fiemap_get(env, d, fm);
 }