From cd49bc2099921a031e3806723646eeb641880eee Mon Sep 17 00:00:00 2001 From: Long Li Date: Fri, 7 Jun 2024 17:33:23 +0800 Subject: [PATCH 1/2] Revert "iomap: Don't create iomap_page objects in iomap_page_mkwrite_actor" hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9UNQS CVE: NA ------------------------------------------ To properly set the dirty state of sub-pages during mmap write operations, it is necessary to ensure that the iop is created beforehand. This prevents issues where the iop might not yet be created when attempting to set the sub-page's dirty state. This reverts commit 9df337860ce3b4de377a68a2b7e8c123fe4118ce. Fixes: 99e9a55ba32b ("iomap: add support to track dirty state of sub pages") Signed-off-by: Long Li --- fs/iomap/buffered-io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 25448d5827d2..304269c845e0 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1073,6 +1073,7 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length, block_commit_write(page, 0, length); } else { WARN_ON_ONCE(!PageUptodate(page)); + iomap_page_create(inode, page); set_page_dirty(page); } -- Gitee From ab70155ba3bbcdb1c425f21e21d41ae02fce14d8 Mon Sep 17 00:00:00 2001 From: Long Li Date: Fri, 7 Jun 2024 17:33:24 +0800 Subject: [PATCH 2/2] iomap: Ensure sub-page dirty state is set during mmap writes hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I9UNQS CVE: NA ------------------------------------------ While running xfstests, specifically test xfs/032, the following errors were reported: XFS (sdb): ino 4a data fork has delalloc extent at [0x3c:0x10] XFS: Assertion failed: 0, file: fs/xfs/xfs_icache.c, line: 1854 The issue stems from the dirty state of sub-pages not being set during mmap writes. This behavior was observed after the introduction of the commit 99e9a55ba32b ("iomap: add support to track dirty state of sub-pages"), which enabled iomap to track the dirty state of sub-pages when the block size is smaller than the page size. Currently, iomap updates the sub-page dirty state only in `__iomap_write_end()`. However, the mmap write path does not invoke this function, resulting in dirty pages created by mmap writes not being scheduled for write-back. This patch fixes the issue by ensuring that the sub-page dirty state is set during mmap writes. Fixes: 99e9a55ba32b ("iomap: add support to track dirty state of sub pages") Signed-off-by: Long Li --- fs/iomap/buffered-io.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 304269c845e0..45471ee7e919 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -158,9 +158,6 @@ iomap_set_range_dirty(struct page *page, unsigned int off, unsigned int len) if (PageError(page)) return; - if (len) - iomap_set_page_dirty(page); - if (!page_has_private(page)) return; @@ -757,6 +754,7 @@ static size_t __iomap_write_end(struct inode *inode, loff_t pos, size_t len, if (unlikely(copied < len && !PageUptodate(page))) return 0; iomap_set_range_uptodate(page, offset_in_page(pos), len); + iomap_set_page_dirty(page); iomap_set_range_dirty(page, offset_in_page(pos), len); return copied; } @@ -1075,6 +1073,7 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length, WARN_ON_ONCE(!PageUptodate(page)); iomap_page_create(inode, page); set_page_dirty(page); + iomap_set_range_dirty(page, offset_in_page(pos), length); } return length; -- Gitee