Message ID | 20250205135821.178256-2-bfoster@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | iomap: incremental per-operation iter advance | expand |
On Wed, Feb 05, 2025 at 08:58:12AM -0500, Brian Foster wrote: > In preparation to support more granular iomap iter advancing, factor > the pos/len values as parameters to length calculation. > > Signed-off-by: Brian Foster <bfoster@redhat.com> > Reviewed-by: Christoph Hellwig <hch@lst.de> Looks ok, Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > include/linux/iomap.h | 23 +++++++++++++++++++---- > 1 file changed, 19 insertions(+), 4 deletions(-) > > diff --git a/include/linux/iomap.h b/include/linux/iomap.h > index 75bf54e76f3b..f5ca71ac2fa2 100644 > --- a/include/linux/iomap.h > +++ b/include/linux/iomap.h > @@ -231,18 +231,33 @@ struct iomap_iter { > int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops); > > /** > - * iomap_length - length of the current iomap iteration > + * iomap_length_trim - trimmed length of the current iomap iteration > * @iter: iteration structure > + * @pos: File position to trim from. > + * @len: Length of the mapping to trim to. > * > - * Returns the length that the operation applies to for the current iteration. > + * Returns a trimmed length that the operation applies to for the current > + * iteration. > */ > -static inline u64 iomap_length(const struct iomap_iter *iter) > +static inline u64 iomap_length_trim(const struct iomap_iter *iter, loff_t pos, > + u64 len) > { > u64 end = iter->iomap.offset + iter->iomap.length; > > if (iter->srcmap.type != IOMAP_HOLE) > end = min(end, iter->srcmap.offset + iter->srcmap.length); > - return min(iter->len, end - iter->pos); > + return min(len, end - pos); > +} > + > +/** > + * iomap_length - length of the current iomap iteration > + * @iter: iteration structure > + * > + * Returns the length that the operation applies to for the current iteration. > + */ > +static inline u64 iomap_length(const struct iomap_iter *iter) > +{ > + return iomap_length_trim(iter, iter->pos, iter->len); > } > > /** > -- > 2.48.1 > >
diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 75bf54e76f3b..f5ca71ac2fa2 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -231,18 +231,33 @@ struct iomap_iter { int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops); /** - * iomap_length - length of the current iomap iteration + * iomap_length_trim - trimmed length of the current iomap iteration * @iter: iteration structure + * @pos: File position to trim from. + * @len: Length of the mapping to trim to. * - * Returns the length that the operation applies to for the current iteration. + * Returns a trimmed length that the operation applies to for the current + * iteration. */ -static inline u64 iomap_length(const struct iomap_iter *iter) +static inline u64 iomap_length_trim(const struct iomap_iter *iter, loff_t pos, + u64 len) { u64 end = iter->iomap.offset + iter->iomap.length; if (iter->srcmap.type != IOMAP_HOLE) end = min(end, iter->srcmap.offset + iter->srcmap.length); - return min(iter->len, end - iter->pos); + return min(len, end - pos); +} + +/** + * iomap_length - length of the current iomap iteration + * @iter: iteration structure + * + * Returns the length that the operation applies to for the current iteration. + */ +static inline u64 iomap_length(const struct iomap_iter *iter) +{ + return iomap_length_trim(iter, iter->pos, iter->len); } /**