[Concept,13/15] ext4l: Add move_extent.c to the build

Message ID 20251221212028.857348-14-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>

Add support for extent-moving for write operations.

Use ext4_uboot.h compatibility layer and add stubs for:
- down_write_nested - forwards to down_write
- filemap_release_folio, IS_SWAPFILE, PAGE_MASK
- lock_two_nondirectories, unlock_two_nondirectories

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

 fs/ext4l/Makefile      |  2 +-
 fs/ext4l/ext4_uboot.h  | 26 ++++++++++++++++++++++++++
 fs/ext4l/move_extent.c |  5 +----
 3 files changed, 28 insertions(+), 5 deletions(-)
  

Patch

diff --git a/fs/ext4l/Makefile b/fs/ext4l/Makefile
index df3c016e3c1..4afcc43e34f 100644
--- a/fs/ext4l/Makefile
+++ b/fs/ext4l/Makefile
@@ -8,7 +8,7 @@  obj-y := interface.o stub.o
 obj-y	+= balloc.o bitmap.o block_validity.o dir.o ext4_jbd2.o extents.o \
 		extents_status.o file.o fsync.o hash.o ialloc.o \
 		indirect.o inline.o inode.o mballoc.o migrate.o \
-		mmp.o namei.o page-io.o readpage.o \
+		mmp.o move_extent.o namei.o page-io.o readpage.o \
 		super.o symlink.o xattr.o \
 		xattr_hurd.o xattr_trusted.o \
 		xattr_user.o fast_commit.o orphan.o
diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 409391dda20..617ec9a8afe 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -2943,4 +2943,30 @@  static inline struct new_utsname *init_utsname(void)
 	return &uts;
 }
 
+/*
+ * Stubs for move_extent.c
+ */
+
+/* down_write_nested - nested write lock acquisition */
+#define down_write_nested(sem, subclass) \
+	do { (void)(sem); (void)(subclass); } while (0)
+
+/* filemap_release_folio - try to release a folio */
+#define filemap_release_folio(folio, gfp) \
+	({ (void)(folio); (void)(gfp); 1; })
+
+/* IS_SWAPFILE - check if inode is a swap file */
+#define IS_SWAPFILE(inode)	({ (void)(inode); 0; })
+
+/* PAGE_MASK - mask for page alignment */
+#ifndef PAGE_MASK
+#define PAGE_MASK	(~(PAGE_SIZE - 1))
+#endif
+
+/* lock_two_nondirectories - lock two inodes in order */
+#define lock_two_nondirectories(i1, i2) \
+	do { (void)(i1); (void)(i2); } while (0)
+#define unlock_two_nondirectories(i1, i2) \
+	do { (void)(i1); (void)(i2); } while (0)
+
 #endif /* __EXT4_UBOOT_H__ */
diff --git a/fs/ext4l/move_extent.c b/fs/ext4l/move_extent.c
index 4b091c21908..db3066b22a8 100644
--- a/fs/ext4l/move_extent.c
+++ b/fs/ext4l/move_extent.c
@@ -5,10 +5,7 @@ 
  *            Akira Fujita <a-fujita@rs.jp.nec.com>
  */
 
-#include <linux/fs.h>
-#include <linux/quotaops.h>
-#include <linux/slab.h>
-#include <linux/sched/mm.h>
+#include "ext4_uboot.h"
 #include "ext4_jbd2.h"
 #include "ext4.h"
 #include "ext4_extents.h"