From patchwork Mon Feb 12 11:54: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: 199677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2378248dyd; Mon, 12 Feb 2024 03:58:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUQxaS5QHkM06nBEnY+NuPl/4/5nS24i+4/n8sZkIpYE3ki/TZGAcZCRPfi4tRnhS7XdwfHqUi/ojVVoB2JvsainRHXWg== X-Google-Smtp-Source: AGHT+IGnD2xIG6WDcj1/Olu99cL/tZssSNuLaXOa59NTpPIIhZxeQMJ3QBXx0jkbw1t8JIEDLFdb X-Received: by 2002:a05:6a00:90a8:b0:6e0:e5bf:8387 with SMTP id jo40-20020a056a0090a800b006e0e5bf8387mr1448774pfb.25.1707739134210; Mon, 12 Feb 2024 03:58:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707739134; cv=pass; d=google.com; s=arc-20160816; b=ktfWoCSkjgmd5wsbp0N+wJXfPtJxvy46RrvzUQ07Oaq1CvB2zqyOPms3L7vX+UYHQm nRCdM3LvDiQySxqWPkzPBPUb2TcxMwK75fbWX5YfVABXK5GKS37GFmP9OtTQTFEnjBu3 EUkn8/ugjv5CL2cwO0paVO3MtRoCHCUWSY3B4ly6ckhIngBzfOSWOzTPJ1KjsteLLWbO 0TIWVplMe6FN5Bp6DDQUQiLBPW4ORLkXfdCJW2wj1vck5t1cyJWPUal0IXu6+gOWtRIW wJyOBwBGb39gnV3t9X14KDXj0xPhUgiAxpRJUdNBsiRH47xSJs4JzTzv7mwrAUs05gU1 yW7g== 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=JV2AGaWWJut6fH2KSy2Vw2i2V/KY4FFinPxihBhkheo=; b=ShsbA4TiQUsIejvBK3Depq/3nZa3gry4Bc71qmF6HawGOrYKnMDp65KOt+uYbBOhoO YPwNtnuQpMCBeInq8Gkd3HTwMUSMZSHQQDUFeINC4LJnquOeOTipzf2Jars99to49lQd eJONXazfya/Od+J3R0gIsfi1DwR+/qEluBqE4rqGVJ/+Z0vuQhGwfRQDI4ZVSlWX9ry4 Ig+aYivbK3frIcB/mE/g7fEmGNLeLV01VcBC3ChZpZAXP/BFZqbSS3Jc3C5oB+8F2yQK rVDUFeXNtP9ir0CIrIYvhqDKaat8EKqTQ6wFCv85yWXDVJb2e0HKfhMaABjss/E3s/MN /XrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=FtzoP6uu; 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-61473-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61473-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com X-Forwarded-Encrypted: i=2; AJvYcCVAslcD0wXuPZ+vrjgHPbVfLXyOECZsj5jrXKFkrJKemsh5iO9i/dmZlIeAhPrMickAfaI/AFSSuABVmNsz4GIz7iwt6A== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y1-20020a62b501000000b006e08faf4d9dsi4833160pfe.360.2024.02.12.03.58.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 03:58:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61473-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=FtzoP6uu; 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-61473-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61473-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EB1CB283E05 for ; Mon, 12 Feb 2024 11:58:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FDFA3C6A4; Mon, 12 Feb 2024 11:55:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="FtzoP6uu" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 030B739AC9 for ; Mon, 12 Feb 2024 11:55:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707738929; cv=none; b=hJJwHrNYhKqYiL8LGOvPANUyE5cEXenQPt9G07D4HUFjNQMqBZxVO7pAxAFhNiLpKnxtXGduTkLk6UEvY/umkfp6b9EgAd2l2xQA9Rozb24N2mF9IHCNduiroNIGz06ce6pQ9e4k5GqEb/Fsyo+6ryFXmYFZWPGxWZ8Ao/xFXhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707738929; c=relaxed/simple; bh=HTmS7KgIHpTSgp6cqH/ynIQyNkUm0EieqPOuHqM5KOY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O1czKxAtO6dqr+TXYF2JVrt3SgOxc2Ot4Eqg2kw6iuhoMXj7nn4yqoHAM00Pbg1CuH72ZuVU7vt4gkmsp+NQsi8oCthje/y6lCU7Iv/FmUuKRmBCsCXig+qr0ywZm1WB3RSAsqL1ntsepumbbvLC/rdNybybE2/k1sPTthAocm8= 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=FtzoP6uu; arc=none smtp.client-ip=209.85.218.48 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-ej1-f48.google.com with SMTP id a640c23a62f3a-a30f7c9574eso361733466b.0 for ; Mon, 12 Feb 2024 03:55:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1707738925; x=1708343725; 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=FtzoP6uuzZxgJVOV82ndafgsvNCeE8feMZmNCuNkR0kenbQ0mgfzU050l38YuOllLD 6mOBSJoZOXOYsZ8KehoaT89Qt1U24EEEKidC2vUIncVIDRsHqtely8ZBFz47obUUGTq2 NlJh73nHZ9A0nAL0GzkkbR2TrLRQ0qhv/NCLv9kUYnBhfXfUpdHXvCTyss33iHg7OxzC 6Y3iNNDsLLLJayiXda8o87ADPiHqxkCH1xfi/hL8xvtLty8yMki4HNCr0DjNbvioPNQw j/0iWbUGwfdCmkWC7eigjYDinpi2F1uvATWXcPjbyWvBIIAHr3lxbRdzAp7+414DcCwP Lzow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707738925; x=1708343725; 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=OgLXo96dw8RC48quawuHvfKcAo8GM9Wu6bxD3t4zb75U573sEYLFKEv83RvQkbg797 bOGUNrtkL4zAAOiKxU7LOFe/PqIu7Yqkc6T0ValeRXtDl/sfV2TRPbaVhuoPueOCBfLG uMmrTbRLLr+IR6VZV8/EjHPrryzHK/NMa2v4FEfjt4X/MFbsZjW3rzNxDo6TimGWEqCi hyCSXl3ptNry3WjSWB6cXQK4d5+spmBpz2RbucAZNnU+rJNInUZmf3nFo6FZh0cGFC5c VOfmmR8A7FR1DkngTnp2CgrJcqup1Frm46gngxKcxh55MSWspDNjCocjzESL9iEEJIJ4 zSbQ== X-Gm-Message-State: AOJu0Yy98Lv4UsjsyqBz2ze/uJEH42DwoWjOqWu2jpN6aN0G5foTcbCs AJrMrokPjqHbYZ3d1sHGXTM+1rMkqDEBiXgLTBu9T6yPny2lYWKG5OMxU7G9xuX0uHyM75ueNml U X-Received: by 2002:a17:906:ece8:b0:a38:1673:682a with SMTP id qt8-20020a170906ece800b00a381673682amr4804067ejb.32.1707738924971; Mon, 12 Feb 2024 03:55:24 -0800 (PST) Received: from raven.blarg.de (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id m1-20020a17090607c100b00a36c3e2e52dsm139203ejc.61.2024.02.12.03.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 03:55:24 -0800 (PST) From: Max Kellermann To: linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH v5 12/35] bvec.h: move declarations to bvec_types.h Date: Mon, 12 Feb 2024 12:54:37 +0100 Message-Id: <20240212115500.2078463-13-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212115500.2078463-1-max.kellermann@ionos.com> References: <20240212115500.2078463-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: 1790694270334274706 X-GMAIL-MSGID: 1790694270334274706 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