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 8767ACD8C92 for ; Mon, 8 Jun 2026 14:58:55 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4gYw8P6xDwz3bsq; Tue, 09 Jun 2026 00:55:49 +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=1780930549; cv=none; b=L4TGdaSXOFZu7DkKI8Pm/zYaxvv60QdaRVXUDgj114OePzRQACQOyQE7QIMxt3EFhgye6tDw1sThMLnVkGzegRQLtRzxiC0AlObtIfmx14LhzfkZn5UaKmV3TahrCrpxNUEvL9/APTYIL3Bk9XptI0MgW5MKZVBKSzI12tcYjDW87F36UP09PEjJrYMrzr2n/rU8gYAGAJPu9cHJl7ow01/3LE5FmRXkWMmjAVlq4ERbAzmGMNKqI74DHxuOjDv2XG22f6T3998RauZBzi6Qo/VvEHrxUpUFRPpJ0BkcyR+dVkTR7jukPkhRhz6UVOkj8DWSDWJi7FAnINxJLmczHw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1780930549; c=relaxed/relaxed; bh=+7WyxlyafAfljSXx2zE5evSFbmc9/FNDO8/ZJyEWYy0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=QLR1XGTbLaBPYOY+9kzwX2Tg1yirhOcEPl1ZBIRxK/XakUq0H+ZogQe8PY+criiaME3sA6+r7ujabPsgykXXhQr+IzT5jZTHDgaRbf7O72XYzNCcjOdqZT5eV+GQZXPZjmyk73egALMoQsn4sVkO9Z4q5lklNcONGyqhSxGYXZ9H7eBYSxjYetfywnZIJdkt1uY1fa2If2+bfSRC0+C5KB2y4tP9O/XhedD2jyZcbJBpkhDcOZyhyUzTQKRZcu5eIcUhbNHTLZ8ZqmxTdsppa+mIr2UUbaM1VajM6C1aRtVO8cLaUU5m0roZRMo7tUoL7pe1bwY79nTtBZoDLJCRlw== 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=XPfvBR5w; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cAl14Pdw; 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=XPfvBR5w; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cAl14Pdw; 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 4gYw8P05lhz30FP for ; Tue, 09 Jun 2026 00:55:48 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780930545; 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=+7WyxlyafAfljSXx2zE5evSFbmc9/FNDO8/ZJyEWYy0=; b=XPfvBR5wzoj31Q9dqDX3XwaIXV0OWbndXO1wTsCX47TKwzun6d7sERKYR7bpLZ7O0gE40U rbgwdPRo4215qBpuuNoYzOEhqlorRtJQmJk3WWJJVrMLFHurVrRaMj1cvfNQJcgT+kTAQn eYYVNlnhN88sZB1LWeKltUYZmRVoGZQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780930546; 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=+7WyxlyafAfljSXx2zE5evSFbmc9/FNDO8/ZJyEWYy0=; b=cAl14PdwpIkGlKBW3TNjUOdf3aDft24HSLckslL2T+qlZl8ZtcaLBK8PMRP/dT16gpnP8G /UfqkgDWnu/OzU60krjHadcViELXQAWHdYT0q6GeOFV0608m9azofGBOANcOF11/tvb0Y1 lqz/cOP7V0qixqzy/7pIajDh0f+hHu0= Received: from mx-prod-mc-01.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-664-7hFZL4NDMYK6OKyZssoBEw-1; Mon, 08 Jun 2026 10:55:42 -0400 X-MC-Unique: 7hFZL4NDMYK6OKyZssoBEw-1 X-Mimecast-MFC-AGG-ID: 7hFZL4NDMYK6OKyZssoBEw_1780930539 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C1AB11956058; Mon, 8 Jun 2026 14:55:39 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.32.43]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4E2241955BC0; Mon, 8 Jun 2026 14:55:33 +0000 (UTC) From: David Howells To: Christian Brauner , Matthew Wilcox , Christoph Hellwig Cc: David Howells , Paulo Alcantara , Jens Axboe , Leon Romanovsky , Steve French , ChenXiaoSong , Marc Dionne , Eric Van Hensbergen , Dominique Martinet , Ilya Dryomov , Trond Myklebust , 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 v3 06/22] Add a function to kmap one page of a multipage bio_vec Date: Mon, 8 Jun 2026 15:54:14 +0100 Message-ID: <20260608145432.681865-7-dhowells@redhat.com> In-Reply-To: <20260608145432.681865-1-dhowells@redhat.com> References: <20260608145432.681865-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.0 on 10.30.177.12 X-Mimecast-MFC-PROC-ID: OCH45mph6vRFEZaNTR5Tuw6y6INgPcMCyk-u3hyQ3Og_1780930539 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 d36dd476feda..f834a862224e 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -299,4 +299,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 */