From: Brian Foster <bfoster@redhat.com>
To: alexjlzheng@gmail.com
Cc: brauner@kernel.org, djwong@kernel.org, hch@infradead.org,
kernel@pankajraghav.com, 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: Re: [PATCH v5 3/4] iomap: make iomap_write_end() return the number of written length again
Date: Thu, 25 Sep 2025 15:00:35 -0400 [thread overview]
Message-ID: <aNWRUyZhdhX7lzig@bfoster> (raw)
In-Reply-To: <20250923042158.1196568-4-alexjlzheng@tencent.com>
On Tue, Sep 23, 2025 at 12:21:57PM +0800, alexjlzheng@gmail.com wrote:
> From: Jinliang Zheng <alexjlzheng@tencent.com>
>
> In the next patch, we allow iomap_write_end() to conditionally accept
> partial writes, so this patch makes iomap_write_end() return the number
> of accepted write bytes in preparation for the next patch.
>
> Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
> ---
> fs/iomap/buffered-io.c | 27 +++++++++++++--------------
> 1 file changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index e130db3b761e..6e516c7d9f04 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
...
> @@ -915,10 +915,10 @@ static void iomap_write_end_inline(const struct iomap_iter *iter,
> }
>
> /*
> - * Returns true if all copied bytes have been written to the pagecache,
> - * otherwise return false.
> + * Returns number of copied bytes have been written to the pagecache,
> + * zero if block is partial update.
> */
> -static bool iomap_write_end(struct iomap_iter *iter, size_t len, size_t copied,
> +static int iomap_write_end(struct iomap_iter *iter, size_t len, size_t copied,
> struct folio *folio)
> {
> const struct iomap *srcmap = iomap_iter_srcmap(iter);
> @@ -926,7 +926,7 @@ static bool iomap_write_end(struct iomap_iter *iter, size_t len, size_t copied,
>
> if (srcmap->type == IOMAP_INLINE) {
> iomap_write_end_inline(iter, folio, pos, copied);
> - return true;
> + return copied;
> }
>
> if (srcmap->flags & IOMAP_F_BUFFER_HEAD) {
> @@ -934,7 +934,7 @@ static bool iomap_write_end(struct iomap_iter *iter, size_t len, size_t copied,
>
> bh_written = block_write_end(pos, len, copied, folio);
> WARN_ON_ONCE(bh_written != copied && bh_written != 0);
> - return bh_written == copied;
> + return bh_written;
I notice block_write_end() actually returns an int. Not sure it's an
issue really, but perhaps we should just change the type of bh_written
here as well. Otherwise seems reasonable.
Brian
> }
>
> return __iomap_write_end(iter->inode, pos, len, copied, folio);
> @@ -1000,8 +1000,7 @@ static int iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i,
> flush_dcache_folio(folio);
>
> copied = copy_folio_from_iter_atomic(folio, offset, bytes, i);
> - written = iomap_write_end(iter, bytes, copied, folio) ?
> - copied : 0;
> + written = iomap_write_end(iter, bytes, copied, folio);
>
> /*
> * Update the in-memory inode size after copying the data into
> @@ -1315,7 +1314,7 @@ static int iomap_unshare_iter(struct iomap_iter *iter,
> do {
> struct folio *folio;
> size_t offset;
> - bool ret;
> + int ret;
>
> bytes = min_t(u64, SIZE_MAX, bytes);
> status = iomap_write_begin(iter, write_ops, &folio, &offset,
> @@ -1327,7 +1326,7 @@ static int iomap_unshare_iter(struct iomap_iter *iter,
>
> ret = iomap_write_end(iter, bytes, bytes, folio);
> __iomap_put_folio(iter, write_ops, bytes, folio);
> - if (WARN_ON_ONCE(!ret))
> + if (WARN_ON_ONCE(ret != bytes))
> return -EIO;
>
> cond_resched();
> @@ -1388,7 +1387,7 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero,
> do {
> struct folio *folio;
> size_t offset;
> - bool ret;
> + int ret;
>
> bytes = min_t(u64, SIZE_MAX, bytes);
> status = iomap_write_begin(iter, write_ops, &folio, &offset,
> @@ -1406,7 +1405,7 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero,
>
> ret = iomap_write_end(iter, bytes, bytes, folio);
> __iomap_put_folio(iter, write_ops, bytes, folio);
> - if (WARN_ON_ONCE(!ret))
> + if (WARN_ON_ONCE(ret != bytes))
> return -EIO;
>
> status = iomap_iter_advance(iter, &bytes);
> --
> 2.49.0
>
>
next prev parent reply other threads:[~2025-09-25 18:56 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 ` [PATCH v5 2/4] iomap: move iter revert case out of the unwritten branch alexjlzheng
2025-09-25 18:59 ` 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 [this message]
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=aNWRUyZhdhX7lzig@bfoster \
--to=bfoster@redhat.com \
--cc=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).