From: Christoph Hellwig hch@lst.de
mainline inclusion from mainline-v5.5-rc1 commit d3b404396977fde1daca3fb4fd4d3b01a3749093 category: bugfix bugzilla: 43551 CVE: NA
-----------------------------------------------
That keeps the function a little easier to understand, and easier to modify for pending enhancements.
Signed-off-by: Christoph Hellwig hch@lst.de Reviewed-by: Darrick J. Wong darrick.wong@oracle.com Signed-off-by: Darrick J. Wong darrick.wong@oracle.com
conflicts: fs/iomap.c
Signed-off-by: Ye Bin yebin10@huawei.com Reviewed-by: Zhang Yi yi.zhang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- fs/iomap.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/fs/iomap.c b/fs/iomap.c index fd3439997d292..efd92e08aa266 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -626,19 +626,12 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len) }
static int -iomap_read_page_sync(struct inode *inode, loff_t block_start, struct page *page, - unsigned poff, unsigned plen, unsigned from, unsigned to, - struct iomap *iomap) +iomap_read_page_sync(loff_t block_start, struct page *page, unsigned poff, + unsigned plen, struct iomap *iomap) { struct bio_vec bvec; struct bio bio;
- 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); - return 0; - } - bio_init(&bio, &bvec, 1); bio.bi_opf = REQ_OP_READ; bio.bi_iter.bi_sector = iomap_sector(iomap, block_start); @@ -667,17 +660,24 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, if (plen == 0) break;
- if ((from > poff && from < poff + plen) || - (to > poff && to < poff + plen)) { - status = iomap_read_page_sync(inode, block_start, page, - poff, plen, from, to, iomap); - if (status) - break; + if ((from <= poff || from >= poff + plen) && + (to <= poff || to >= poff + plen)) + continue; + + 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; } + status = iomap_read_page_sync(block_start, page, poff, plen, + iomap); + if (status) + return status;
} while ((block_start += plen) < block_end);
- return status; + return 0; }
static int