From mboxrd@z Thu Jan 1 00:00:00 1970 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 C6510511209 for ; Tue, 29 Sep 2026 10:34:46 +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=1790678099; cv=none; b=tVxa9ovGBRj1rrwls2taH38x3TUGOGbLcB1V8lTYLM4DS9AqXGLqKF4svIbdKUvW3GSbGUWiPuPftBU0wVSbULwpVjfwRDu7Adba8gj5/kyWwT4gFEPmvf7PTMnbUpfpkb+zV1hJryDZlTdAXbbyGSb2g7WSmUSUR6lD8awWzGw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790678099; c=relaxed/simple; bh=FFbefN2Y4qRJn5vswr2Uy9xuWqjQECbgHAQFP+xEhfc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b8BynD1ubXQ5cWDs4P0Xi0d5F9uyu1ogDTMhBLTSjFgSoJ9/6Zhz9dAkw38RWgfMZm1N/Xa76DpWQDXf7RUHqTCFgsWmLMpLyTFeQHIpIg7py/rIxq6+Y6YxKgef46Ds/rmykTcvFkhfYuvVY8scb7dryUS333PtoZL2K3P2b8s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=c+KGQwhx; arc=none smtp.client-ip=170.10.129.124 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.b="c+KGQwhx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790678081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TrGq5iY6/w2n25N0igq41iNBSv1Z7z5H/VJULRFdP7Y=; b=c+KGQwhxE2NKvkzLvynOaoXFlo+Iim/TirpGWzzJKUWaQt4HfvQFbZJz4K2Yj3j0FarKwr woBCi0S7iXtC1UF0MspjjJZsmd5DhFuEz7kNSyidb8e767HlIBjWlWjEMyb9tRrOXCtVRB F6f8x2tFM+d9dqdv0uyk79FhtEzWD+Q= 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-657-9R9gw07tNe6RkVuJNB01oA-1; Tue, 29 Sep 2026 06:34:35 -0400 X-MC-Unique: 9R9gw07tNe6RkVuJNB01oA-1 X-Mimecast-MFC-AGG-ID: 9R9gw07tNe6RkVuJNB01oA_1790678073 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 580CD1954225; Tue, 29 Sep 2026 10:34:32 +0000 (UTC) Received: from warthog.com (unknown [10.44.32.54]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0029D1956087; Tue, 29 Sep 2026 10:34:24 +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 v13 01/10] Add a function to kmap one page of a multipage bio_vec Date: Tue, 29 Sep 2026 11:34:01 +0100 Message-ID: <20260929103412.2807494-2-dhowells@redhat.com> In-Reply-To: <20260929103412.2807494-1-dhowells@redhat.com> References: <20260929103412.2807494-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 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 */