mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
iomap: reset per-iter state on non-error iter advances
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> Link: https://lore.kernel.org/r/20241115200155.593665-2-bfoster@redhat.com Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
a514e6f8f5
commit
2519369201
1 changed files with 5 additions and 6 deletions
|
@ -22,26 +22,25 @@
|
||||||
static inline int iomap_iter_advance(struct iomap_iter *iter)
|
static inline int iomap_iter_advance(struct iomap_iter *iter)
|
||||||
{
|
{
|
||||||
bool stale = iter->iomap.flags & IOMAP_F_STALE;
|
bool stale = iter->iomap.flags & IOMAP_F_STALE;
|
||||||
|
int ret = 1;
|
||||||
|
|
||||||
/* handle the previous iteration (if any) */
|
/* handle the previous iteration (if any) */
|
||||||
if (iter->iomap.length) {
|
if (iter->iomap.length) {
|
||||||
if (iter->processed < 0)
|
if (iter->processed < 0)
|
||||||
return iter->processed;
|
return iter->processed;
|
||||||
if (!iter->processed && !stale)
|
|
||||||
return 0;
|
|
||||||
if (WARN_ON_ONCE(iter->processed > iomap_length(iter)))
|
if (WARN_ON_ONCE(iter->processed > iomap_length(iter)))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
iter->pos += iter->processed;
|
iter->pos += iter->processed;
|
||||||
iter->len -= iter->processed;
|
iter->len -= iter->processed;
|
||||||
if (!iter->len)
|
if (!iter->len || (!iter->processed && !stale))
|
||||||
return 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clear the state for the next iteration */
|
/* clear the per iteration state */
|
||||||
iter->processed = 0;
|
iter->processed = 0;
|
||||||
memset(&iter->iomap, 0, sizeof(iter->iomap));
|
memset(&iter->iomap, 0, sizeof(iter->iomap));
|
||||||
memset(&iter->srcmap, 0, sizeof(iter->srcmap));
|
memset(&iter->srcmap, 0, sizeof(iter->srcmap));
|
||||||
return 1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void iomap_iter_done(struct iomap_iter *iter)
|
static inline void iomap_iter_done(struct iomap_iter *iter)
|
||||||
|
|
Loading…
Add table
Reference in a new issue