mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 08:33:17 +02:00
iomap: refactor iomap_iter() length check and tracepoint
iomap_iter() checks iomap.length to skip individual code blocks not appropriate for the initial case where there is no mapping in the iter. To prepare for upcoming changes, refactor the code to jump straight to the ->iomap_begin() handler in the initial case and move the tracepoint to the top of the function so it always executes. Signed-off-by: Brian Foster <bfoster@redhat.com> Link: https://lore.kernel.org/r/20250207143253.314068-4-bfoster@redhat.com Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
2e4b0b6cf5
commit
f479983866
|
|
@ -73,7 +73,12 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
|
|||
{
|
||||
int ret;
|
||||
|
||||
if (iter->iomap.length && ops->iomap_end) {
|
||||
trace_iomap_iter(iter, ops, _RET_IP_);
|
||||
|
||||
if (!iter->iomap.length)
|
||||
goto begin;
|
||||
|
||||
if (ops->iomap_end) {
|
||||
ret = ops->iomap_end(iter->inode, iter->pos, iomap_length(iter),
|
||||
iter->processed > 0 ? iter->processed : 0,
|
||||
iter->flags, &iter->iomap);
|
||||
|
|
@ -82,14 +87,12 @@ int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops)
|
|||
}
|
||||
|
||||
/* advance and clear state from the previous iteration */
|
||||
trace_iomap_iter(iter, ops, _RET_IP_);
|
||||
if (iter->iomap.length) {
|
||||
ret = iomap_iter_advance(iter, iter->processed);
|
||||
iomap_iter_reset_iomap(iter);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
}
|
||||
ret = iomap_iter_advance(iter, iter->processed);
|
||||
iomap_iter_reset_iomap(iter);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
|
||||
begin:
|
||||
ret = ops->iomap_begin(iter->inode, iter->pos, iter->len, iter->flags,
|
||||
&iter->iomap, &iter->srcmap);
|
||||
if (ret < 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user