]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iomap: remove over-strict inline data boundary check
authorNamjae Jeon <linkinjeon@kernel.org>
Mon, 11 May 2026 14:11:51 +0000 (23:11 +0900)
committerChristian Brauner <brauner@kernel.org>
Mon, 11 May 2026 14:56:53 +0000 (16:56 +0200)
The current iomap_inline_data_valid() check ensures that inline data
does not cross a PAGE_SIZE boundary. However, this is an unnecessarily
strict constraint. If a filesystem provides a valid iomap::inline_data
pointer and iomap::length, we should trust that the caller has mapped
sufficient memory for the range, even if it spans across page boundaries.
Removing this check allows filesystems to point directly to their
internal data structures without forced page-alignment or additional
redundant allocations. This remove iomap_inline_data_valid() and
its callers in buffered and direct I/O paths.

Suggested-by: Matthew Wilcox <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Link: https://patch.msgid.link/20260511141151.6021-1-linkinjeon@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/iomap/buffered-io.c
fs/iomap/direct-io.c
include/linux/iomap.h

index 437a7c527c4a447ef51456a3e1f1df502f483545..c98cf19fbe08ad1c349d0918e87984397ac79735 100644 (file)
@@ -1058,7 +1058,6 @@ static bool iomap_write_end_inline(const struct iomap_iter *iter,
        void *addr;
 
        WARN_ON_ONCE(!folio_test_uptodate(folio));
-       BUG_ON(!iomap_inline_data_valid(iomap));
 
        if (WARN_ON_ONCE(!iomap->inline_data))
                return false;
index b0a6549b38487b23c985a14097924e9977f6a08d..a4459c5abb07827296f96faf6cadd5d663ac37ed 100644 (file)
@@ -603,9 +603,6 @@ static int iomap_dio_inline_iter(struct iomap_iter *iomi, struct iomap_dio *dio)
        if (WARN_ON_ONCE(!inline_data))
                return -EIO;
 
-       if (WARN_ON_ONCE(!iomap_inline_data_valid(iomap)))
-               return -EIO;
-
        if (dio->flags & IOMAP_DIO_WRITE) {
                loff_t size = iomi->inode->i_size;
 
index 2c5685adf3a97c0f697d7b327124cdb0606616b4..52bfd6783417cb93faa4017c1f68cb2bdf1f4186 100644 (file)
@@ -142,16 +142,6 @@ static inline void *iomap_inline_data(const struct iomap *iomap, loff_t pos)
        return iomap->inline_data + pos - iomap->offset;
 }
 
-/*
- * Check if the mapping's length is within the valid range for inline data.
- * This is used to guard against accessing data beyond the page inline_data
- * points at.
- */
-static inline bool iomap_inline_data_valid(const struct iomap *iomap)
-{
-       return iomap->length <= PAGE_SIZE - offset_in_page(iomap->inline_data);
-}
-
 /*
  * When get_folio succeeds, put_folio will always be called to do any
  * cleanup work necessary.  put_folio is responsible for unlocking and putting