+# LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
+#
+# kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
+# ext4: avoid declaring fs inconsistent due to invalid file handles
+# __ext4_find_entry became a helper function for ext4_find_entry
+# conflicting with previous ldiskfs patches.
+# ldiskfs patches map ext4_find_entry to ldiskfs_find_entry_locked to
+# avoid conflicting with __ext4_find_entry
+#
+# When the following check succeeds __ext4_find_entry helper is not
+# used.
+#
+AC_DEFUN([LB_SRC_LDISKFS_FIND_ENTRY_LOCKED_EXISTS], [
+ LB2_LINUX_TEST_SRC([ldiskfs_find_entry_locked], [
+ #include <linux/fs.h>
+ #include "$EXT4_SRC_DIR/ext4.h"
+ #include "$EXT4_SRC_DIR/namei.c"
+
+ static int __ext4_find_entry(void) { return 0; }
+ ],[
+ int x = __ext4_find_entry();
+ (void)x;
+ ],[-Werror])
+])
+AC_DEFUN([LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS], [
+ LB2_MSG_LINUX_TEST_RESULT([if __ldiskfs_find_entry is available],
+ [ldiskfs_find_entry_locked], [
+ AC_DEFINE(HAVE___LDISKFS_FIND_ENTRY, 1,
+ [if __ldiskfs_find_entry is available])
+ ])
+]) # LB_LDISKFS_FIND_ENTRY_LOCKED_EXISTS
+
+#
+# LB_LDISKFSFS_DIRHASH_WANTS_DIR
+#
+# kernel 5.2 commit 8a363970d1dc38c4ec4ad575c862f776f468d057
+# ext4fs_dirhash UNICODE support
+#
+AC_DEFUN([LB_SRC_LDISKFSFS_DIRHASH_WANTS_DIR], [
+ LB2_LINUX_TEST_SRC([ext4fs_dirhash], [
+ #include <linux/fs.h>
+ #include "$EXT4_SRC_DIR/ext4.h"
+ ],[
+ int f = ext4fs_dirhash(NULL, NULL, 0, NULL);
+ (void)f;
+ ],[-Werror],[],[ext4fs_dirhash])
+])
+AC_DEFUN([LB_LDISKFSFS_DIRHASH_WANTS_DIR], [
+ LB2_MSG_LINUX_TEST_RESULT([if ldiskfsfs_dirhash takes an inode argument],
+ [ext4fs_dirhash], [
+ AC_DEFINE(HAVE_LDISKFSFS_DIRHASH_WITH_DIR, 1,
+ [if ldiskfsfs_dirhash takes an inode argument])
+ ])
+]) # LB_LDISKFSFS_DIRHASH_WANTS_DIR
+
+#
+# LB_JBD2_H_TOTAL_CREDITS
+#
+# kernel 5.5 commit 933f1c1e0b75bbc29730eef07c9e196c6dfd37e5
+# jbd2: Reserve space for revoke descriptor blocks
+#
+AC_DEFUN([LB_SRC_JBD2_H_TOTAL_CREDITS], [
+ LB2_LINUX_TEST_SRC([handle_t_h_revoke_credits], [
+ #include <linux/jbd2.h>
+ ],[
+ int x = offsetof(struct jbd2_journal_handle, h_total_credits);
+ (void)x;
+ ],[-Werror])
+])
+AC_DEFUN([LB_JBD2_H_TOTAL_CREDITS], [
+ LB2_MSG_LINUX_TEST_RESULT([if struct jbd2_journal_handle has h_total_credits member],
+ [handle_t_h_revoke_credits], [
+ AC_DEFINE(HAVE_JOURNAL_TOTAL_CREDITS, 1,
+ [struct jbd2_journal_handle has h_total_credits member])
+ ])
+]) # LB_JBD2_H_TOTAL_CREDITS
+
+#
+# LB_EXT4_INC_DEC_COUNT_2ARGS
+#
+# Linux v5.9-rc7-8-g15ed2851b0f4
+# ext4: remove unused argument from ext4_(inc|dec)_count
+#
+AC_DEFUN([LB_EXT4_INC_DEC_COUNT_2ARGS], [
+ AC_MSG_CHECKING([if ext4_(inc|dec)_count() have 2 arguments])
+ AS_IF([grep -q -E 'void ext4_inc_count.handle_t \*handle' $EXT4_SRC_DIR/namei.c],[
+ AC_DEFINE(HAVE_EXT4_INC_DEC_COUNT_2ARGS, 1,
+ [ext4_(inc|dec)_count() has 2 arguments])
+ AC_MSG_RESULT(yes)
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+]) # LB_EXT4_INC_DEC_COUNT_2ARGS
+
+#
+# LB_JBD2_JOURNAL_GET_MAX_TXN_BUFS
+# Linux commit v5.10-rc2-9-gede7dc7fa0af
+# jbd2: rename j_maxlen to j_total_len and add jbd2_journal_max_txn_bufs
+#
+AC_DEFUN([LB_SRC_JBD2_JOURNAL_GET_MAX_TXN_BUFS], [
+ LB2_LINUX_TEST_SRC([jbd2_journal_get_max_txn_bufs], [
+ #include <linux/jbd2.h>
+ ],[
+ journal_t *journal = NULL;
+ int x = jbd2_journal_get_max_txn_bufs(journal);
+ (void)x;
+ ],[-Werror],[],[])
+])
+AC_DEFUN([LB_JBD2_JOURNAL_GET_MAX_TXN_BUFS], [
+ LB2_MSG_LINUX_TEST_RESULT([if jbd2_journal_get_max_txn_bufs is available],
+ [jbd2_journal_get_max_txn_bufs], [
+ AC_DEFINE(HAVE_JBD2_JOURNAL_GET_MAX_TXN_BUFS, 1,
+ [if jbd2_journal_get_max_txn_bufs is available])
+ ])
+]) # LB_JBD2_JOURNAL_GET_MAX_TXN_BUFS
+
+#
+# LB_EXT4_JOURNAL_GET_WRITE_ACCESS_4A
+#
+# Linux v5.14-rc2-19-g188c299e2a26
+# ext4: Support for checksumming from journal triggers
+#
+AC_DEFUN([LB_EXT4_JOURNAL_GET_WRITE_ACCESS_4A], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if jbd2_journal_get_max_txn_bufs is available],
+ext4_journal_get_write_access, [
+ #include <linux/fs.h>
+ #include "$EXT4_SRC_DIR/ext4.h"
+ #include "$EXT4_SRC_DIR/ext4_jbd2.h"
+
+ int __ext4_journal_get_write_access(const char *where, unsigned int line,
+ handle_t *handle,
+ struct super_block *sb,
+ struct buffer_head *bh,
+ enum ext4_journal_trigger_type trigger_type)
+ {
+ return 0;
+ }
+],[
+ handle_t *handle = NULL;
+ struct super_block *sb = NULL;
+ struct buffer_head *bh = NULL;
+ enum ext4_journal_trigger_type trigger_type = EXT4_JTR_NONE;
+ int err = ext4_journal_get_write_access(handle, sb, bh, trigger_type);
+
+ (void)err;
+],[
+ AC_DEFINE(HAVE_EXT4_JOURNAL_GET_WRITE_ACCESS_4ARGS, 1,
+ [ext4_journal_get_write_access() has 4 arguments])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LB_EXT4_JOURNAL_GET_WRITE_ACCESS_4A
+
+#
+# LB_HAVE_INODE_LOCK_SHARED
+#
+AC_DEFUN([LB_HAVE_INODE_LOCK_SHARED], [
+LB_CHECK_COMPILE([if inode_lock_shared() defined],
+inode_lock_shared, [
+ #include <linux/fs.h>
+],[
+ struct inode i;
+
+ inode_lock_shared(&i);
+],[
+ AC_DEFINE(HAVE_INODE_LOCK_SHARED, 1,
+ [inode_lock_shared() defined])
+])
+]) # LB_HAVE_INODE_LOCK_SHARED
+
+#
+# LB_HAVE_INODE_IVERSION
+#
+AC_DEFUN([LB_HAVE_INODE_IVERSION], [
+LB_CHECK_COMPILE([if iversion primitives defined],
+inode_set_iversion, [
+ #include <linux/iversion.h>
+],[
+ struct inode i;
+
+ inode_set_iversion(&i, 0);
+],[
+ AC_DEFINE(HAVE_INODE_IVERSION, 1,
+ [iversion primitives defined])
+])
+]) # LB_HAVE_INODE_IVERSION
+
+#