From patchwork Sun Feb 11 12:29:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 199420 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1902813dyd; Sun, 11 Feb 2024 04:34:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEN5Oy2X1iKOr54AsspN8GgmdoEvLrKJ1c9mgbkfW3uDd35rwq7TSJz0sSVvGs+82thwIRE X-Received: by 2002:a05:6358:88e:b0:17a:cd7e:3228 with SMTP id m14-20020a056358088e00b0017acd7e3228mr4875140rwj.4.1707654888760; Sun, 11 Feb 2024 04:34:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707654888; cv=pass; d=google.com; s=arc-20160816; b=Ft6p09wSX725uH/QwKF3WYtah/lGI/mgAKQKQTXEg/7oicQ7IuVDE5UfVNP51E464/ 64RzWdQtkLmyJRKBj9eTiYbyGkwmya74l+EN46Np4CsBCUNku2jV4OxMnPuMrXFLScKt yu72UOor/kx3i3Eer72RnFuJTyGNCIg3H7Ei9fuUZOPftjzTuD8CGi3R8+7tJDnSJ+Dn E41AdtczxasrWYOOPlBEcjYejAAjoBeieHyN95T2R+FPVU1vsJmEvs1OwkMmcsnrPQeF geX/GSsfQS6BpdKhY6gw/n8IT/+6JOZjLbrOB5WCAOhNCyuq9qB7/PGmDbVg8dOwt4ZW vAOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mCAe8mO/KUlyg+BnRuX+JoIprh3UWXF6vcGK++EkmGw=; fh=sjpMrkbfNfEc98hO904TagUQvmTLg+Y9FYtz2JbgsFs=; b=Rfj8rGWJ3+/VweUA4bhGkyc3LReVrzs7ylAGLGoR2rIiSFINiVweA7zCYUa7WafGTH rkihXQRsAVW0/urELA4Ab+UCCwEClVYy7s/gzvZ6Hw3NolV5aQl3vTxenjlX375lht70 ekjv7UZ32AUfRkQxgsUnLgMyR+LUrSRNP0ScNVzQ7k2pUPZViT2FH8HeAjHrMvg+AhpD moRiPlme80dT0AlxTCVIVvCeb+jayfdKMc9Iu+QVlRXvFqj7wtydatcKL5w8chGJtFja 3Bpni22ffBVY/f01Om+cPhbFawnGlPL5x+V95H+2B8fcbsalT8Po7ISZLGbwY4TryHmj A+gg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=GvRlx9M3; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-60741-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60741-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com X-Forwarded-Encrypted: i=2; AJvYcCWHUwO1OL7/TjWpnItg+DKcH7ZpYvKW7zruufaDm4G3om0GRpM/ADR0pIGTSBFmkr4fnczTjixTPxIr2ljQtnu9FM6RXw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k8-20020aa79d08000000b006db9c4a5258si3442618pfp.304.2024.02.11.04.34.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 04:34:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60741-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=GvRlx9M3; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-60741-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60741-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 278F5B23517 for ; Sun, 11 Feb 2024 12:33:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98D505DF18; Sun, 11 Feb 2024 12:30:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="GvRlx9M3" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 424445B1F8 for ; Sun, 11 Feb 2024 12:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707654631; cv=none; b=SDK02wEczilFuGBjDzBwvPZtuS4aIb199OSvngKkDnElT6ROwTdX1cfPWzFe8vvyxzqbbxhy4tIdZqrnERC7iwxuKVEcASCpHrYBngmUIfj87KNE2bH4T5nZR46S55wOkvlfYUViIhrRhPt4auENHRZ21n91V/do/qflS+dx4CU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707654631; c=relaxed/simple; bh=HTmS7KgIHpTSgp6cqH/ynIQyNkUm0EieqPOuHqM5KOY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Fu0lPVGnleqCFJEm3pKckOto4hidHeGPRBNZlt7XwxOl46EeBHrrAiOodPKs4H1dcbiX/gMfIu1DTwdJm2LvFn1bLJG/QXj2KeRA73oO2tgAQbbLYt5Kvgs6TeH3kXN0M1+y01SJ6zcDUrq+dgHgczwSIvGp6s4ggrSQQ5cSH10= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=GvRlx9M3; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5605c7b1f32so3136862a12.0 for ; Sun, 11 Feb 2024 04:30:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1707654626; x=1708259426; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mCAe8mO/KUlyg+BnRuX+JoIprh3UWXF6vcGK++EkmGw=; b=GvRlx9M3CPd3W7hWoZnTTg12P+dCAptA+9LABJV767k09hXL9fLZcBIlnW3C8m8TH7 IgIHSYwi2Aw8E598mA1b2rXI5HYB2JefKrE4YwCCm+tKvTxh5OCGN19amn1KgZJ/Z6m1 3qPxFMHekkfeD8tRcvOtmGY8IlSjmeStY3OCTVfMstnZxGEcqPNpYHTPxDjG+PIjUMzs hM30a3UON5IqDHfddOFTY7MwcmZ8IjD7NxPLK1vBXNymWBEEzwnW2a7krnRQUkK+9jqZ fBFhF7fUAuf1h132rT1syh3uRVwsEWwiqajZR02RG0p3PE68dj0llYjvzvKZ2Id1XBn0 Vd/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707654626; x=1708259426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mCAe8mO/KUlyg+BnRuX+JoIprh3UWXF6vcGK++EkmGw=; b=vkoFajBnZFooXWxJ3hZJogAzRJjsT3KzIFqV4IO2nVv4j9x1CjInryct7RnZbHFrZ6 L9bHj1vOYFmeliCfbEOL+qq4mVgER6qJCz+K21CmlARe5nrI3V3eJU1yQTamsbTld9D6 v50cH7GRSkMGW7uuZx1U0h3oL5kf3QE0nOY8G2SS8Kt5tJO85h0W9bnY/yXuWCjGhGKa yXFuME+j6V7Zeq1r1jV8o/hp70fT4BCZKZXTF6f/W3pTawL2p6g3/fKcFaxEueK17Hd1 gAL//Rg7VxV/pLq29AbGhtvTVxwfrkZE3vPcWVpNbB8djA3AjmsLqLxje+S2w7Veijed dAow== X-Gm-Message-State: AOJu0Yxztw2flL2O9B72TK4kOUQSoYrAzwKxqEpuDyTYxMukSpn0BM3A SzZ6v1sbMsUdoAeuLM+x2i6p8GM0sjGWsAwtj7hPRHMGY/w/VypVnwMe6uzkoBIhAHITTb4paeF v X-Received: by 2002:aa7:c3cd:0:b0:560:d73b:aff4 with SMTP id l13-20020aa7c3cd000000b00560d73baff4mr2473856edr.3.1707654626039; Sun, 11 Feb 2024 04:30:26 -0800 (PST) Received: from raven.intern.cm-ag (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id fj18-20020a0564022b9200b0056187ca4120sm1024611edb.10.2024.02.11.04.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 04:30:25 -0800 (PST) From: Max Kellermann To: linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v3 12/35] bvec.h: move declarations to bvec_types.h Date: Sun, 11 Feb 2024 13:29:37 +0100 Message-Id: <20240211123000.3359365-13-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240211123000.3359365-1-max.kellermann@ionos.com> References: <20240211123000.3359365-1-max.kellermann@ionos.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790605932326466165 X-GMAIL-MSGID: 1790605932326466165 By providing declarations in a lean header, we can reduce header dependencies. Signed-off-by: Max Kellermann --- include/linux/blk_types.h | 2 +- include/linux/bvec.h | 84 +-------------------------------- include/linux/bvec_types.h | 95 ++++++++++++++++++++++++++++++++++++++ include/linux/iov_iter.h | 2 +- include/linux/skbuff.h | 2 +- 5 files changed, 99 insertions(+), 86 deletions(-) create mode 100644 include/linux/bvec_types.h diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 1c07848dea7e..9d2d8a8328a6 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -7,7 +7,7 @@ #define __LINUX_BLK_TYPES_H #include -#include +#include #include #include diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 555aae5448ae..fbb79e6ba953 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -7,6 +7,7 @@ #ifndef __LINUX_BVEC_H #define __LINUX_BVEC_H +#include #include #include #include @@ -14,26 +15,6 @@ #include #include -struct page; - -/** - * struct bio_vec - a contiguous range of physical memory addresses - * @bv_page: First page associated with the address range. - * @bv_len: Number of bytes in the address range. - * @bv_offset: Start of the address range relative to the start of @bv_page. - * - * The following holds for a bvec if n * PAGE_SIZE < bv_offset + bv_len: - * - * nth_page(@bv_page, n) == @bv_page + n - * - * This holds because page_is_mergeable() checks the above property. - */ -struct bio_vec { - struct page *bv_page; - unsigned int bv_len; - unsigned int bv_offset; -}; - /** * bvec_set_page - initialize a bvec based off a struct page * @bv: bvec to initialize @@ -74,69 +55,6 @@ static inline void bvec_set_virt(struct bio_vec *bv, void *vaddr, bvec_set_page(bv, virt_to_page(vaddr), len, offset_in_page(vaddr)); } -struct bvec_iter { - sector_t bi_sector; /* device address in 512 byte - sectors */ - unsigned int bi_size; /* residual I/O count */ - - unsigned int bi_idx; /* current index into bvl_vec */ - - unsigned int bi_bvec_done; /* number of bytes completed in - current bvec */ -} __packed; - -struct bvec_iter_all { - struct bio_vec bv; - int idx; - unsigned done; -}; - -/* - * various member access, note that bio_data should of course not be used - * on highmem page vectors - */ -#define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx]) - -/* multi-page (mp_bvec) helpers */ -#define mp_bvec_iter_page(bvec, iter) \ - (__bvec_iter_bvec((bvec), (iter))->bv_page) - -#define mp_bvec_iter_len(bvec, iter) \ - min((iter).bi_size, \ - __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done) - -#define mp_bvec_iter_offset(bvec, iter) \ - (__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done) - -#define mp_bvec_iter_page_idx(bvec, iter) \ - (mp_bvec_iter_offset((bvec), (iter)) / PAGE_SIZE) - -#define mp_bvec_iter_bvec(bvec, iter) \ -((struct bio_vec) { \ - .bv_page = mp_bvec_iter_page((bvec), (iter)), \ - .bv_len = mp_bvec_iter_len((bvec), (iter)), \ - .bv_offset = mp_bvec_iter_offset((bvec), (iter)), \ -}) - -/* For building single-page bvec in flight */ - #define bvec_iter_offset(bvec, iter) \ - (mp_bvec_iter_offset((bvec), (iter)) % PAGE_SIZE) - -#define bvec_iter_len(bvec, iter) \ - min_t(unsigned, mp_bvec_iter_len((bvec), (iter)), \ - PAGE_SIZE - bvec_iter_offset((bvec), (iter))) - -#define bvec_iter_page(bvec, iter) \ - (mp_bvec_iter_page((bvec), (iter)) + \ - mp_bvec_iter_page_idx((bvec), (iter))) - -#define bvec_iter_bvec(bvec, iter) \ -((struct bio_vec) { \ - .bv_page = bvec_iter_page((bvec), (iter)), \ - .bv_len = bvec_iter_len((bvec), (iter)), \ - .bv_offset = bvec_iter_offset((bvec), (iter)), \ -}) - static inline bool bvec_iter_advance(const struct bio_vec *bv, struct bvec_iter *iter, unsigned bytes) { diff --git a/include/linux/bvec_types.h b/include/linux/bvec_types.h new file mode 100644 index 000000000000..23453c988154 --- /dev/null +++ b/include/linux/bvec_types.h @@ -0,0 +1,95 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * bvec iterator + * + * Copyright (C) 2001 Ming Lei + */ +#ifndef __LINUX_BVEC_TYPES_H +#define __LINUX_BVEC_TYPES_H + +#include + +struct page; + +/** + * struct bio_vec - a contiguous range of physical memory addresses + * @bv_page: First page associated with the address range. + * @bv_len: Number of bytes in the address range. + * @bv_offset: Start of the address range relative to the start of @bv_page. + * + * The following holds for a bvec if n * PAGE_SIZE < bv_offset + bv_len: + * + * nth_page(@bv_page, n) == @bv_page + n + * + * This holds because page_is_mergeable() checks the above property. + */ +struct bio_vec { + struct page *bv_page; + unsigned int bv_len; + unsigned int bv_offset; +}; + +struct bvec_iter { + sector_t bi_sector; /* device address in 512 byte + sectors */ + unsigned int bi_size; /* residual I/O count */ + + unsigned int bi_idx; /* current index into bvl_vec */ + + unsigned int bi_bvec_done; /* number of bytes completed in + current bvec */ +} __packed; + +struct bvec_iter_all { + struct bio_vec bv; + int idx; + unsigned done; +}; + +/* + * various member access, note that bio_data should of course not be used + * on highmem page vectors + */ +#define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx]) + +/* multi-page (mp_bvec) helpers */ +#define mp_bvec_iter_page(bvec, iter) \ + (__bvec_iter_bvec((bvec), (iter))->bv_page) + +#define mp_bvec_iter_len(bvec, iter) \ + min((iter).bi_size, \ + __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done) + +#define mp_bvec_iter_offset(bvec, iter) \ + (__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done) + +#define mp_bvec_iter_page_idx(bvec, iter) \ + (mp_bvec_iter_offset((bvec), (iter)) / PAGE_SIZE) + +#define mp_bvec_iter_bvec(bvec, iter) \ +((struct bio_vec) { \ + .bv_page = mp_bvec_iter_page((bvec), (iter)), \ + .bv_len = mp_bvec_iter_len((bvec), (iter)), \ + .bv_offset = mp_bvec_iter_offset((bvec), (iter)), \ +}) + +/* For building single-page bvec in flight */ + #define bvec_iter_offset(bvec, iter) \ + (mp_bvec_iter_offset((bvec), (iter)) % PAGE_SIZE) + +#define bvec_iter_len(bvec, iter) \ + min_t(unsigned, mp_bvec_iter_len((bvec), (iter)), \ + PAGE_SIZE - bvec_iter_offset((bvec), (iter))) + +#define bvec_iter_page(bvec, iter) \ + (mp_bvec_iter_page((bvec), (iter)) + \ + mp_bvec_iter_page_idx((bvec), (iter))) + +#define bvec_iter_bvec(bvec, iter) \ +((struct bio_vec) { \ + .bv_page = bvec_iter_page((bvec), (iter)), \ + .bv_len = bvec_iter_len((bvec), (iter)), \ + .bv_offset = bvec_iter_offset((bvec), (iter)), \ +}) + +#endif /* __LINUX_BVEC_TYPES_H */ diff --git a/include/linux/iov_iter.h b/include/linux/iov_iter.h index c3adba9ff389..060626682481 100644 --- a/include/linux/iov_iter.h +++ b/include/linux/iov_iter.h @@ -9,7 +9,7 @@ #define _LINUX_IOV_ITER_H #include -#include +#include #include // for kmap_local_page() typedef size_t (*iov_step_f)(void *iter_base, size_t progress, size_t len, diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 2dde34c29203..8ee67e49699b 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include