* [PATCH 4.19.y] iomap: Set all uptodate bits for an Uptodate page
@ 2023-11-16 6:40 zhangshida
2023-11-24 16:02 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: zhangshida @ 2023-11-16 6:40 UTC (permalink / raw)
To: stable
Cc: starzhangzsd, zhangshida, Matthew Wilcox (Oracle), Qian Cai,
Brian Foster, Gao Xiang, Darrick J . Wong, Christoph Hellwig
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
commit 4595a298d5563cf76c1d852970f162051fd1a7a6 upstream.
For filesystems with block size < page size, we need to set all the
per-block uptodate bits if the page was already uptodate at the time
we create the per-block metadata. This can happen if the page is
invalidated (eg by a write to drop_caches) but ultimately not removed
from the page cache.
This is a data corruption issue as page writeback skips blocks which
are marked !uptodate.
Fixes: 9dc55f1389f9 ("iomap: add support for sub-pagesize buffered I/O without buffer heads")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reported-by: Qian Cai <cai@redhat.com>
Cc: Brian Foster <bfoster@redhat.com>
Reviewed-by: Gao Xiang <hsiangkao@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
---
fs/iomap.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/iomap.c b/fs/iomap.c
index ac7b2152c3ad..04e82b6bd9bf 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -109,6 +109,7 @@ static struct iomap_page *
iomap_page_create(struct inode *inode, struct page *page)
{
struct iomap_page *iop = to_iomap_page(page);
+ unsigned int nr_blocks = PAGE_SIZE / i_blocksize(inode);
if (iop || i_blocksize(inode) == PAGE_SIZE)
return iop;
@@ -118,6 +119,8 @@ iomap_page_create(struct inode *inode, struct page *page)
atomic_set(&iop->write_count, 0);
spin_lock_init(&iop->uptodate_lock);
bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);
+ if (PageUptodate(page))
+ bitmap_fill(iop->uptodate, nr_blocks);
/*
* migrate_page_move_mapping() assumes that pages with private data have
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 4.19.y] iomap: Set all uptodate bits for an Uptodate page
2023-11-16 6:40 [PATCH 4.19.y] iomap: Set all uptodate bits for an Uptodate page zhangshida
@ 2023-11-24 16:02 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2023-11-24 16:02 UTC (permalink / raw)
To: zhangshida
Cc: stable, zhangshida, Matthew Wilcox (Oracle), Qian Cai,
Brian Foster, Gao Xiang, Darrick J . Wong, Christoph Hellwig
On Thu, Nov 16, 2023 at 02:40:10PM +0800, zhangshida wrote:
> From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
>
> commit 4595a298d5563cf76c1d852970f162051fd1a7a6 upstream.
>
> For filesystems with block size < page size, we need to set all the
> per-block uptodate bits if the page was already uptodate at the time
> we create the per-block metadata. This can happen if the page is
> invalidated (eg by a write to drop_caches) but ultimately not removed
> from the page cache.
>
> This is a data corruption issue as page writeback skips blocks which
> are marked !uptodate.
>
> Fixes: 9dc55f1389f9 ("iomap: add support for sub-pagesize buffered I/O without buffer heads")
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Reported-by: Qian Cai <cai@redhat.com>
> Cc: Brian Foster <bfoster@redhat.com>
> Reviewed-by: Gao Xiang <hsiangkao@redhat.com>
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
> ---
> fs/iomap.c | 3 +++
> 1 file changed, 3 insertions(+)
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-24 16:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-16 6:40 [PATCH 4.19.y] iomap: Set all uptodate bits for an Uptodate page zhangshida
2023-11-24 16:02 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox