From: Brian Foster <bfoster@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-xfs@vger.kernel.org, hch@infradead.org, djwong@kernel.org
Subject: [PATCH v4 1/3] iomap: reset per-iter state on non-error iter advances
Date: Fri, 15 Nov 2024 15:01:53 -0500 [thread overview]
Message-ID: <20241115200155.593665-2-bfoster@redhat.com> (raw)
In-Reply-To: <20241115200155.593665-1-bfoster@redhat.com>
iomap_iter_advance() zeroes the processed and mapping fields on
every non-error iteration except for the last expected iteration
(i.e. return 0 expected to terminate the iteration loop). This
appears to be circumstantial as nothing currently relies on these
fields after the final iteration.
Therefore to better faciliate iomap_iter reuse in subsequent
patches, update iomap_iter_advance() to always reset per-iteration
state on successful completion.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
fs/iomap/iter.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/iomap/iter.c b/fs/iomap/iter.c
index 79a0614eaab7..3790918646af 100644
--- a/fs/iomap/iter.c
+++ b/fs/iomap/iter.c
@@ -22,26 +22,25 @@
static inline int iomap_iter_advance(struct iomap_iter *iter)
{
bool stale = iter->iomap.flags & IOMAP_F_STALE;
+ int ret = 1;
/* handle the previous iteration (if any) */
if (iter->iomap.length) {
if (iter->processed < 0)
return iter->processed;
- if (!iter->processed && !stale)
- return 0;
if (WARN_ON_ONCE(iter->processed > iomap_length(iter)))
return -EIO;
iter->pos += iter->processed;
iter->len -= iter->processed;
- if (!iter->len)
- return 0;
+ if (!iter->len || (!iter->processed && !stale))
+ ret = 0;
}
- /* clear the state for the next iteration */
+ /* clear the per iteration state */
iter->processed = 0;
memset(&iter->iomap, 0, sizeof(iter->iomap));
memset(&iter->srcmap, 0, sizeof(iter->srcmap));
- return 1;
+ return ret;
}
static inline void iomap_iter_done(struct iomap_iter *iter)
--
2.47.0
next prev parent reply other threads:[~2024-11-15 20:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 20:01 [PATCH v4 0/3] iomap: zero range flush fixes Brian Foster
2024-11-15 20:01 ` Brian Foster [this message]
2024-11-15 20:01 ` [PATCH v4 2/3] iomap: lift zeroed mapping handling into iomap_zero_range() Brian Foster
2024-11-18 6:29 ` Christoph Hellwig
2024-11-18 13:54 ` Brian Foster
2024-11-18 14:14 ` Christoph Hellwig
2024-11-15 20:01 ` [PATCH v4 3/3] iomap: elide flush from partial eof zero range Brian Foster
2024-11-20 8:33 ` [PATCH v4 0/3] iomap: zero range flush fixes Christian Brauner
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=20241115200155.593665-2-bfoster@redhat.com \
--to=bfoster@redhat.com \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.