[Concept,07/14] linux: ext4l: Mark journaled metadata buffers dirty for bh_cache_sync

Message ID 20251230205157.3383926-8-sjg@u-boot.org
State New
Headers
Series ext4l: Linux adaptation patches for ext4 write support |

Commit Message

Simon Glass Dec. 30, 2025, 8:51 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

In U-Boot's ext4l implementation, bh_cache_sync() writes all dirty
buffers to disk. However, buffers passed through the journal via
jbd2_journal_dirty_metadata() were not being marked dirty for
bh_cache_sync() to pick up.

Add mark_buffer_dirty() after jbd2_journal_dirty_metadata() to ensure
these buffers are written by bh_cache_sync(). This is needed because
U-Boot's journal implementation does not write buffers to their final
locations.

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

 fs/ext4l/ext4_jbd2.c | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Patch

diff --git a/fs/ext4l/ext4_jbd2.c b/fs/ext4l/ext4_jbd2.c
index 84a985ce3a2..d8ae15099e1 100644
--- a/fs/ext4l/ext4_jbd2.c
+++ b/fs/ext4l/ext4_jbd2.c
@@ -367,6 +367,14 @@  int __ext4_handle_dirty_metadata(const char *where, unsigned int line,
 	set_buffer_uptodate(bh);
 	if (ext4_handle_valid(handle)) {
 		err = jbd2_journal_dirty_metadata(handle, bh);
+#ifdef __UBOOT__
+		/*
+		 * Also mark buffer dirty for bh_cache_sync().
+		 * The journal may not write buffers to final locations,
+		 * so we need bh_cache_sync() to write them.
+		 */
+		mark_buffer_dirty(bh);
+#endif
 		/* Errors can only happen due to aborted journal or a nasty bug */
 		if (!is_handle_aborted(handle) && WARN_ON_ONCE(err)) {
 			ext4_journal_abort_handle(where, line, __func__, bh,