From: alexjlzheng@gmail.com
To: brauner@kernel.org, djwong@kernel.org, hch@infradead.org,
kernel@pankajraghav.com
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, yi.zhang@huawei.com,
Jinliang Zheng <alexjlzheng@tencent.com>
Subject: [PATCH v5 2/4] iomap: move iter revert case out of the unwritten branch
Date: Tue, 23 Sep 2025 12:21:56 +0800 [thread overview]
Message-ID: <20250923042158.1196568-3-alexjlzheng@tencent.com> (raw)
In-Reply-To: <20250923042158.1196568-1-alexjlzheng@tencent.com>
From: Jinliang Zheng <alexjlzheng@tencent.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@tencent.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 ee1b2cd8a4b4..e130db3b761e 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
next prev parent reply other threads:[~2025-09-23 4:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 4:21 [PATCH v5 0/4] allow partial folio write with iomap_folio_state alexjlzheng
2025-09-23 4:21 ` [PATCH v5 1/4] iomap: make sure iomap_adjust_read_range() are aligned with block_size alexjlzheng
2025-09-25 18:59 ` Brian Foster
2025-09-23 4:21 ` alexjlzheng [this message]
2025-09-25 18:59 ` [PATCH v5 2/4] iomap: move iter revert case out of the unwritten branch Brian Foster
2025-09-23 4:21 ` [PATCH v5 3/4] iomap: make iomap_write_end() return the number of written length again alexjlzheng
2025-09-25 19:00 ` Brian Foster
2025-09-23 4:21 ` [PATCH v5 4/4] iomap: don't abandon the whole copy when we have iomap_folio_state alexjlzheng
2025-09-25 19:01 ` Brian Foster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250923042158.1196568-3-alexjlzheng@tencent.com \
--to=alexjlzheng@gmail.com \
--cc=alexjlzheng@tencent.com \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=kernel@pankajraghav.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=yi.zhang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).