diff mbox

[16/34] iomap: add initial support for writes without buffer heads

Message ID 20180522083103.GA10079@lst.de (mailing list archive)
State New, archived
Headers show

Commit Message

Christoph Hellwig May 22, 2018, 8:31 a.m. UTC
The fix should be as simple as this:
diff mbox

Patch

diff --git a/fs/iomap.c b/fs/iomap.c
index 357711e50cfa..212c3c21e51c 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -342,19 +342,19 @@  __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
 	loff_t block_end = (pos + len + block_size - 1) & ~(block_size - 1);
 	unsigned poff = block_start & (PAGE_SIZE - 1);
 	unsigned plen = min_t(loff_t, PAGE_SIZE - poff, block_end - block_start);
+	unsigned from = pos & (PAGE_SIZE - 1);
+	unsigned to = from + len;
 	int status;
 
 	WARN_ON_ONCE(i_blocksize(inode) < PAGE_SIZE);
 
 	if (PageUptodate(page))
 		return 0;
+	if (poff >= from && poff + len <= to)
+		return 0;
 
 	if (iomap_block_needs_zeroing(inode, block_start, iomap)) {
-		unsigned from = pos & (PAGE_SIZE - 1), to = from + len;
-		unsigned pend = poff + plen;
-
-		if (poff < from || pend > to)
-			zero_user_segments(page, poff, from, to, pend);
+		zero_user_segments(page, poff, from, to, poff + len);
 	} else {
 		status = iomap_read_page_sync(inode, block_start, page,
 				poff, plen, iomap);