From: Brian Foster <bfoster@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 1/6] iomap: resample iter->pos after iomap_write_begin() calls
Date: Wed, 30 Apr 2025 15:01:07 -0400 [thread overview]
Message-ID: <20250430190112.690800-2-bfoster@redhat.com> (raw)
In-Reply-To: <20250430190112.690800-1-bfoster@redhat.com>
In preparation for removing the pos parameter, push the local pos
assignment down after calls to iomap_write_begin().
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/iomap/buffered-io.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index 5b08bd417b28..a41c8ffc4996 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -920,11 +920,11 @@ static int iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
size_t bytes; /* Bytes to write to folio */
size_t copied; /* Bytes copied from user */
u64 written; /* Bytes have been written */
- loff_t pos = iter->pos;
+ loff_t pos;
bytes = iov_iter_count(i);
retry:
- offset = pos & (chunk - 1);
+ offset = iter->pos & (chunk - 1);
bytes = min(chunk - offset, bytes);
status = balance_dirty_pages_ratelimited_flags(mapping,
bdp_flags);
@@ -949,13 +949,14 @@ static int iomap_write_iter(struct iomap_iter *iter, struct iov_iter *i)
break;
}
- status = iomap_write_begin(iter, pos, bytes, &folio);
+ status = iomap_write_begin(iter, iter->pos, bytes, &folio);
if (unlikely(status)) {
- iomap_write_failed(iter->inode, pos, bytes);
+ iomap_write_failed(iter->inode, iter->pos, bytes);
break;
}
if (iter->iomap.flags & IOMAP_F_STALE)
break;
+ pos = iter->pos;
offset = offset_in_folio(folio, pos);
if (bytes > folio_size(folio) - offset)
@@ -1276,15 +1277,16 @@ static int iomap_unshare_iter(struct iomap_iter *iter)
do {
struct folio *folio;
size_t offset;
- loff_t pos = iter->pos;
+ loff_t pos;
bool ret;
bytes = min_t(u64, SIZE_MAX, bytes);
- status = iomap_write_begin(iter, pos, bytes, &folio);
+ status = iomap_write_begin(iter, iter->pos, bytes, &folio);
if (unlikely(status))
return status;
if (iomap->flags & IOMAP_F_STALE)
break;
+ pos = iter->pos;
offset = offset_in_folio(folio, pos);
if (bytes > folio_size(folio) - offset)
@@ -1351,15 +1353,16 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero)
do {
struct folio *folio;
size_t offset;
- loff_t pos = iter->pos;
+ loff_t pos;
bool ret;
bytes = min_t(u64, SIZE_MAX, bytes);
- status = iomap_write_begin(iter, pos, bytes, &folio);
+ status = iomap_write_begin(iter, iter->pos, bytes, &folio);
if (status)
return status;
if (iter->iomap.flags & IOMAP_F_STALE)
break;
+ pos = iter->pos;
/* warn about zeroing folios beyond eof that won't write back */
WARN_ON_ONCE(folio_pos(folio) > iter->inode->i_size);
--
2.49.0
next prev parent reply other threads:[~2025-04-30 18:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 19:01 [PATCH 0/6] iomap: misc buffered write path cleanups and prep Brian Foster
2025-04-30 19:01 ` Brian Foster [this message]
2025-05-05 9:00 ` [PATCH 1/6] iomap: resample iter->pos after iomap_write_begin() calls Christoph Hellwig
2025-04-30 19:01 ` [PATCH 2/6] iomap: drop unnecessary pos param from iomap_write_[begin|end] Brian Foster
2025-05-01 22:22 ` Darrick J. Wong
2025-05-05 9:01 ` Christoph Hellwig
2025-04-30 19:01 ` [PATCH 3/6] iomap: drop pos param from __iomap_[get|put]_folio() Brian Foster
2025-05-01 22:22 ` Darrick J. Wong
2025-05-05 9:01 ` Christoph Hellwig
2025-04-30 19:01 ` [PATCH 4/6] iomap: helper to trim pos/bytes to within folio Brian Foster
2025-05-05 9:03 ` Christoph Hellwig
2025-05-05 14:38 ` Brian Foster
2025-04-30 19:01 ` [PATCH 5/6] iomap: push non-large folio check into get folio path Brian Foster
2025-05-05 9:03 ` Christoph Hellwig
2025-04-30 19:01 ` [PATCH 6/6] iomap: rework iomap_write_begin() to return folio offset and length Brian Foster
2025-05-01 22:22 ` Darrick J. Wong
2025-05-02 13:18 ` Brian Foster
2025-05-02 19:40 ` Darrick J. Wong
2025-05-02 20:00 ` Darrick J. Wong
2025-05-05 14:39 ` Brian Foster
2025-05-05 9:05 ` Christoph Hellwig
2025-05-05 14:39 ` 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=20250430190112.690800-2-bfoster@redhat.com \
--to=bfoster@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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).