Skip to content
  • Matthew Wilcox (Oracle)'s avatar
    44a83bd3
    iomap: Clear page error before beginning a write · 44a83bd3
    Matthew Wilcox (Oracle) authored
    
    
    [ Upstream commit e6e7ca92 ]
    
    If we find a page in write_begin which is !Uptodate, we need
    to clear any error on the page before starting to read data
    into it.  This matches how filemap_fault(), do_read_cache_page()
    and generic_file_buffered_read() handle PageError on !Uptodate pages.
    When calling iomap_set_range_uptodate() in __iomap_write_begin(), blocks
    were not being marked as uptodate.
    
    This was found with generic/127 and a specially modified kernel which
    would fail (some) readahead I/Os.  The test read some bytes in a prior
    page which caused readahead to extend into page 0x34.  There was
    a subsequent write to page 0x34, followed by a read to page 0x34.
    Because the blocks were still marked as !Uptodate, the read caused all
    blocks to be re-read, overwriting the write.  With this change, and the
    next one, the bytes which were written are marked as being Uptodate, so
    even though the page is still marked as !Uptodate, the blocks containing
    the written data are not re-read from storage.
    
    Fixes: 9dc55f13 ("iomap: add support for sub-pagesize buffered I/O without buffer heads")
    Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
    Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
    44a83bd3
    iomap: Clear page error before beginning a write
    Matthew Wilcox (Oracle) authored
    
    
    [ Upstream commit e6e7ca92 ]
    
    If we find a page in write_begin which is !Uptodate, we need
    to clear any error on the page before starting to read data
    into it.  This matches how filemap_fault(), do_read_cache_page()
    and generic_file_buffered_read() handle PageError on !Uptodate pages.
    When calling iomap_set_range_uptodate() in __iomap_write_begin(), blocks
    were not being marked as uptodate.
    
    This was found with generic/127 and a specially modified kernel which
    would fail (some) readahead I/Os.  The test read some bytes in a prior
    page which caused readahead to extend into page 0x34.  There was
    a subsequent write to page 0x34, followed by a read to page 0x34.
    Because the blocks were still marked as !Uptodate, the read caused all
    blocks to be re-read, overwriting the write.  With this change, and the
    next one, the bytes which were written are marked as being Uptodate, so
    even though the page is still marked as !Uptodate, the blocks containing
    the written data are not re-read from storage.
    
    Fixes: 9dc55f13 ("iomap: add support for sub-pagesize buffered I/O without buffer heads")
    Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
    Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Loading