diff mbox series

[2/6] iomap: factor out iomap length helper

Message ID 20241213143610.1002526-3-bfoster@redhat.com (mailing list archive)
State New
Headers show
Series iomap: incremental per-operation iter advance | expand

Commit Message

Brian Foster Dec. 13, 2024, 2:36 p.m. UTC
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>
---
 include/linux/iomap.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 5675af6b740c..cbacccb3fb14 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -236,13 +236,19 @@  int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops);
  *
  * Returns the 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(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);
+}
+
+static inline u64 iomap_length(const struct iomap_iter *iter)
+{
+	return __iomap_length(iter, iter->pos, iter->len);
 }
 
 /**