Skip to contentSkip to conversation

iomap: support tail packing inline read

PATCH Superseded Gao Xiang 4 participants 13 messages Jul 19, 2021 – Jul 20, 2021

Subsystems (2)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH v3 1/1 iomap: support tail packing inline read

This tries to add tail packing inline read to iomap, which can support several inline tail blocks. Similar to the previous approach, it cleans post-EOF in one iteration.

The write path remains untouched since EROFS cannot be used for testing. It'd be better to be implemented if upcoming real users care rather than leave untested dead code around.

Cc Christoph Hellwig <[email protected]>
Cc Darrick J. Wong <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Andreas Gruenbacher <[email protected]>

---
v2: https://lore.kernel.org/r/YPLdSja%2F4FBsjss%[email protected]/
changes since v2:
- update suggestion from Christoph:
https://lore.kernel.org/r/[email protected]/

Hi Andreas,
would you mind test on the gfs2 side? Thanks in advance!

Thanks,
Gao Xiang

 fs/iomap/buffered-io.c | 50 ++++++++++++++++++++++++++----------------
 fs/iomap/direct-io.c   | 11 ++++++----
 2 files changed, 38 insertions(+), 23 deletions(-)
fs/iomap/buffered-io.c +31 -19
index 87ccb3438bec..cac8a88660d8 100644
@@ -207,23 +207,22 @@ struct iomap_readpage_ctx {
 
 static void
 iomap_read_inline_data(struct inode *inode, struct page *page,
-		struct iomap *iomap)
+		struct iomap *iomap, loff_t pos)
 {
-	size_t size = i_size_read(inode);
+	unsigned int size, poff = offset_in_page(pos);
 	void *addr;
 
-	if (PageUptodate(page))
-		return;
-
-	BUG_ON(page_has_private(page));
-	BUG_ON(page->index);
-	BUG_ON(size > PAGE_SIZE - offset_in_page(iomap->inline_data));
+	/* inline source data must be inside a single page */
+	BUG_ON(iomap->length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+	/* handle tail-packing blocks cross the current page into the next */
+	size = min_t(unsigned int, iomap->length + pos - iomap->offset,
+		     PAGE_SIZE - poff);
 
 	addr = kmap_atomic(page);
-	memcpy(addr, iomap->inline_data, size);
-	memset(addr + size, 0, PAGE_SIZE - size);
+	memcpy(addr + poff, iomap->inline_data - iomap->offset + pos, size);
+	memset(addr + poff + size, 0, PAGE_SIZE - poff - size);
 	kunmap_atomic(addr);
-	SetPageUptodate(page);
+	iomap_set_range_uptodate(page, poff, PAGE_SIZE - poff);
 }
 
 static inline bool iomap_block_needs_zeroing(struct inode *inode,
@@ -246,18 +245,19 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
 	unsigned poff, plen;
 	sector_t sector;
 
-	if (iomap->type == IOMAP_INLINE) {
-		WARN_ON_ONCE(pos);
-		iomap_read_inline_data(inode, page, iomap);
-		return PAGE_SIZE;
-	}
-
-	/* zero post-eof blocks as the page may be mapped */
 	iop = iomap_page_create(inode, page);
+	/* needs to skip some leading uptodated blocks */
 	iomap_adjust_read_range(inode, iop, &pos, length, &poff, &plen);
 	if (plen == 0)
 		goto done;
 
+	if (iomap->type == IOMAP_INLINE) {
+		iomap_read_inline_data(inode, page, iomap, pos);
+		plen = PAGE_SIZE - poff;
+		goto done;
+	}
+
+	/* zero post-eof blocks as the page may be mapped */
 	if (iomap_block_needs_zeroing(inode, iomap, pos)) {
 		zero_user(page, poff, plen);
 		iomap_set_range_uptodate(page, poff, plen);
@@ -589,6 +589,18 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, int flags,
 	return 0;
 }
 
+static int iomap_write_begin_inline(struct inode *inode, loff_t pos,
+		struct page *page, struct iomap *srcmap)
+{
+	/* needs more work for the tailpacking case, disable for now */
+	if (WARN_ON_ONCE(pos != 0))
+		return -EIO;
+	if (PageUptodate(page))
+		return 0;
+	iomap_read_inline_data(inode, page, srcmap, pos);
+	return 0;
+}
+
 static int
 iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
 		struct page **pagep, struct iomap *iomap, struct iomap *srcmap)
@@ -618,7 +630,7 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
 	}
 
 	if (srcmap->type == IOMAP_INLINE)
-		iomap_read_inline_data(inode, page, srcmap);
+		status = iomap_write_begin_inline(inode, pos, page, srcmap);
 	else if (iomap->flags & IOMAP_F_BUFFER_HEAD)
 		status = __block_write_begin_int(page, pos, len, NULL, srcmap);
 	else
fs/iomap/direct-io.c +7 -4
index 9398b8c31323..ee6309967b77 100644
@@ -379,22 +379,25 @@ iomap_dio_inline_actor(struct inode *inode, loff_t pos, loff_t length,
 {
 	struct iov_iter *iter = dio->submit.iter;
 	size_t copied;
+	void *dst = iomap->inline_data + pos - iomap->offset;
 
-	BUG_ON(pos + length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+	/* inline data must be inside a single page */
+	BUG_ON(length > PAGE_SIZE - offset_in_page(iomap->inline_data));
 
 	if (dio->flags & IOMAP_DIO_WRITE) {
 		loff_t size = inode->i_size;
 
 		if (pos > size)
-			memset(iomap->inline_data + size, 0, pos - size);
-		copied = copy_from_iter(iomap->inline_data + pos, length, iter);
+			memset(iomap->inline_data + size - iomap->offset,
+			       0, pos - size);
+		copied = copy_from_iter(dst, length, iter);
 		if (copied) {
 			if (pos + copied > size)
 				i_size_write(inode, pos + copied);
 			mark_inode_dirty(inode);
 		}
 	} else {
-		copied = copy_to_iter(iomap->inline_data + pos, length, iter);
+		copied = copy_to_iter(dst, length, iter);
 	}
 	dio->size += copied;
 	return copied;
Signature · 1 line
2.24.4
#1 lore raw
Quoted 12 lines · Gao Xiang
fs/iomap/buffered-io.c +0 -7
@@ -246,18 +245,19 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
 	unsigned poff, plen;
 	sector_t sector;
 
-	if (iomap->type == IOMAP_INLINE) {
-		WARN_ON_ONCE(pos);
-		iomap_read_inline_data(inode, page, iomap);
-		return PAGE_SIZE;
-	}
-
-	/* zero post-eof blocks as the page may be mapped */
 	iop = iomap_page_create(inode, page);

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 258

Quoted 10 lines
fs/iomap/buffered-io.c +6 -0
+	/* needs to skip some leading uptodated blocks */
 	iomap_adjust_read_range(inode, iop, &pos, length, &poff, &plen);
 	if (plen == 0)
 		goto done;
 
+	if (iomap->type == IOMAP_INLINE) {
+		iomap_read_inline_data(inode, page, iomap, pos);
+		plen = PAGE_SIZE - poff;
+		goto done;
+	}

This is going to break Andreas' case that he just patched to work. GFS2 needs for there to _not_ be an iop for inline data. That's why I said we need to sort out when to create an iop before moving the IOMAP_INLINE case below the creation of the iop.

If we're not going to do that first, then I recommend leaving the IOMAP_INLINE case where it is and changing it to ...

	if (iomap->type == IOMAP_INLINE)
		return iomap_read_inline_data(inode, page, iomap, pos);

... and have iomap_read_inline_data() return the number of bytes that it copied + zeroed (ie PAGE_SIZE - poff).

#2 lore raw
Quoted 11 lines · Matthew Wilcox

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 258

Quoted 5 lines
fs/iomap/buffered-io.c +5 -0
+	if (iomap->type == IOMAP_INLINE) {
+		iomap_read_inline_data(inode, page, iomap, pos);
+		plen = PAGE_SIZE - poff;
+		goto done;
+	}

This is going to break Andreas' case that he just patched to work. GFS2 needs for there to _not_ be an iop for inline data. That's why I said we need to sort out when to create an iop before moving the IOMAP_INLINE case below the creation of the iop.

Quoted 8 lines

If we're not going to do that first, then I recommend leaving the IOMAP_INLINE case where it is and changing it to ...

	if (iomap->type == IOMAP_INLINE)
		return iomap_read_inline_data(inode, page, iomap, pos);

... and have iomap_read_inline_data() return the number of bytes that it copied + zeroed (ie PAGE_SIZE - poff).

Returning the bytes is much cleaner anyway. But we still need to deal with the sub-page uptodate status in one form or another.

author
#3 lore raw
Quoted 15 lines · Christoph Hellwig
Quoted 14 lines · Matthew Wilcox

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 258

Quoted 5 lines
fs/iomap/buffered-io.c +5 -0
+	if (iomap->type == IOMAP_INLINE) {
+		iomap_read_inline_data(inode, page, iomap, pos);
+		plen = PAGE_SIZE - poff;
+		goto done;
+	}

This is going to break Andreas' case that he just patched to work. GFS2 needs for there to _not_ be an iop for inline data. That's why I said we need to sort out when to create an iop before moving the IOMAP_INLINE case below the creation of the iop.

If we're not going to do that first, then I recommend leaving the IOMAP_INLINE case where it is and changing it to ...

Quoted 8 lines
Quoted 5 lines
	if (iomap->type == IOMAP_INLINE)
		return iomap_read_inline_data(inode, page, iomap, pos);

... and have iomap_read_inline_data() return the number of bytes that it copied + zeroed (ie PAGE_SIZE - poff).

Returning the bytes is much cleaner anyway. But we still need to deal with the sub-page uptodate status in one form or another.

There is another iomap_read_inline_data() caller as in:
+static int iomap_write_begin_inline(struct inode *inode, loff_t pos,
+ struct page *page, struct iomap *srcmap)
+{
+ /* needs more work for the tailpacking case, disable for now */
+ if (WARN_ON_ONCE(pos != 0))
+ return -EIO;
+ if (PageUptodate(page))
+ return 0;
+ iomap_read_inline_data(inode, page, srcmap, pos);
+ return 0;
+}

I'd like to avoid it as (void)iomap_read_inline_data(...). That's why it left as void return type.

Anyway, let's check if it works correctly first. I think it's a high priority stuff, and EROFS uncompressed cases can be entirely cleaned up with iomap then.

Thanks,
Gao Xiang

#4 lore raw
Quoted 38 lines · Gao Xiang
Quoted 15 lines · Christoph Hellwig
Quoted 14 lines · Matthew Wilcox

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 258

Quoted 5 lines
fs/iomap/buffered-io.c +5 -0
+	if (iomap->type == IOMAP_INLINE) {
+		iomap_read_inline_data(inode, page, iomap, pos);
+		plen = PAGE_SIZE - poff;
+		goto done;
+	}

This is going to break Andreas' case that he just patched to work. GFS2 needs for there to _not_ be an iop for inline data. That's why I said we need to sort out when to create an iop before moving the IOMAP_INLINE case below the creation of the iop.

If we're not going to do that first, then I recommend leaving the IOMAP_INLINE case where it is and changing it to ...

Quoted 8 lines
Quoted 5 lines
	if (iomap->type == IOMAP_INLINE)
		return iomap_read_inline_data(inode, page, iomap, pos);

... and have iomap_read_inline_data() return the number of bytes that it copied + zeroed (ie PAGE_SIZE - poff).

Returning the bytes is much cleaner anyway. But we still need to deal with the sub-page uptodate status in one form or another.

There is another iomap_read_inline_data() caller as in:

fs/iomap/buffered-io.c +11 -0
+static int iomap_write_begin_inline(struct inode *inode, loff_t pos,
+		struct page *page, struct iomap *srcmap)
+{
+	/* needs more work for the tailpacking case, disable for now */
+	if (WARN_ON_ONCE(pos != 0))
+		return -EIO;
+	if (PageUptodate(page))
+		return 0;
+	iomap_read_inline_data(inode, page, srcmap, pos);
+	return 0;
+}
Quoted 2 lines

I'd like to avoid it as (void)iomap_read_inline_data(...). That's why it left as void return type.

You don't need to cast away the return value in C.

author
#5 lore raw
Quoted 39 lines · Matthew Wilcox
Quoted 38 lines · Gao Xiang
Quoted 15 lines · Christoph Hellwig
Quoted 14 lines · Matthew Wilcox

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 258

Quoted 5 lines
fs/iomap/buffered-io.c +5 -0
+	if (iomap->type == IOMAP_INLINE) {
+		iomap_read_inline_data(inode, page, iomap, pos);
+		plen = PAGE_SIZE - poff;
+		goto done;
+	}

This is going to break Andreas' case that he just patched to work. GFS2 needs for there to _not_ be an iop for inline data. That's why I said we need to sort out when to create an iop before moving the IOMAP_INLINE case below the creation of the iop.

If we're not going to do that first, then I recommend leaving the IOMAP_INLINE case where it is and changing it to ...

Quoted 8 lines
Quoted 5 lines
	if (iomap->type == IOMAP_INLINE)
		return iomap_read_inline_data(inode, page, iomap, pos);

... and have iomap_read_inline_data() return the number of bytes that it copied + zeroed (ie PAGE_SIZE - poff).

Returning the bytes is much cleaner anyway. But we still need to deal with the sub-page uptodate status in one form or another.

There is another iomap_read_inline_data() caller as in:

fs/iomap/buffered-io.c +11 -0
+static int iomap_write_begin_inline(struct inode *inode, loff_t pos,
+		struct page *page, struct iomap *srcmap)
+{
+	/* needs more work for the tailpacking case, disable for now */
+	if (WARN_ON_ONCE(pos != 0))
+		return -EIO;
+	if (PageUptodate(page))
+		return 0;
+	iomap_read_inline_data(inode, page, srcmap, pos);
+	return 0;
+}
Quoted 4 lines
Quoted 2 lines

I'd like to avoid it as (void)iomap_read_inline_data(...). That's why it left as void return type.

You don't need to cast away the return value in C.

Well, I don't check the current behavior of this, but see:
http://c-faq.com/style/voidcasts.html

Anyway, that's minor and easy to update if really needed. I'd like to check if it works first...

Thanks,
Gao Xiang

author
#6 lore raw
In reply to Matthew Wilcox
Quoted 18 lines · Matthew Wilcox
Quoted 17 lines · Gao Xiang
fs/iomap/buffered-io.c +1 -7
@@ -246,18 +245,19 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
 	unsigned poff, plen;
 	sector_t sector;
 
-	if (iomap->type == IOMAP_INLINE) {
-		WARN_ON_ONCE(pos);
-		iomap_read_inline_data(inode, page, iomap);
-		return PAGE_SIZE;
-	}
-
-	/* zero post-eof blocks as the page may be mapped */
 	iop = iomap_page_create(inode, page);
+	/* needs to skip some leading uptodated blocks */
 	iomap_adjust_read_range(inode, iop, &pos, length, &poff, &plen);
 	if (plen == 0)
 		goto done;
 
Quoted 10 lines

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 258

Quoted 5 lines
fs/iomap/buffered-io.c +5 -0
+	if (iomap->type == IOMAP_INLINE) {
+		iomap_read_inline_data(inode, page, iomap, pos);
+		plen = PAGE_SIZE - poff;
+		goto done;
+	}

This is going to break Andreas' case that he just patched to work. GFS2 needs for there to _not_ be an iop for inline data. That's why I said we need to sort out when to create an iop before moving the IOMAP_INLINE case below the creation of the iop.

I have no idea how it breaks Andreas' case from the previous commit
message: "
iomap: Don't create iomap_page objects for inline files
In iomap_readpage_actor, don't create iop objects for inline inodes. Otherwise, iomap_read_inline_data will set PageUptodate without setting iop->uptodate, and iomap_page_release will eventually complain.

To prevent this kind of bug from occurring in the future, make sure the page doesn't have private data attached in iomap_read_inline_data. "

After this patch, iomap_read_inline_data() will set iop->uptodate with iomap_set_range_uptodate() rather than set PageUptodate() directly, so iomap_page_release won't complain.

Am I missing something?

Thanks,
Gao Xiang

Quoted 9 lines

If we're not going to do that first, then I recommend leaving the IOMAP_INLINE case where it is and changing it to ...

	if (iomap->type == IOMAP_INLINE)
		return iomap_read_inline_data(inode, page, iomap, pos);

... and have iomap_read_inline_data() return the number of bytes that it copied + zeroed (ie PAGE_SIZE - poff).

#7 lore raw

Am Mo., 19. Juli 2021 um 17:29 Uhr schrieb Gao Xiang <[email protected]>:

Quoted 37 lines · Matthew Wilcox
Quoted 18 lines · Gao Xiang
Quoted 17 lines
fs/iomap/buffered-io.c +1 -7
@@ -246,18 +245,19 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
    unsigned poff, plen;
    sector_t sector;
 
-   if (iomap->type == IOMAP_INLINE) {
-           WARN_ON_ONCE(pos);
-           iomap_read_inline_data(inode, page, iomap);
-           return PAGE_SIZE;
-   }
-
-   /* zero post-eof blocks as the page may be mapped */
    iop = iomap_page_create(inode, page);
+   /* needs to skip some leading uptodated blocks */
    iomap_adjust_read_range(inode, iop, &pos, length, &poff, &plen);
    if (plen == 0)
            goto done;
 
Quoted 10 lines

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 258

Quoted 5 lines
fs/iomap/buffered-io.c +5 -0
+   if (iomap->type == IOMAP_INLINE) {
+           iomap_read_inline_data(inode, page, iomap, pos);
+           plen = PAGE_SIZE - poff;
+           goto done;
+   }

This is going to break Andreas' case that he just patched to work. GFS2 needs for there to _not_ be an iop for inline data. That's why I said we need to sort out when to create an iop before moving the IOMAP_INLINE case below the creation of the iop.

I have no idea how it breaks Andreas' case from the previous commit
message: "
iomap: Don't create iomap_page objects for inline files
In iomap_readpage_actor, don't create iop objects for inline inodes. Otherwise, iomap_read_inline_data will set PageUptodate without setting iop->uptodate, and iomap_page_release will eventually complain.

Quoted 7 lines

To prevent this kind of bug from occurring in the future, make sure the page doesn't have private data attached in iomap_read_inline_data. "

After this patch, iomap_read_inline_data() will set iop->uptodate with iomap_set_range_uptodate() rather than set PageUptodate() directly, so iomap_page_release won't complain.

Yes, that actually looks fine.

Thanks,
Andreas

author
#8 lore raw
Quoted 43 lines · Andreas Grünbacher

Am Mo., 19. Juli 2021 um 17:29 Uhr schrieb Gao Xiang <[email protected]>:

Quoted 41 lines · Matthew Wilcox
Quoted 18 lines · Gao Xiang
Quoted 17 lines
fs/iomap/buffered-io.c +1 -7
@@ -246,18 +245,19 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
    unsigned poff, plen;
    sector_t sector;
 
-   if (iomap->type == IOMAP_INLINE) {
-           WARN_ON_ONCE(pos);
-           iomap_read_inline_data(inode, page, iomap);
-           return PAGE_SIZE;
-   }
-
-   /* zero post-eof blocks as the page may be mapped */
    iop = iomap_page_create(inode, page);
+   /* needs to skip some leading uptodated blocks */
    iomap_adjust_read_range(inode, iop, &pos, length, &poff, &plen);
    if (plen == 0)
            goto done;
 
Quoted 10 lines

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 258

Quoted 5 lines
fs/iomap/buffered-io.c +5 -0
+   if (iomap->type == IOMAP_INLINE) {
+           iomap_read_inline_data(inode, page, iomap, pos);
+           plen = PAGE_SIZE - poff;
+           goto done;
+   }

This is going to break Andreas' case that he just patched to work. GFS2 needs for there to _not_ be an iop for inline data. That's why I said we need to sort out when to create an iop before moving the IOMAP_INLINE case below the creation of the iop.

I have no idea how it breaks Andreas' case from the previous commit
message: "
iomap: Don't create iomap_page objects for inline files
In iomap_readpage_actor, don't create iop objects for inline inodes. Otherwise, iomap_read_inline_data will set PageUptodate without setting iop->uptodate, and iomap_page_release will eventually complain.

To prevent this kind of bug from occurring in the future, make sure the page doesn't have private data attached in iomap_read_inline_data. "

Quoted 5 lines
Quoted 3 lines

After this patch, iomap_read_inline_data() will set iop->uptodate with iomap_set_range_uptodate() rather than set PageUptodate() directly, so iomap_page_release won't complain.

Yes, that actually looks fine.

Yeah, although I admit it looks (maybe) somewhat sub-optimal, but I think let's make it work correctly first. Then consider how to optimize it even further (like drop iops or likewise...).

Just my humble suggestion of this from heart....

Thanks,
Gao Xiang

Quoted 3 lines

Thanks,
Andreas

#9 lore raw
In reply to Gao Xiang

Am Mo., 19. Juli 2021 um 16:48 Uhr schrieb Gao Xiang <[email protected]>:

Quoted 45 lines

This tries to add tail packing inline read to iomap, which can support several inline tail blocks. Similar to the previous approach, it cleans post-EOF in one iteration.

The write path remains untouched since EROFS cannot be used for testing. It'd be better to be implemented if upcoming real users care rather than leave untested dead code around.

Cc Christoph Hellwig <[email protected]>
Cc Darrick J. Wong <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Andreas Gruenbacher <[email protected]>

---
v2: https://lore.kernel.org/r/YPLdSja%2F4FBsjss%[email protected]/
changes since v2:
- update suggestion from Christoph:
https://lore.kernel.org/r/[email protected]/

Hi Andreas,
would you mind test on the gfs2 side? Thanks in advance!

Thanks,
Gao Xiang

 fs/iomap/buffered-io.c | 50 ++++++++++++++++++++++++++----------------
 fs/iomap/direct-io.c   | 11 ++++++----
 2 files changed, 38 insertions(+), 23 deletions(-)
fs/iomap/buffered-io.c +2 -3
index 87ccb3438bec..cac8a88660d8 100644
@@ -207,23 +207,22 @@ struct iomap_readpage_ctx {
 
 static void
 iomap_read_inline_data(struct inode *inode, struct page *page,
-               struct iomap *iomap)
+               struct iomap *iomap, loff_t pos)
 {
-       size_t size = i_size_read(inode);
+       unsigned int size, poff = offset_in_page(pos);
        void *addr;
 
-       if (PageUptodate(page))

fs/iomap/buffered-io.c struct iomap_readpage_ctx { · line 219

Quoted 10 lines
fs/iomap/buffered-io.c +5 -5
-               return;
-
-       BUG_ON(page_has_private(page));
-       BUG_ON(page->index);
-       BUG_ON(size > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* inline source data must be inside a single page */
+       BUG_ON(iomap->length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* handle tail-packing blocks cross the current page into the next */
+       size = min_t(unsigned int, iomap->length + pos - iomap->offset,
+                    PAGE_SIZE - poff);

Hmm, so EROFS really does multi-page tail packing? This contradicts the comment and code in iomap_dio_inline_actor.

fs/iomap/buffered-io.c struct iomap_readpage_ctx { · line 226

Quoted 9 lines
fs/iomap/buffered-io.c +3 -3
        addr = kmap_atomic(page);
-       memcpy(addr, iomap->inline_data, size);
-       memset(addr + size, 0, PAGE_SIZE - size);
+       memcpy(addr + poff, iomap->inline_data - iomap->offset + pos, size);
+       memset(addr + poff + size, 0, PAGE_SIZE - poff - size);
        kunmap_atomic(addr);
-       SetPageUptodate(page);
+       iomap_set_range_uptodate(page, poff, PAGE_SIZE - poff);
 }

It's been said before, but iomap_read_inline_data should return PAGE_SIZE - poff, and no (void) casting when the return value is ignored.

Quoted 4 lines
fs/iomap/buffered-io.c +0 -0
 static inline bool iomap_block_needs_zeroing(struct inode *inode,
@@ -246,18 +245,19 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
        unsigned poff, plen;
        sector_t sector;

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 249

Quoted 10 lines
fs/iomap/buffered-io.c +1 -7
 
-       if (iomap->type == IOMAP_INLINE) {
-               WARN_ON_ONCE(pos);
-               iomap_read_inline_data(inode, page, iomap);
-               return PAGE_SIZE;
-       }
-
-       /* zero post-eof blocks as the page may be mapped */
        iop = iomap_page_create(inode, page);
+       /* needs to skip some leading uptodated blocks */

"needs to skip some leading uptodate blocks"

Quoted 15 lines
fs/iomap/buffered-io.c +7 -0
        iomap_adjust_read_range(inode, iop, &pos, length, &poff, &plen);
        if (plen == 0)
                goto done;
 
+       if (iomap->type == IOMAP_INLINE) {
+               iomap_read_inline_data(inode, page, iomap, pos);
+               plen = PAGE_SIZE - poff;
+               goto done;
+       }
+
+       /* zero post-eof blocks as the page may be mapped */
        if (iomap_block_needs_zeroing(inode, iomap, pos)) {
                zero_user(page, poff, plen);
                iomap_set_range_uptodate(page, poff, plen);

fs/iomap/buffered-io.c __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, int flags, · line 596

Quoted 8 lines
fs/iomap/buffered-io.c +5 -0
@@ -589,6 +589,18 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, int flags,
        return 0;
 }
 
+static int iomap_write_begin_inline(struct inode *inode, loff_t pos,
+               struct page *page, struct iomap *srcmap)
+{
+       /* needs more work for the tailpacking case, disable for now */
+       if (WARN_ON_ONCE(pos != 0))

This should be a WARN_ON_ONCE(srcmap->offset != 0). Otherwise, something like:

xfs_io -ft -c 'pwrite 1 2'

will fail because pos will be 1.

fs/iomap/buffered-io.c __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, int flags, · line 600

Quoted 4 lines
fs/iomap/buffered-io.c +4 -0
+               return -EIO;
+       if (PageUptodate(page))
+               return 0;
+       iomap_read_inline_data(inode, page, srcmap, pos);

The above means that passing pos to iomap_read_inline_data here won't do the right thing, either.

Quoted 50 lines
fs/iomap/buffered-io.c +4 -1
+       return 0;
+}
+
 static int
 iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
                struct page **pagep, struct iomap *iomap, struct iomap *srcmap)
@@ -618,7 +630,7 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
        }
 
        if (srcmap->type == IOMAP_INLINE)
-               iomap_read_inline_data(inode, page, srcmap);
+               status = iomap_write_begin_inline(inode, pos, page, srcmap);
        else if (iomap->flags & IOMAP_F_BUFFER_HEAD)
                status = __block_write_begin_int(page, pos, len, NULL, srcmap);
        else
fs/iomap/direct-io.c +7 -5
index 9398b8c31323..ee6309967b77 100644
@@ -379,22 +379,25 @@ iomap_dio_inline_actor(struct inode *inode, loff_t pos, loff_t length,
 {
        struct iov_iter *iter = dio->submit.iter;
        size_t copied;
+       void *dst = iomap->inline_data + pos - iomap->offset;
 
-       BUG_ON(pos + length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* inline data must be inside a single page */
+       BUG_ON(length > PAGE_SIZE - offset_in_page(iomap->inline_data));
 
        if (dio->flags & IOMAP_DIO_WRITE) {
                loff_t size = inode->i_size;
 
                if (pos > size)
-                       memset(iomap->inline_data + size, 0, pos - size);
-               copied = copy_from_iter(iomap->inline_data + pos, length, iter);
+                       memset(iomap->inline_data + size - iomap->offset,
+                              0, pos - size);
+               copied = copy_from_iter(dst, length, iter);
                if (copied) {
                        if (pos + copied > size)
                                i_size_write(inode, pos + copied);
                        mark_inode_dirty(inode);
                }
        } else {
-               copied = copy_to_iter(iomap->inline_data + pos, length, iter);
+               copied = copy_to_iter(dst, length, iter);
        }
        dio->size += copied;
        return copied;
--
Quoted 2 lines

2.24.4

Thanks,
Andreas

author
#10 lore raw

Hi Andreas,

Quoted 46 lines · Andreas Grünbacher

Am Mo., 19. Juli 2021 um 16:48 Uhr schrieb Gao Xiang <[email protected]>:

Quoted 44 lines

This tries to add tail packing inline read to iomap, which can support several inline tail blocks. Similar to the previous approach, it cleans post-EOF in one iteration.

The write path remains untouched since EROFS cannot be used for testing. It'd be better to be implemented if upcoming real users care rather than leave untested dead code around.

Cc Christoph Hellwig <[email protected]>
Cc Darrick J. Wong <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Andreas Gruenbacher <[email protected]>

---
v2: https://lore.kernel.org/r/YPLdSja%2F4FBsjss%[email protected]/
changes since v2:
- update suggestion from Christoph:
https://lore.kernel.org/r/[email protected]/

Hi Andreas,
would you mind test on the gfs2 side? Thanks in advance!

Thanks,
Gao Xiang

 fs/iomap/buffered-io.c | 50 ++++++++++++++++++++++++++----------------
 fs/iomap/direct-io.c   | 11 ++++++----
 2 files changed, 38 insertions(+), 23 deletions(-)
fs/iomap/buffered-io.c +2 -2
index 87ccb3438bec..cac8a88660d8 100644
@@ -207,23 +207,22 @@ struct iomap_readpage_ctx {
 
 static void
 iomap_read_inline_data(struct inode *inode, struct page *page,
-               struct iomap *iomap)
+               struct iomap *iomap, loff_t pos)
 {
-       size_t size = i_size_read(inode);
+       unsigned int size, poff = offset_in_page(pos);
        void *addr;
 
Quoted 14 lines

fs/iomap/buffered-io.c struct iomap_readpage_ctx { · line 219

Quoted 11 lines
fs/iomap/buffered-io.c +5 -6
-       if (PageUptodate(page))
-               return;
-
-       BUG_ON(page_has_private(page));
-       BUG_ON(page->index);
-       BUG_ON(size > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* inline source data must be inside a single page */
+       BUG_ON(iomap->length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* handle tail-packing blocks cross the current page into the next */
+       size = min_t(unsigned int, iomap->length + pos - iomap->offset,
+                    PAGE_SIZE - poff);

Hmm, so EROFS really does multi-page tail packing? This contradicts the comment and code in iomap_dio_inline_actor.

No, it doesn't really contradict anything. There are 2 different concepts, the one is the metapage of iomap->inline_data itself. It should be in the same page, so the inode itself and inline data can be in the same page since currently assumed we don't support partial page read.
___________________________________________________

   | inode |              inline data                 |
   |<-------------- metadata page ------------------->|

(here inline data can be multiple blocks.)

The other one is actual file tail blocks, I think it can cross pages due to multiple tail inline blocks.

                            |<---------- inline data ------------->|
  _________________________________________________________________
  | file block | file block | file block | file block | file block |
  |<----------------    page   ---------------------->|<---  page

Although EROFS currently only support page-sized block, but I will look into subpage-sized blocks after iomap work is done (due to PAGE_SIZE of some platform is large, e.g. 64kb rather than 4kb.)

Quoted 11 lines

fs/iomap/buffered-io.c struct iomap_readpage_ctx { · line 226

Quoted 10 lines
fs/iomap/buffered-io.c +3 -3
        addr = kmap_atomic(page);
-       memcpy(addr, iomap->inline_data, size);
-       memset(addr + size, 0, PAGE_SIZE - size);
+       memcpy(addr + poff, iomap->inline_data - iomap->offset + pos, size);
+       memset(addr + poff + size, 0, PAGE_SIZE - poff - size);
        kunmap_atomic(addr);
-       SetPageUptodate(page);
+       iomap_set_range_uptodate(page, poff, PAGE_SIZE - poff);
 }
Quoted 3 lines

It's been said before, but iomap_read_inline_data should return PAGE_SIZE - poff, and no (void) casting when the return value is ignored.

Ok, anyway, I could update it in the next version.

Quoted 6 lines
Quoted 6 lines
fs/iomap/buffered-io.c +0 -0
 static inline bool iomap_block_needs_zeroing(struct inode *inode,
@@ -246,18 +245,19 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
        unsigned poff, plen;
        sector_t sector;
 
Quoted 11 lines

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 249

Quoted 9 lines
fs/iomap/buffered-io.c +1 -7
-       if (iomap->type == IOMAP_INLINE) {
-               WARN_ON_ONCE(pos);
-               iomap_read_inline_data(inode, page, iomap);
-               return PAGE_SIZE;
-       }
-
-       /* zero post-eof blocks as the page may be mapped */
        iop = iomap_page_create(inode, page);
+       /* needs to skip some leading uptodated blocks */

"needs to skip some leading uptodate blocks"

will update.

Quoted 27 lines
Quoted 16 lines
fs/iomap/buffered-io.c +7 -0
        iomap_adjust_read_range(inode, iop, &pos, length, &poff, &plen);
        if (plen == 0)
                goto done;
 
+       if (iomap->type == IOMAP_INLINE) {
+               iomap_read_inline_data(inode, page, iomap, pos);
+               plen = PAGE_SIZE - poff;
+               goto done;
+       }
+
+       /* zero post-eof blocks as the page may be mapped */
        if (iomap_block_needs_zeroing(inode, iomap, pos)) {
                zero_user(page, poff, plen);
                iomap_set_range_uptodate(page, poff, plen);

fs/iomap/buffered-io.c __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, int flags, · line 596

Quoted 8 lines
fs/iomap/buffered-io.c +5 -0
@@ -589,6 +589,18 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, int flags,
        return 0;
 }
 
+static int iomap_write_begin_inline(struct inode *inode, loff_t pos,
+               struct page *page, struct iomap *srcmap)
+{
+       /* needs more work for the tailpacking case, disable for now */
+       if (WARN_ON_ONCE(pos != 0))

This should be a WARN_ON_ONCE(srcmap->offset != 0). Otherwise, something like:

Quoted 3 lines

xfs_io -ft -c 'pwrite 1 2'

will fail because pos will be 1.

Yeah, will update. Thanks for pointing out!

Quoted 8 lines

fs/iomap/buffered-io.c __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, int flags, · line 600

Quoted 5 lines
fs/iomap/buffered-io.c +4 -0
+               return -EIO;
+       if (PageUptodate(page))
+               return 0;
+       iomap_read_inline_data(inode, page, srcmap, pos);

The above means that passing pos to iomap_read_inline_data here won't do the right thing, either.

yeah, I think it should use 0 here instead. since iomap->offset == 0

Thanks,
Gao Xiang

Quoted 56 lines
Quoted 51 lines
fs/iomap/buffered-io.c +4 -1
+       return 0;
+}
+
 static int
 iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
                struct page **pagep, struct iomap *iomap, struct iomap *srcmap)
@@ -618,7 +630,7 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
        }
 
        if (srcmap->type == IOMAP_INLINE)
-               iomap_read_inline_data(inode, page, srcmap);
+               status = iomap_write_begin_inline(inode, pos, page, srcmap);
        else if (iomap->flags & IOMAP_F_BUFFER_HEAD)
                status = __block_write_begin_int(page, pos, len, NULL, srcmap);
        else
fs/iomap/direct-io.c +7 -5
index 9398b8c31323..ee6309967b77 100644
@@ -379,22 +379,25 @@ iomap_dio_inline_actor(struct inode *inode, loff_t pos, loff_t length,
 {
        struct iov_iter *iter = dio->submit.iter;
        size_t copied;
+       void *dst = iomap->inline_data + pos - iomap->offset;
 
-       BUG_ON(pos + length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* inline data must be inside a single page */
+       BUG_ON(length > PAGE_SIZE - offset_in_page(iomap->inline_data));
 
        if (dio->flags & IOMAP_DIO_WRITE) {
                loff_t size = inode->i_size;
 
                if (pos > size)
-                       memset(iomap->inline_data + size, 0, pos - size);
-               copied = copy_from_iter(iomap->inline_data + pos, length, iter);
+                       memset(iomap->inline_data + size - iomap->offset,
+                              0, pos - size);
+               copied = copy_from_iter(dst, length, iter);
                if (copied) {
                        if (pos + copied > size)
                                i_size_write(inode, pos + copied);
                        mark_inode_dirty(inode);
                }
        } else {
-               copied = copy_to_iter(iomap->inline_data + pos, length, iter);
+               copied = copy_to_iter(dst, length, iter);
        }
        dio->size += copied;
        return copied;
--
Quoted 2 lines

2.24.4

Thanks,
Andreas

#11 lore raw
In reply to Gao Xiang

Am Mo., 19. Juli 2021 um 16:48 Uhr schrieb Gao Xiang <[email protected]>:

Quoted 69 lines

This tries to add tail packing inline read to iomap, which can support several inline tail blocks. Similar to the previous approach, it cleans post-EOF in one iteration.

The write path remains untouched since EROFS cannot be used for testing. It'd be better to be implemented if upcoming real users care rather than leave untested dead code around.

Cc Christoph Hellwig <[email protected]>
Cc Darrick J. Wong <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Andreas Gruenbacher <[email protected]>

---
v2: https://lore.kernel.org/r/YPLdSja%2F4FBsjss%[email protected]/
changes since v2:
- update suggestion from Christoph:
https://lore.kernel.org/r/[email protected]/

Hi Andreas,
would you mind test on the gfs2 side? Thanks in advance!

Thanks,
Gao Xiang

 fs/iomap/buffered-io.c | 50 ++++++++++++++++++++++++++----------------
 fs/iomap/direct-io.c   | 11 ++++++----
 2 files changed, 38 insertions(+), 23 deletions(-)
fs/iomap/buffered-io.c +10 -11
index 87ccb3438bec..cac8a88660d8 100644
@@ -207,23 +207,22 @@ struct iomap_readpage_ctx {
 
 static void
 iomap_read_inline_data(struct inode *inode, struct page *page,
-               struct iomap *iomap)
+               struct iomap *iomap, loff_t pos)
 {
-       size_t size = i_size_read(inode);
+       unsigned int size, poff = offset_in_page(pos);
        void *addr;
 
-       if (PageUptodate(page))
-               return;
-
-       BUG_ON(page_has_private(page));
-       BUG_ON(page->index);
-       BUG_ON(size > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* inline source data must be inside a single page */
+       BUG_ON(iomap->length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* handle tail-packing blocks cross the current page into the next */
+       size = min_t(unsigned int, iomap->length + pos - iomap->offset,
+                    PAGE_SIZE - poff);
 
        addr = kmap_atomic(page);
-       memcpy(addr, iomap->inline_data, size);
-       memset(addr + size, 0, PAGE_SIZE - size);
+       memcpy(addr + poff, iomap->inline_data - iomap->offset + pos, size);
+       memset(addr + poff + size, 0, PAGE_SIZE - poff - size);
        kunmap_atomic(addr);
-       SetPageUptodate(page);
+       iomap_set_range_uptodate(page, poff, PAGE_SIZE - poff);
 }
 
 static inline bool iomap_block_needs_zeroing(struct inode *inode,
@@ -246,18 +245,19 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
        unsigned poff, plen;

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 248

Quoted 10 lines
fs/iomap/buffered-io.c +0 -7
        sector_t sector;
 
-       if (iomap->type == IOMAP_INLINE) {
-               WARN_ON_ONCE(pos);
-               iomap_read_inline_data(inode, page, iomap);
-               return PAGE_SIZE;
-       }
-
-       /* zero post-eof blocks as the page may be mapped */
        iop = iomap_page_create(inode, page);

We can skip creating the iop when reading the entire page.

Quoted 78 lines
fs/iomap/buffered-io.c +21 -1
+       /* needs to skip some leading uptodated blocks */
        iomap_adjust_read_range(inode, iop, &pos, length, &poff, &plen);
        if (plen == 0)
                goto done;
 
+       if (iomap->type == IOMAP_INLINE) {
+               iomap_read_inline_data(inode, page, iomap, pos);
+               plen = PAGE_SIZE - poff;
+               goto done;
+       }
+
+       /* zero post-eof blocks as the page may be mapped */
        if (iomap_block_needs_zeroing(inode, iomap, pos)) {
                zero_user(page, poff, plen);
                iomap_set_range_uptodate(page, poff, plen);
@@ -589,6 +589,18 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, int flags,
        return 0;
 }
 
+static int iomap_write_begin_inline(struct inode *inode, loff_t pos,
+               struct page *page, struct iomap *srcmap)
+{
+       /* needs more work for the tailpacking case, disable for now */
+       if (WARN_ON_ONCE(pos != 0))
+               return -EIO;
+       if (PageUptodate(page))
+               return 0;
+       iomap_read_inline_data(inode, page, srcmap, pos);
+       return 0;
+}
+
 static int
 iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
                struct page **pagep, struct iomap *iomap, struct iomap *srcmap)
@@ -618,7 +630,7 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags,
        }
 
        if (srcmap->type == IOMAP_INLINE)
-               iomap_read_inline_data(inode, page, srcmap);
+               status = iomap_write_begin_inline(inode, pos, page, srcmap);
        else if (iomap->flags & IOMAP_F_BUFFER_HEAD)
                status = __block_write_begin_int(page, pos, len, NULL, srcmap);
        else
fs/iomap/direct-io.c +7 -5
index 9398b8c31323..ee6309967b77 100644
@@ -379,22 +379,25 @@ iomap_dio_inline_actor(struct inode *inode, loff_t pos, loff_t length,
 {
        struct iov_iter *iter = dio->submit.iter;
        size_t copied;
+       void *dst = iomap->inline_data + pos - iomap->offset;
 
-       BUG_ON(pos + length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* inline data must be inside a single page */
+       BUG_ON(length > PAGE_SIZE - offset_in_page(iomap->inline_data));
 
        if (dio->flags & IOMAP_DIO_WRITE) {
                loff_t size = inode->i_size;
 
                if (pos > size)
-                       memset(iomap->inline_data + size, 0, pos - size);
-               copied = copy_from_iter(iomap->inline_data + pos, length, iter);
+                       memset(iomap->inline_data + size - iomap->offset,
+                              0, pos - size);
+               copied = copy_from_iter(dst, length, iter);
                if (copied) {
                        if (pos + copied > size)
                                i_size_write(inode, pos + copied);
                        mark_inode_dirty(inode);
                }
        } else {
-               copied = copy_to_iter(iomap->inline_data + pos, length, iter);
+               copied = copy_to_iter(dst, length, iter);
        }
        dio->size += copied;
        return copied;
--
Quoted 2 lines

2.24.4

Thanks,
Andreas

author
#12 lore raw
Quoted 73 lines · Andreas Grünbacher

Am Mo., 19. Juli 2021 um 16:48 Uhr schrieb Gao Xiang <[email protected]>:

Quoted 71 lines

This tries to add tail packing inline read to iomap, which can support several inline tail blocks. Similar to the previous approach, it cleans post-EOF in one iteration.

The write path remains untouched since EROFS cannot be used for testing. It'd be better to be implemented if upcoming real users care rather than leave untested dead code around.

Cc Christoph Hellwig <[email protected]>
Cc Darrick J. Wong <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Andreas Gruenbacher <[email protected]>

---
v2: https://lore.kernel.org/r/YPLdSja%2F4FBsjss%[email protected]/
changes since v2:
- update suggestion from Christoph:
https://lore.kernel.org/r/[email protected]/

Hi Andreas,
would you mind test on the gfs2 side? Thanks in advance!

Thanks,
Gao Xiang

 fs/iomap/buffered-io.c | 50 ++++++++++++++++++++++++++----------------
 fs/iomap/direct-io.c   | 11 ++++++----
 2 files changed, 38 insertions(+), 23 deletions(-)
fs/iomap/buffered-io.c +10 -11
index 87ccb3438bec..cac8a88660d8 100644
@@ -207,23 +207,22 @@ struct iomap_readpage_ctx {
 
 static void
 iomap_read_inline_data(struct inode *inode, struct page *page,
-               struct iomap *iomap)
+               struct iomap *iomap, loff_t pos)
 {
-       size_t size = i_size_read(inode);
+       unsigned int size, poff = offset_in_page(pos);
        void *addr;
 
-       if (PageUptodate(page))
-               return;
-
-       BUG_ON(page_has_private(page));
-       BUG_ON(page->index);
-       BUG_ON(size > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* inline source data must be inside a single page */
+       BUG_ON(iomap->length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+       /* handle tail-packing blocks cross the current page into the next */
+       size = min_t(unsigned int, iomap->length + pos - iomap->offset,
+                    PAGE_SIZE - poff);
 
        addr = kmap_atomic(page);
-       memcpy(addr, iomap->inline_data, size);
-       memset(addr + size, 0, PAGE_SIZE - size);
+       memcpy(addr + poff, iomap->inline_data - iomap->offset + pos, size);
+       memset(addr + poff + size, 0, PAGE_SIZE - poff - size);
        kunmap_atomic(addr);
-       SetPageUptodate(page);
+       iomap_set_range_uptodate(page, poff, PAGE_SIZE - poff);
 }
 
 static inline bool iomap_block_needs_zeroing(struct inode *inode,
@@ -246,18 +245,19 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
        unsigned poff, plen;
        sector_t sector;
 
Quoted 10 lines

fs/iomap/buffered-io.c iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, · line 248

Quoted 8 lines
fs/iomap/buffered-io.c +0 -7
-       if (iomap->type == IOMAP_INLINE) {
-               WARN_ON_ONCE(pos);
-               iomap_read_inline_data(inode, page, iomap);
-               return PAGE_SIZE;
-       }
-
-       /* zero post-eof blocks as the page may be mapped */
        iop = iomap_page_create(inode, page);

We can skip creating the iop when reading the entire page.

As I said before, I think it can be in a separated patch like
https://lore.kernel.org/r/[email protected]/
and Christoph said it should be careful:
https://lore.kernel.org/r/YPVfxn6%[email protected]/

Thanks,
Gao Xiang