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)