From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16270C61DD6 for ; Wed, 2 Sep 2026 17:35:04 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hZqcQ3Ndnz2xlv; Thu, 03 Sep 2026 03:35:02 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1788370502; cv=none; b=je7Qit2UhZMjUNXMmPCrkc+y/kjWnypHnxUz4NmsoWM9hjR7Em3GysgahcU1+foB/1IP1S+hgAckCWL4Wx+ATeoI/omWc90rSKPDjS8O7qT8T3PBNjwPBENMl72nWr7kOKjj0UVyiwd+gNaeo0T9nTzVhsHg5gegvsZxjuEIXZXYnlSJKjfFwoaq7QnzBqQsJzZTBiMQkifT2zOiRvIModJopL4gLCbcxCHaVi/lzhDYW3solzwCZsQiwiADDjXqnK7ihjGCYW3Fndhoa82hclrn2URMlYCPJuZCxnNLn8MwWGSMhqeuBo4PrxYbWNU770oimWvLeMMymDMo7FpBBQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1788370502; c=relaxed/relaxed; bh=w6zNKOiuTw5u0HdAYVT065CTtc/jv5Fs9gijIHE4Hmo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=nz5OTcBazgPS5jzeqawsVRK14drDvJNzKMvnmzc23E2LEKMX7l6kHvgU7QLgUmgIcpl/o2XYjnaoEUnRzJopPwGmV9k+W1Xn1VfH6jTpMfV5gLTt3tNsD9fCrj4hnvmOVfsgL8t96d3hob8aINmTmRHs6xmgKbxFyC2GIItK8WyTVFh1/ZiR1IbhhIZ1lyxo4cBon4t7CpOGRc3W5qijy1P5CpRrkt2Gd7lq4JSIOZP1kkSXbZzuoyWtvb+c+dCKZk2ITgL14F4pR2jUXwZ2WrRn7jHZbKK3bi3RTZGLRLTUkPzKEIU8yAUDzKcfEmhWMZMX7fw11iw/YqYvUTRzjQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hQjCOdv5; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hQjCOdv5; dkim-atps=neutral; spf=pass (client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=dhowells@redhat.com; receiver=lists.ozlabs.org) smtp.mailfrom=redhat.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hQjCOdv5; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hQjCOdv5; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=dhowells@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 lists.ozlabs.org (Postfix) with ESMTPS id 4hZqcP2xVmz2xl6 for ; Thu, 03 Sep 2026 03:35:01 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788370497; 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=w6zNKOiuTw5u0HdAYVT065CTtc/jv5Fs9gijIHE4Hmo=; b=hQjCOdv5iE7cKTOS3Ikr/EbiYEZyasTqkzJZNpWJaLxUJaljibQ36D3T8Tzkfz2xabneTz gQAqCAJIjq4D2uKNJlM+r4veuGRuwgr8KGpzXBlINhbkm+AKUXnzlte5LuwBrdDyRN+XZ5 xuqnbAPt52tO70u9E7vc8Pn+5iZmhvw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788370497; 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=w6zNKOiuTw5u0HdAYVT065CTtc/jv5Fs9gijIHE4Hmo=; b=hQjCOdv5iE7cKTOS3Ikr/EbiYEZyasTqkzJZNpWJaLxUJaljibQ36D3T8Tzkfz2xabneTz gQAqCAJIjq4D2uKNJlM+r4veuGRuwgr8KGpzXBlINhbkm+AKUXnzlte5LuwBrdDyRN+XZ5 xuqnbAPt52tO70u9E7vc8Pn+5iZmhvw= Received: from mx-prod-mc-05.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-20-lbm4j_M_MCS_MzX-iVHWDw-1; Wed, 02 Sep 2026 13:34:51 -0400 X-MC-Unique: lbm4j_M_MCS_MzX-iVHWDw-1 X-Mimecast-MFC-AGG-ID: lbm4j_M_MCS_MzX-iVHWDw_1788370488 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 357D61933F85; Wed, 2 Sep 2026 17:34:48 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.158]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 95B2218005BA; Wed, 2 Sep 2026 17:34:41 +0000 (UTC) From: David Howells To: Paulo Alcantara Cc: David Howells , Christian Brauner , Matthew Wilcox , Christoph Hellwig , Jens Axboe , Leon Romanovsky , Namjae Jeon , ChenXiaoSong , Marc Dionne , Stefan Metzmacher , Eric Van Hensbergen , Dominique Martinet , Ilya Dryomov , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH v11 05/36] Add a function to kmap one page of a multipage bio_vec Date: Wed, 2 Sep 2026 18:33:17 +0100 Message-ID: <20260902173350.3468672-6-dhowells@redhat.com> In-Reply-To: <20260902173350.3468672-1-dhowells@redhat.com> References: <20260902173350.3468672-1-dhowells@redhat.com> X-Mailing-List: linux-erofs@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-MFC-PROC-ID: mZeME5M3C-roxxErp0iD2kQkPv6q16KerC_VMD0GTcA_1788370488 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Add a function to kmap one page of a multipage bio_vec by offset (which is added to the offset in the bio_vec internally). The caller is responsible for calculating how much of the page is then available. Signed-off-by: David Howells Acked-by: Paulo Alcantara (Red Hat) cc: Matthew Wilcox cc: Christoph Hellwig cc: Jens Axboe cc: linux-block@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- include/linux/bvec.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index fc566ee1c1ff..df9ce860e787 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -343,4 +343,22 @@ static inline phys_addr_t bvec_phys(const struct bio_vec *bvec) return page_to_phys(bvec->bv_page) + bvec->bv_offset; } +/** + * bvec_kmap_partial - Map part of a bvec into the kernel virtual address space + * @bvec: bvec to map + * @offset: Offset into bvec + * + * Map the page containing the byte at @offset into the kernel virtual address + * space. The caller is responsible for making sure this doesn't overrun. + * + * Call kunmap_local on the returned address to unmap. + */ +static inline void *bvec_kmap_partial(struct bio_vec *bvec, size_t offset) +{ + offset += bvec->bv_offset; + + return kmap_local_page(bvec->bv_page + (offset >> PAGE_SHIFT)) + + (offset & ~PAGE_MASK); +} + #endif /* __LINUX_BVEC_H */