+static inline struct osd_oi *osd_fid2oi(struct osd_device *osd,
+ const struct lu_fid *fid)
+{
+ LASSERT(!fid_is_idif(fid));
+ LASSERT(!fid_is_igif(fid));
+ LASSERT(osd->od_oi_table != NULL && osd->od_oi_count >= 1);
+ /* It can work even od_oi_count equals to 1 although it's unexpected,
+ * the only reason we set it to 1 is for performance measurement */
+ return osd->od_oi_table[fid->f_seq & (osd->od_oi_count - 1)];
+}
+
+extern const struct lu_device_operations osd_lu_ops;
+
+static inline int lu_device_is_osd(const struct lu_device *d)
+{
+ return ergo(d != NULL && d->ld_ops != NULL, d->ld_ops == &osd_lu_ops);
+}
+
+static inline struct osd_device *osd_dt_dev(const struct dt_device *d)
+{
+ LASSERT(lu_device_is_osd(&d->dd_lu_dev));
+ return container_of0(d, struct osd_device, od_dt_dev);
+}
+
+static inline struct osd_device *osd_dev(const struct lu_device *d)
+{
+ LASSERT(lu_device_is_osd(d));
+ return osd_dt_dev(container_of0(d, struct dt_device, dd_lu_dev));
+}
+
+static inline struct osd_device *osd_obj2dev(const struct osd_object *o)
+{
+ return osd_dev(o->oo_dt.do_lu.lo_dev);
+}
+
+static inline struct super_block *osd_sb(const struct osd_device *dev)
+{
+ return dev->od_mount->lmi_mnt->mnt_sb;
+}
+
+static inline int osd_object_is_root(const struct osd_object *obj)
+{
+ return osd_sb(osd_obj2dev(obj))->s_root->d_inode == obj->oo_inode;
+}
+
+static inline struct osd_object *osd_obj(const struct lu_object *o)
+{
+ LASSERT(lu_device_is_osd(o->lo_dev));
+ return container_of0(o, struct osd_object, oo_dt.do_lu);
+}
+
+static inline struct osd_object *osd_dt_obj(const struct dt_object *d)
+{
+ return osd_obj(&d->do_lu);
+}
+
+static inline struct lu_device *osd2lu_dev(struct osd_device *osd)
+{
+ return &osd->od_dt_dev.dd_lu_dev;
+}
+
+static inline journal_t *osd_journal(const struct osd_device *dev)
+{
+ return LDISKFS_SB(osd_sb(dev))->s_journal;
+}
+
+extern const struct dt_body_operations osd_body_ops;
+extern struct lu_context_key osd_key;
+
+static inline struct osd_thread_info *osd_oti_get(const struct lu_env *env)
+{
+ return lu_context_key_get(&env->le_ctx, &osd_key);
+}
+
+extern const struct dt_body_operations osd_body_ops_new;
+
+/**
+ * IAM Iterator
+ */
+static inline
+struct iam_path_descr *osd_it_ipd_get(const struct lu_env *env,
+ const struct iam_container *bag)
+{
+ return bag->ic_descr->id_ops->id_ipd_alloc(bag,
+ osd_oti_get(env)->oti_it_ipd);
+}
+
+static inline
+struct iam_path_descr *osd_idx_ipd_get(const struct lu_env *env,
+ const struct iam_container *bag)
+{
+ return bag->ic_descr->id_ops->id_ipd_alloc(bag,
+ osd_oti_get(env)->oti_idx_ipd);
+}
+
+static inline void osd_ipd_put(const struct lu_env *env,
+ const struct iam_container *bag,
+ struct iam_path_descr *ipd)
+{
+ bag->ic_descr->id_ops->id_ipd_free(ipd);
+}
+
+int osd_ldiskfs_read(struct inode *inode, void *buf, int size, loff_t *offs);
+
+static inline
+struct dentry *osd_child_dentry_by_inode(const struct lu_env *env,
+ struct inode *inode,
+ const char *name, const int namelen)
+{
+ struct osd_thread_info *info = osd_oti_get(env);
+ struct dentry *child_dentry = &info->oti_child_dentry;
+ struct dentry *obj_dentry = &info->oti_obj_dentry;
+
+ obj_dentry->d_inode = inode;
+ obj_dentry->d_sb = inode->i_sb;
+ obj_dentry->d_name.hash = 0;
+
+ child_dentry->d_name.hash = 0;
+ child_dentry->d_parent = obj_dentry;
+ child_dentry->d_name.name = name;
+ child_dentry->d_name.len = namelen;
+ return child_dentry;
+}
+
+/**
+ * Helper function to pack the fid, ldiskfs stores fid in packed format.