From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795077560; b=SFwoEhovr5PXAiX8BgzJPsXhnjLo35uZjgW/cJ01VGO0lgnThdRQCq1HlIlZkY19R0D3 NeMEpqPekaFqmp/Khw9oFj16FIKtcZnfpJJN1WlhyvFbBYCg7IB8I4yE9KODgDjAaZhi1 BTW+4HCaUwV+9GyAx8bQ5PqRExoNzbm+DS1YEqrq1jba3uJOeTq/A28ww7ZWEeusphQ3R v1joM1PL6gIBhI73uYKgTsucrX1zBneg2YNdUZrsUDR+BZCJ1lhwUGmw+OzlFl/7XgmYb 0eyFaZsyICgFX304YT+OnP5ID/8AU79OH6yQbUPMrwwpls7j7C1tYIyvB/cvtZvSCBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795077560; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version:X-Scanned-By: X-Mimecast-MFC-PROC-ID:X-Mimecast-Originator: Content-Transfer-Encoding:content-type; bh=PhNajVV4YOAVa6HzjBax5Vzcm0CeXg6v0Uflf51EUrc=; b=FDdDPoTLVcjhvA91SPS8MtxiXpxqZ7vzGYIhoz96fKM/vQVFwDrheot8HtqodIk4YDiL LgOpgo8t5c7SLAJv42+NOWzcG2f3+aeAGoGCgVN6CrLvOqOG+W+GDGCTV4/rtUVxjQSv8 /ZJ7+fu4R87nEz7b6f7HmwhBF+jFpF3b6Sz1igMdhmqKSrK58dLVNY/qS8/pWgI7V8UZi kexMxAXPPvTPf8Zht5p4CLrrkkghaw24dQUzN2jr3o8loZu/CCUlr3uvEy9IukQQf4ydd C59JYMdS5qIU1FRVAJpK0u883VuDok25O6Lepc1oBNwuGQzNVxLVPsoYE215jx+wvGA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=J9Fea37v; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5DA7606A324 for ; Thu, 19 Nov 2026 08:39:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C5DA7606A324 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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.a=rsa-sha256 header.s=mimecast20190719 header.b=J9Fea37v DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795077558; 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=PhNajVV4YOAVa6HzjBax5Vzcm0CeXg6v0Uflf51EUrc=; b=J9Fea37v+qtck1pgEhK/q0T6OxmxZaRK1kQB8ISuNcQ/XuRy+stvRCl86pbLuV++4LK/aa 5IbJ3M2ppxRoTBsMla7FG4Bb92AJ0wFqjxCgqnMB3Vu1K4rVQ0hWUmDODYxqkRFvYp7aoj 5nGmxo9hixXcaZWW8I/wQ64EBMeETLk= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-J86VbOqoNfq-SFhEQJNgdA-1; Thu, 19 Nov 2026 03:39:15 -0500 X-MC-Unique: J86VbOqoNfq-SFhEQJNgdA-1 X-Mimecast-MFC-AGG-ID: J86VbOqoNfq-SFhEQJNgdA_1795077553 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DD92518004FE; Thu, 19 Nov 2026 08:39:11 +0000 (UTC) Received: from dhowells-thinkpadp1gen8.rmtgb.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E23171956088; Thu, 19 Nov 2026 08:39:06 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Paulo Alcantara , Matthew Wilcox , Namjae Jeon , 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-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jens Axboe , Christoph Hellwig , linux-block@vger.kernel.org Subject: [PATCH v19 02/17] block: Add a function to kmap one page of a multipage bio_vec Date: Thu, 19 Nov 2026 08:38:33 +0000 Message-ID: <20261119083851.3306418-3-dhowells@redhat.com> In-Reply-To: <20261119083851.3306418-1-dhowells@redhat.com> References: <20261119083851.3306418-1-dhowells@redhat.com> X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-MFC-PROC-ID: DxXec_RK-47e64bFCL3Ieu1fzjdHno250KPzWwdWHyk_1795077553 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 Reviewed-by: Paulo Alcantara (Red Hat) cc: Matthew Wilcox cc: Jens Axboe cc: Christoph Hellwig 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 b63914ff56e3..7ea62643cfb7 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -344,4 +344,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(const 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 */