Skip to content
Snippets Groups Projects
Commit a259beb0 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Yang Yingliang
Browse files

iomap: Mark read blocks uptodate in write_begin


mainline inclusion
from mainline-v5.10
commit 14284fed
category: bugfix
bugzilla: 43547
CVE: NA

-----------------------------------------------

When bringing (portions of) a page uptodate, we were marking blocks that
were zeroed as being uptodate, but not blocks that were read from storage.

Like the previous commit, this problem was found with generic/127 and
a kernel which failed readahead I/Os.  This bug causes writes to be
silently lost when working with flaky 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>

conflicts:
fs/iomap.c

Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
Reviewed-by: default avatarZhang Yi <yi.zhang@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parent b3a0aab5
No related branches found
No related tags found
No related merge requests found
......@@ -649,7 +649,6 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
loff_t block_start = pos & ~(block_size - 1);
loff_t block_end = (pos + len + block_size - 1) & ~(block_size - 1);
unsigned from = offset_in_page(pos), to = from + len, poff, plen;
int status = 0;
if (PageUptodate(page))
return 0;
......@@ -668,14 +667,14 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
if (iomap->type != IOMAP_MAPPED ||
block_start >= i_size_read(inode)) {
zero_user_segments(page, poff, from, to, poff + plen);
iomap_set_range_uptodate(page, poff, plen);
continue;
} else {
int status = iomap_read_page_sync(block_start, page,
poff, plen, iomap);
if (status)
return status;
}
status = iomap_read_page_sync(block_start, page, poff, plen,
iomap);
if (status)
return status;
iomap_set_range_uptodate(page, poff, plen);
} while ((block_start += plen) < block_end);
return 0;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment