[Concept,06/15] jbd2: Add checkpoint.c to the build

Message ID 20251221212028.857348-7-sjg@u-boot.org
State New
Headers
Series ext4l: Add jbd2 and remaining ext4l files to build (part F) |

Commit Message

Simon Glass Dec. 21, 2025, 9:20 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Update checkpoint.c includes to use ext4_uboot.h compatibility layer.
Add jbd2/Makefile and include jbd2 in the build via fs/Makefile

Add necessary stubs and definitions:
- JBD2 trace stubs (trace_jbd2_checkpoint, etc.)
- mutex_lock_io, write_dirty_buffer, spin_needbreak stubs
- bd_dev field to struct block_device
- Temporary JBD2 function stubs until other jbd2 files are added

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/Makefile           |  1 +
 fs/ext4l/ext4_uboot.h | 14 ++++++++++++++
 fs/ext4l/stub.c       | 33 +++++++++++++++++++++++++++++++++
 fs/jbd2/Makefile      |  6 ++++++
 fs/jbd2/checkpoint.c  |  7 +------
 include/linux/fs.h    |  1 +
 6 files changed, 56 insertions(+), 6 deletions(-)
 create mode 100644 fs/jbd2/Makefile
  

Patch

diff --git a/fs/Makefile b/fs/Makefile
index a7d5df10424..b6d4f7a9cf7 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -22,6 +22,7 @@  obj-$(CONFIG_CMD_CRAMFS) += cramfs/
 obj-$(CONFIG_FS_EXFAT) += exfat/
 obj-$(CONFIG_FS_EXT4) += ext4/
 obj-$(CONFIG_FS_EXT4L) += ext4l/
+obj-$(CONFIG_FS_EXT4L) += jbd2/
 obj-$(CONFIG_FS_FAT) += fat/
 obj-$(CONFIG_FS_JFFS2) += jffs2/
 obj-$(CONFIG_SANDBOX) += sandbox/
diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 82b68056953..62815e334c8 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -2768,4 +2768,18 @@  struct wait_bit_entry {
 /* get_current_ioprio - I/O priority (not used in U-Boot) */
 #define get_current_ioprio()		(0)
 
+/* JBD2 checkpoint.c stubs */
+#define mutex_lock_io(m)		mutex_lock(m)
+#define write_dirty_buffer(bh, flags)	sync_dirty_buffer(bh)
+#define spin_needbreak(l)		({ (void)(l); 0; })
+
+/* JBD2 trace stubs */
+#define trace_jbd2_checkpoint(j, r)	do { (void)(j); (void)(r); } while (0)
+#define trace_jbd2_shrink_checkpoint_list(j, f, t, l, n, d) \
+	do { (void)(j); (void)(f); (void)(t); (void)(l); (void)(n); (void)(d); } while (0)
+#define trace_jbd2_checkpoint_stats(d, tid, stats) \
+	do { (void)(d); (void)(tid); (void)(stats); } while (0)
+#define trace_jbd2_drop_transaction(j, t) \
+	do { (void)(j); (void)(t); } while (0)
+
 #endif /* __EXT4_UBOOT_H__ */
diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c
index 2b2b777d1f2..0458191c496 100644
--- a/fs/ext4l/stub.c
+++ b/fs/ext4l/stub.c
@@ -827,3 +827,36 @@  int dquot_alloc_block(struct inode *inode, loff_t nr)
 void dquot_free_block(struct inode *inode, loff_t nr)
 {
 }
+
+/*
+ * JBD2 stubs - temporary stubs until other jbd2 files are added
+ * Note: These use void* to avoid pulling in jbd2.h types which would conflict
+ */
+
+int jbd2_journal_get_log_tail(void *journal, void *tid, unsigned long *block)
+{
+	return 0;
+}
+
+int __jbd2_update_log_tail(void *journal, unsigned int tid, unsigned long block)
+{
+	return 0;
+}
+
+void *jbd2_journal_grab_journal_head(struct buffer_head *bh)
+{
+	return NULL;
+}
+
+void jbd2_journal_put_journal_head(void *jh)
+{
+}
+
+void jbd2_journal_free_transaction(void *transaction)
+{
+}
+
+int jbd2_log_start_commit(void *journal, unsigned int tid)
+{
+	return 0;
+}
diff --git a/fs/jbd2/Makefile b/fs/jbd2/Makefile
new file mode 100644
index 00000000000..03e8ba0f2ec
--- /dev/null
+++ b/fs/jbd2/Makefile
@@ -0,0 +1,6 @@ 
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for JBD2 journaling layer (used by ext4l)
+#
+
+obj-y := checkpoint.o
diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 2d0719bf6d8..994e454bb5b 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -14,13 +14,8 @@ 
  * reused.
  */
 
-#include <linux/time.h>
-#include <linux/fs.h>
+#include "../ext4l/ext4_uboot.h"
 #include <linux/jbd2.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/blkdev.h>
-#include <trace/events/jbd2.h>
 
 /*
  * Unlink a buffer from a transaction checkpoint list.
diff --git a/include/linux/fs.h b/include/linux/fs.h
index ae34b1f7356..ef28c12c022 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -65,6 +65,7 @@  struct block_device {
 	struct address_space *bd_mapping;
 	void *bd_disk;
 	struct super_block *bd_super;
+	dev_t bd_dev;
 };
 
 /* errseq functions - stubs */