Skip to content

Commit

Permalink
iomap: Set all uptodate bits for an Uptodate page
Browse files Browse the repository at this point in the history
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: 9dc55f1 ("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>
  • Loading branch information
Matthew Wilcox (Oracle) authored and Darrick J. Wong committed Sep 28, 2020
1 parent 81ee8e5 commit 4595a29
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/iomap/buffered-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ iomap_page_create(struct inode *inode, struct page *page)
iop = kzalloc(struct_size(iop, uptodate, BITS_TO_LONGS(nr_blocks)),
GFP_NOFS | __GFP_NOFAIL);
spin_lock_init(&iop->uptodate_lock);
if (PageUptodate(page))
bitmap_fill(iop->uptodate, nr_blocks);
attach_page_private(page, iop);
return iop;
}
Expand Down

0 comments on commit 4595a29

Please sign in to comment.