Add a flag to request that the iomap instances do not allocate blocks by translating it to another new IOMAP_NOALLOC flag. Signed-off-by: Christoph Hellwig <hch@xxxxxx> --- fs/iomap/direct-io.c | 2 ++ include/linux/iomap.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 96dc72debc4b79..a01f1d182685b4 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -436,6 +436,8 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, if (is_sync_kiocb(iocb)) dio_flags |= IOMAP_DIO_FORCE_WAIT; + if (dio_flags & IOMAP_DIO_NOALLOC) + flags |= IOMAP_NOALLOC; dio = kmalloc(sizeof(*dio), GFP_KERNEL); if (!dio) diff --git a/include/linux/iomap.h b/include/linux/iomap.h index e7865654dd0dca..a92890d5dc6799 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -122,6 +122,7 @@ struct iomap_page_ops { #define IOMAP_FAULT (1 << 3) /* mapping for page fault */ #define IOMAP_DIRECT (1 << 4) /* direct I/O */ #define IOMAP_NOWAIT (1 << 5) /* do not block */ +#define IOMAP_NOALLOC (1 << 6) /* do not allocate blocks */ struct iomap_ops { /* @@ -257,6 +258,7 @@ struct iomap_dio_ops { }; #define IOMAP_DIO_FORCE_WAIT (1 << 0) /* force waiting for I/O */ +#define IOMAP_DIO_NOALLOC (1 << 1) /* do not allocate blocks */ ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, const struct iomap_ops *ops, const struct iomap_dio_ops *dops, -- 2.29.2