[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250812091538.2004295-3-alexjlzheng@tencent.com>
Date: Tue, 12 Aug 2025 17:15:36 +0800
From: alexjlzheng@...il.com
To: brauner@...nel.org,
djwong@...nel.org
Cc: linux-xfs@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
yi.zhang@...wei.com,
Jinliang Zheng <alexjlzheng@...cent.com>
Subject: [PATCH v3 2/4] iomap: move iter revert case out of the unwritten branch
From: Jinliang Zheng <alexjlzheng@...cent.com>
The commit e1f453d4336d ("iomap: do some small logical cleanup in
buffered write") merged iomap_write_failed() and iov_iter_revert()
into the branch with written == 0. Because, at the time,
iomap_write_end() could never return a partial write length.
In the subsequent patch, iomap_write_end() will be modified to allow
to return block-aligned partial write length (partial write length
here is relative to the folio-sized write), which violated the above
patch's assumption.
This patch moves it back out to prepare for the subsequent patches.
Signed-off-by: Jinliang Zheng <alexjlzheng@...cent.com>
---
fs/iomap/buffered-io.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 0c38333933c6..109c3bad6ccf 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1019,6 +1019,11 @@ static int iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i,
if (old_size < pos)
pagecache_isize_extended(iter->inode, old_size, pos);
+ if (written < bytes)
+ iomap_write_failed(iter->inode, pos + written,
+ bytes - written);
+ if (unlikely(copied != written))
+ iov_iter_revert(i, copied - written);
cond_resched();
if (unlikely(written == 0)) {
@@ -1028,9 +1033,6 @@ static int iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i,
* halfway through, might be a race with munmap,
* might be severe memory pressure.
*/
- iomap_write_failed(iter->inode, pos, bytes);
- iov_iter_revert(i, copied);
-
if (chunk > PAGE_SIZE)
chunk /= 2;
if (copied) {
--
2.49.0
Powered by blists - more mailing lists