+#ifndef HAVE_I_UID_READ
+static inline uid_t i_uid_read(const struct inode *inode)
+{
+ return inode->i_uid;
+}
+
+static inline gid_t i_gid_read(const struct inode *inode)
+{
+ return inode->i_gid;
+}
+
+static inline void i_uid_write(struct inode *inode, uid_t uid)
+{
+ inode->i_uid = uid;
+}
+
+static inline void i_gid_write(struct inode *inode, gid_t gid)
+{
+ inode->i_gid = gid;
+}
+#endif
+
+#ifdef HAVE_PROJECT_QUOTA
+static inline __u32 i_projid_read(struct inode *inode)
+{
+ return (__u32)from_kprojid(&init_user_ns, LDISKFS_I(inode)->i_projid);
+}
+
+static inline void i_projid_write(struct inode *inode, __u32 projid)
+{
+ kprojid_t kprojid;
+ kprojid = make_kprojid(&init_user_ns, (projid_t)projid);
+ LDISKFS_I(inode)->i_projid = kprojid;
+}
+#else
+static inline uid_t i_projid_read(struct inode *inode)
+{
+ return 0;
+}
+static inline void i_projid_write(struct inode *inode, __u32 projid)
+{
+ return;
+}
+#endif
+
+#ifdef HAVE_LDISKFS_INFO_JINODE
+# define osd_attach_jinode(inode) ldiskfs_inode_attach_jinode(inode)
+#else /* HAVE_LDISKFS_INFO_JINODE */
+# define osd_attach_jinode(inode) 0
+#endif /* HAVE_LDISKFS_INFO_JINODE */
+
+#ifdef LDISKFS_HT_MISC
+# define osd_journal_start_sb(sb, type, nblock) \
+ ldiskfs_journal_start_sb(sb, type, nblock)
+static inline struct buffer_head *osd_ldiskfs_append(handle_t *handle,
+ struct inode *inode,
+ ldiskfs_lblk_t *nblock)
+{
+ int rc;
+
+ rc = osd_attach_jinode(inode);
+ if (rc)
+ return ERR_PTR(rc);
+ return ldiskfs_append(handle, inode, nblock);
+}
+# define osd_ldiskfs_find_entry(dir, name, de, inlined, lock) \
+ (__ldiskfs_find_entry(dir, name, de, inlined, lock) ?: \
+ ERR_PTR(-ENOENT))
+# define osd_journal_start(inode, type, nblocks) \
+ ldiskfs_journal_start(inode, type, nblocks)
+# define osd_transaction_size(dev) \
+ (osd_journal(dev)->j_max_transaction_buffers / 2)
+#else
+# define LDISKFS_HT_MISC 0
+# define osd_journal_start_sb(sb, type, nblock) \
+ ldiskfs_journal_start_sb(sb, nblock)