From patchwork Thu Jan 30 17:09:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Foster X-Patchwork-Id: 13954736 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F37C81EF081 for ; Thu, 30 Jan 2025 17:07:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738256865; cv=none; b=lDLahJjYBO4xt2fb2ic8GQQPm81MzvK9rHTRO4+QzxZMAOApGU7QGpE4PYhBIS201hAdXyDo/czeqg7z8SrxJuUGvd0jlSukeKxQ+O04KER+qL9MTU9B4wt0oxBx0bU7SXLpfmj61yRqP+sT0eKNDF0cR1u0ttCF3RZSfjLpL0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738256865; c=relaxed/simple; bh=F6nitF1RA8Ks+0UbuwspJowzlmUpb5/2u/8WdMxeJbQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZHhpHtIfZUec+Lh4cwWWBxMI58GAV+XZCWTPJwSoS+Vf9Oy4QdKjD2M5rLmujiqgyQAB/fSSfLfI2v8RkOQlWaHSOjLSFwTNev5O/aHORHbPIDBCCb8meWd5KaGuZzN45l0WVTouJxfOpPKvCexHO9CfAwi17uAf0K2hXpEsZjw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UAqv9Ydm; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UAqv9Ydm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738256862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CBbISAal2K72JLWIf5DrIZYo0Uh2lYCJgSNclGMZ9w4=; b=UAqv9YdmZQNiUqwqRpb6m/cnGVYpOQbRrLDBYoVq/g6vEzkXx3pY5KZSenYH+aCVPZbZZK nDrlAeRL6/1AGKkpynae/EN2iph8ybzsmAboEBD+p0wKkeRy1qKxnuw2GUtQw5pDgaNUsC /pb04cCcRrWJ+QgmfRhMVboQDN1O8xI= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-257-LcRCS6mANu2OYKXH7Te8IA-1; Thu, 30 Jan 2025 12:07:39 -0500 X-MC-Unique: LcRCS6mANu2OYKXH7Te8IA-1 X-Mimecast-MFC-AGG-ID: LcRCS6mANu2OYKXH7Te8IA Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6D58419560BB; Thu, 30 Jan 2025 17:07:38 +0000 (UTC) Received: from bfoster.redhat.com (unknown [10.22.80.113]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A0A7830001BE; Thu, 30 Jan 2025 17:07:37 +0000 (UTC) From: Brian Foster To: linux-fsdevel@vger.kernel.org Cc: linux-xfs@vger.kernel.org, Christoph Hellwig Subject: [PATCH v3 2/7] iomap: factor out iomap length helper Date: Thu, 30 Jan 2025 12:09:43 -0500 Message-ID: <20250130170949.916098-3-bfoster@redhat.com> In-Reply-To: <20250130170949.916098-1-bfoster@redhat.com> References: <20250130170949.916098-1-bfoster@redhat.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 In preparation to support more granular iomap iter advancing, factor the pos/len values as parameters to length calculation. Signed-off-by: Brian Foster Reviewed-by: Christoph Hellwig --- 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); } /**