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 875E1C5AE49 for ; Mon, 10 Aug 2026 14:49:03 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4hJd1T50wKz300M; Tue, 11 Aug 2026 00:49:01 +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=1786373341; cv=none; b=K5nJlRIT7CQouNJPR1MGVmUo2fLJRDUeAVcwnv0jh4vGD3iNEvJ9NtzTk3vl1HusJR256uJl5gwOEok0rsitvwtzC73GkmbiCcgqu0az4quxJUWcHqxXuKHHEAF4kLC/szRgj2gsfBjh2c3spOhihmSaEfRXy3bx9086fYKyTESfn4Iv4L8oh0SrBYQEJnT6NNa4UvV8hhWaYp1cRH6sLmqsyH5vZLUxFDNb9inSgL2Wk0cR8XxQNofONTg6xXpGXfgKnyXwgyj/foNjmVC8S7FMNucZaqMO83yWdOvvoFh3ZNyJc1FVVcLu34QFo2b5eFht2T/H4e9OFAbfYFxS1w== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1786373341; c=relaxed/relaxed; bh=forfFVNHXdcKUrAO6tYWFvQxC3xkWQUr9XOJVlaCNVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=IxDvfamD0EGkSKs8DWbLaFfGC2O8fc9A4n2MVmgawUh5ODxyAycvBGaomWHC3pUUJKU+lxq+gi6/YTeqmeC6lduPeWbUriObLQnrzNY5KiW6nvJn1a8csU4p6MYZghfNuBZpi1PzEBWAsWF3e3PRW/QA3d64S0EGfHNFEYEQzAIKM/lfN8LqQoiScoy5JJNkmkBTM8SRaKioFvf2ovwvYOXhin0Ry9yYfbqO6EuDBS1+oJTGgnlD5VxW69DY6/qQfRB5skimrjDZfm8Jv5t5YNf9UQtwCLEkEuoDxQ9Y6dmMn213qE/g6Ho/AEa1p2InFOJQmp4PMdQ5mQF4NS/cRQ== 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=QPSPIFj7; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IO6mZmUX; 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=QPSPIFj7; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IO6mZmUX; 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 4hJd1S4KYdz2ytv for ; Tue, 11 Aug 2026 00:49:00 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786373336; 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=forfFVNHXdcKUrAO6tYWFvQxC3xkWQUr9XOJVlaCNVg=; b=QPSPIFj7iAvn/2eNN9I5SG9HsE/9JRjcAHnnpF/tA+dxlEf04zvFQpnEwRQRIX9GQJHFsY 02tQljNdud3M7Rt5SmBIbc10wtEjhgNsZDRUhHu1q8cHKcG7mNGVsAx38Bnm7DmeY86+tE a3VYdTQoUkk4UUIlQYlyaZmRMkwkOEA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1786373337; 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=forfFVNHXdcKUrAO6tYWFvQxC3xkWQUr9XOJVlaCNVg=; b=IO6mZmUXvHPx0BB4b15goRxTEco2rbyg24R+tyjkv0hR9rZckXj6gtg6buu1uDOidc/JPn dC7R1W2Siw3MWBLJ24JXGHW1M1CCJqWL55rKTHjc28UesS7jRDOH08qzVWN+dh/xXh9ZGw pIpmG18iCu347bxFEeQBQoH0GvCewWQ= Received: from mx-prod-mc-08.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-30-kLO0B6PJPjG9rhvMsny_bA-1; Mon, 10 Aug 2026 10:48:39 -0400 X-MC-Unique: kLO0B6PJPjG9rhvMsny_bA-1 X-Mimecast-MFC-AGG-ID: kLO0B6PJPjG9rhvMsny_bA_1786373317 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C35111800471; Mon, 10 Aug 2026 14:48:36 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.44.32.44]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F3A1E426; Mon, 10 Aug 2026 14:48:29 +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 , 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 v9 04/26] Add a function to kmap one page of a multipage bio_vec Date: Mon, 10 Aug 2026 15:47:21 +0100 Message-ID: <20260810144746.574036-5-dhowells@redhat.com> In-Reply-To: <20260810144746.574036-1-dhowells@redhat.com> References: <20260810144746.574036-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.6 on 10.30.177.95 X-Mimecast-MFC-PROC-ID: 3ZNughL58Kz13I-f_y9gMEL1sR4PZ-GgXJbMgjP_HmM_1786373317 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 92837e2743f1..53cf36e73967 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 */