From 4661181496ea6162ae0455fbbe7984e60a033424 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Thu, 6 Aug 2026 22:27:46 +0000 Subject: [PATCH] Compat for iomap private and write_ops arguments The iomap read/write entry points have grown arguments that el10 has picked up. Since v5.18-rc7-162-g786f847f43a5 iomap_dio_rw() takes a private pointer that it stashes in the iomap_iter for the filesystem's use, and since v6.16-rc1-11-g2a5574fc57d1 the iomap_folio_ops that used to hang off the iomap are passed to iomap_file_buffered_write() as iomap_write_ops, which also gained a private pointer of its own. We have neither per-iter state nor write ops, so the compat wrappers just pass nulls for the new arguments, which the iomap code checks for. While we're in here, drop the extern for scoutfs_iomap_page_ops. It was never defined, and struct iomap_page_ops no longer exists upstream. Signed-off-by: Auke Kok --- kmod/src/Makefile.kernelcompat | 21 +++++++++++++++++++++ kmod/src/file.c | 10 +++++----- kmod/src/iomap.h | 1 - kmod/src/kernelcompat.h | 20 ++++++++++++++++++++ 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/kmod/src/Makefile.kernelcompat b/kmod/src/Makefile.kernelcompat index 713e3d32..f12ac54e 100644 --- a/kmod/src/Makefile.kernelcompat +++ b/kmod/src/Makefile.kernelcompat @@ -361,3 +361,24 @@ endif ifneq (,$(shell grep 'copy_page_to_iter_nofault' include/linux/uio.h)) ccflags-y += -DKC_USE_IOMAP_FOR_IO endif + +# +# v5.18-rc7-162-g786f847f43a5 +# +# iomap_dio_rw() takes a private pointer that it stores in the iomap_iter +# for the filesystem's use. +# +ifneq (,$(shell grep 'unsigned int dio_flags, void .private' include/linux/iomap.h)) +ccflags-y += -DKC_IOMAP_DIO_RW_PRIVATE +endif + +# +# v6.16-rc1-11-g2a5574fc57d1 +# +# The iomap_folio_ops that used to hang off the iomap are replaced by +# iomap_write_ops which are passed to iomap_file_buffered_write() along +# with a private pointer. +# +ifneq (,$(shell grep 'const struct iomap_write_ops .write_ops, void .private' include/linux/iomap.h)) +ccflags-y += -DKC_IOMAP_WRITE_OPS +endif diff --git a/kmod/src/file.c b/kmod/src/file.c index 730a6625..1968a044 100644 --- a/kmod/src/file.c +++ b/kmod/src/file.c @@ -154,7 +154,7 @@ static ssize_t scoutfs_file_direct_read(struct kiocb *iocb, struct iov_iter *to, retry: pagefault_disable(); to->nofault = true; - ret = iomap_dio_rw(iocb, to, &scoutfs_iomap_ops, NULL, IOMAP_DIO_PARTIAL, read); + ret = KC_IOMAP_DIO_RW(iocb, to, &scoutfs_iomap_ops, NULL, IOMAP_DIO_PARTIAL, read); to->nofault = false; pagefault_enable(); @@ -336,9 +336,9 @@ retry: * any needed pages later on. */ from->nofault = true; - ret = iomap_dio_rw(iocb, from, &scoutfs_iomap_ops, NULL, - IOMAP_DIO_PARTIAL | IOMAP_DIO_FORCE_WAIT, - written); + ret = KC_IOMAP_DIO_RW(iocb, from, &scoutfs_iomap_ops, NULL, + IOMAP_DIO_PARTIAL | IOMAP_DIO_FORCE_WAIT, + written); from->nofault = false; if (ret <= 0) { @@ -410,7 +410,7 @@ retry: locked = true; pagefault_disable(); - ret = iomap_file_buffered_write(iocb, from, &scoutfs_iomap_ops); + ret = KC_IOMAP_FILE_BUFFERED_WRITE(iocb, from, &scoutfs_iomap_ops); pagefault_enable(); /* Accumulate the count of what's been written so far */ diff --git a/kmod/src/iomap.h b/kmod/src/iomap.h index 3d4c8547..27c2a971 100644 --- a/kmod/src/iomap.h +++ b/kmod/src/iomap.h @@ -3,6 +3,5 @@ extern const struct iomap_ops scoutfs_iomap_report_ops; extern const struct iomap_ops scoutfs_iomap_ops; -extern const struct iomap_page_ops scoutfs_iomap_page_ops; #endif diff --git a/kmod/src/kernelcompat.h b/kmod/src/kernelcompat.h index 56cac59d..86dec4b7 100644 --- a/kmod/src/kernelcompat.h +++ b/kmod/src/kernelcompat.h @@ -374,6 +374,26 @@ static inline long inode_get_atime_nsec(const struct inode *inode) #define KC_PAGE_OR_FOLIO(p, f) p #endif +/* + * We don't have any per-iter state or write ops of our own, so we just + * pass in nulls for the newer arguments. + */ +#ifdef KC_IOMAP_DIO_RW_PRIVATE +#define KC_IOMAP_DIO_RW(iocb, iter, ops, dops, dio_flags, done_before) \ + iomap_dio_rw(iocb, iter, ops, dops, dio_flags, NULL, done_before) +#else +#define KC_IOMAP_DIO_RW(iocb, iter, ops, dops, dio_flags, done_before) \ + iomap_dio_rw(iocb, iter, ops, dops, dio_flags, done_before) +#endif + +#ifdef KC_IOMAP_WRITE_OPS +#define KC_IOMAP_FILE_BUFFERED_WRITE(iocb, iter, ops) \ + iomap_file_buffered_write(iocb, iter, ops, NULL, NULL) +#else +#define KC_IOMAP_FILE_BUFFERED_WRITE(iocb, iter, ops) \ + iomap_file_buffered_write(iocb, iter, ops) +#endif + #ifndef KC_TIMER_CONTAINER_OF #define timer_container_of(var, callback_timer, timer_fieldname) \ from_timer(var, callback_timer, timer_fieldname)