size_t dif_recsize_min;
/** maximal required record size, 0 if no limit */
size_t dif_recsize_max;
+ /** pointer size for record */
+ size_t dif_ptrsize;
};
enum dt_index_flags {
* 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;
+ __u32 dah_mode;
};
/**
+ * object type specifier.
+ */
+
+enum dt_format_type {
+ DFT_REGULAR,
+ DFT_DIR,
+ /** for mknod */
+ DFT_NODE,
+ /** for special index */
+ DFT_INDEX,
+ /** for symbolic link */
+ DFT_SYM,
+};
+
+/**
+ * object format specifier.
+ */
+struct dt_object_format {
+ /** type for dt object */
+ enum dt_format_type dof_type;
+ union {
+ struct dof_regular {
+ } dof_reg;
+ struct dof_dir {
+ } dof_dir;
+ struct dof_node {
+ } dof_node;
+ /**
+ * special index need feature as parameter to create
+ * special idx
+ */
+ struct dof_index {
+ const struct dt_index_features *di_feat;
+ } dof_idx;
+ } u;
+};
+
+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.
*/
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
int (*do_create)(const struct lu_env *env, struct dt_object *dt,
struct lu_attr *attr,
struct dt_allocation_hint *hint,
+ struct dt_object_format *dof,
struct thandle *th);
/**
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
+ * precondition: dt_object_exists(dt);
+ */
+ int (*do_data_get)(const struct lu_env *env, struct dt_object *dt,
+ void **data);
};
/**
* precondition: dt_object_exists(dt);
*/
struct dt_it *(*init)(const struct lu_env *env,
- struct dt_object *dt, int writable,
+ struct dt_object *dt,
struct lustre_capa *capa);
void (*fini)(const struct lu_env *env,
struct dt_it *di);
const struct dt_key *key);
void (*put)(const struct lu_env *env,
struct dt_it *di);
- int (*del)(const struct lu_env *env,
- struct dt_it *di, struct thandle *th);
int (*next)(const struct lu_env *env,
struct dt_it *di);
struct dt_key *(*key)(const struct lu_env *env,
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,
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
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;
};
int dt_txn_hook_commit(const struct lu_env *env, struct thandle *txn);
int dt_try_as_dir(const struct lu_env *env, struct dt_object *obj);
+
+/**
+ * Callback function used for parsing path.
+ * \see llo_store_resolve
+ */
+typedef int (*dt_entry_func_t)(const struct lu_env *env,
+ const char *name,
+ void *pvt);
+
+#define DT_MAX_PATH 1024
+
+int dt_path_parser(const struct lu_env *env,
+ char *local, dt_entry_func_t entry_func,
+ void *data);
+
struct dt_object *dt_store_open(const struct lu_env *env,
- struct dt_device *dt, const char *name,
+ struct dt_device *dt,
+ const char *dirname,
+ const char *filename,
struct lu_fid *fid);
-/** @} dt */
+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 */