From patchwork Wed Jan 31 14:49:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 194809 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1959154dyb; Wed, 31 Jan 2024 07:18:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/SfK6S/WtnkEngqb0OKrF2Teh7g6V4DLMU0K+ESli/bogpm4wBbQP23D0+IgHi3uriVmz X-Received: by 2002:a05:6870:47a6:b0:218:53ba:a941 with SMTP id c38-20020a05687047a600b0021853baa941mr2187432oaq.47.1706714310958; Wed, 31 Jan 2024 07:18:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706714310; cv=pass; d=google.com; s=arc-20160816; b=yIg4bC1IO4nPtZTrSkj6F7g9+AfJ9cUVQA32Z1KyAXvlGxmr2Ofl8gauq//xWuAJ9p WwajjLd6BBuc33SltRTYi7AmSCt2h/pJBmRTvEH4nTBQx32EMvmYh0N4jhBbXS/yC35d h1Vb8DRsnLsqo8GFjy1DvuwYPDXNvFpESlqOfsX8QeOqD5DZI4rBO4hBY3Y7c/nIvVNQ 2P3WSx7mMsDzQUNlB8hmuCiG3UXJXc8bOgZEAe7zGAFsN+LPAb+mGzHt2mqyM36OLict u0cBK4NPs0jA7w7eHcNs3kbrFiqkwUFjtC20R8Ek5VQLmIk3Z53ah5mEauVcQvWOHYz5 KC5w== 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=ixJxOzrAktkBTAcc5ADo7AICuAwWjUqvYJlGkoY3KJA=; fh=co4Fe1QEpJeNE9Wx6cJ4VgZiYSCLyqWranOJ7GkmjcI=; b=LONYlERTBObWJRXfwF88CKYH9W5FdvidoRgNXFmmjhiUidWFBHq1dgDF4itzrr1Uku 3RHTpDtGX2ys84mgjvkQr2y05Aqxwc4r4UvgMU/7kk0JpUheGBEgu+wyXoesr43UimMK BDdCXuda4Mt5S33DZydmfAsE+JpxIdo+5pDL7eeAK5E571ukcXf7wutNKr8U2WQ4bL83 h//ZmUZIVLylxVyMKuQYZkJBbDU8ZmpMk1//PgyuGw2lMnv1TpRkTcNBv+5xkholMKIR GH3YZyB8mH6CZrjDslqSXMIt0nXud0C5e8uOzykNsHdPjMDCJSJFumNnQcBrJ5BROJx3 NGlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=fjWgfBdD; 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-46645-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46645-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com X-Forwarded-Encrypted: i=1; AJvYcCVk6F6yziNSdKCvwcSfbANuJiDP+MFFz0KDVGL7IzT7sCOeAVNYYAYwmoQLUaqpI4lCh8+js5P9BJ7iFI2c0dZvpLxsHQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b16-20020a656690000000b005d553239b15si10055846pgw.493.2024.01.31.07.18.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 07:18:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46645-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=fjWgfBdD; 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-46645-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46645-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 27EB4292E2A for ; Wed, 31 Jan 2024 14:54:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B75FB12FF8F; Wed, 31 Jan 2024 14:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="fjWgfBdD" Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 EE06C12BF13 for ; Wed, 31 Jan 2024 14:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706712631; cv=none; b=qnhyX9s3I0mWX1iT8AoFzIHrKZ/8Be5e3ofd0Mib74xEX7r9kvLfW+NuB/YIFFKghZ0lYSTc6g87WIiyPIkrDAp453GXeest7BAwd7ekGJHb1VmTlnanHcQ/zmtxo+oXoXVC6OEbQcLVh3Amyb6lyPmY/qD7LMyrMvDQbX3Bhos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706712631; c=relaxed/simple; bh=nr5Z35SJ6TsMVseA4udiDyZYQLbt12PZ6Zg2bhnq3RI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S2q4uzMqAEFqk+4QkMuIqeDoo4xIU7l0nXyxD4f2iLzyoxhIcfoxlJGbXUafyNOve4JrG1eAMDmdcFbc30vvddZUNj5s6tmu9N2smkyKNB2AkOU71EOQJ9H3pUwxo20xq1n6UozhyVj47csFNFVCMDyIVCicCytnw7b6KLCV2es= 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=fjWgfBdD; arc=none smtp.client-ip=209.85.128.47 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-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40f033c2e30so15543745e9.0 for ; Wed, 31 Jan 2024 06:50:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1706712626; x=1707317426; 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=ixJxOzrAktkBTAcc5ADo7AICuAwWjUqvYJlGkoY3KJA=; b=fjWgfBdDcdVXYC4iF1jz7hY1/IwQhD2Vfq73aTD0x2dScHvtHmBrQDAFDuUmYMLZK1 liInBl+F9BZBBgHq1ND8GvLL4QAVD4hBH5kTM36vKcGriBsmJiUmW/600FxiNH1ijG5g B7ABaPQb5iv8H+4ergxPsPkMhSbF2l850J23OeGTmXOEzWkurHmeWBkloOi+zIhY61vF 0ndOYqUoh4Dmb843iyYSIFnv0tHQrpc2IaHa0skdjGceygXHKPsc/CVxDfQylhRL/W6y j0L9bE5zUBFrRwCarTsS6t/UXmcnC5o5D0oh1ITY3ql8Dqpa4aoyJI+BNr+YObv/rTnm yGPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706712626; x=1707317426; 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=ixJxOzrAktkBTAcc5ADo7AICuAwWjUqvYJlGkoY3KJA=; b=vU5gbma8urPwVWWOgrjzxVVgNjgaAHsuqRBX7c0YAypBB1qYwmBuNLNyycqsL+dpjs H1FoVJ8+1fSZCOzFQcFkD/bYUQdkxM2ree00L3oTmUHAKZmZjJmOamjcthGlqU2oznjM UkJ8uO3ARcIatreDltj0RNVjvhLMzZ2RweYElagVhMDP0hc5B5pK+4Rx6hJvoSwjqKKi Odq5ljO9NikdoHZIxCMhHEocrIRbA+Bt+QM01K5KzXbIsLSYfMnbaDUlfIJAbaoOdDcd tzN3nMEofYMD3mmkf6+ZwTnER8vO2qAyU225TfSHZevRKHANM7qTBorKIszwjjI79iKt 7QPA== X-Gm-Message-State: AOJu0Yz2xGDudbPAVJsWT/4KJ7koWZBwVCGNnZGZQkZDIN/eRuV4UPPC u/EUQT9lzAgS7lWxIv+x3zPp1gbuSiX7Msf4b6eQ0/DpDOgnxFJloVg7ReTVxcf5ZN1AgsPjynz T X-Received: by 2002:a05:600c:354f:b0:40f:b376:6021 with SMTP id i15-20020a05600c354f00b0040fb3766021mr1373319wmq.3.1706712626000; Wed, 31 Jan 2024 06:50:26 -0800 (PST) Received: from raven.blarg.de (p200300dc6f2f5c00023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f2f:5c00:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id ch15-20020a5d5d0f000000b0033905a60689sm13850173wrb.45.2024.01.31.06.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 06:50:24 -0800 (PST) From: Max Kellermann To: linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH 12/28] bvec.h: move declarations to bvec_types.h Date: Wed, 31 Jan 2024 15:49:52 +0100 Message-Id: <20240131145008.1345531-13-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240131145008.1345531-1-max.kellermann@ionos.com> References: <20240131145008.1345531-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: 1789619665443872995 X-GMAIL-MSGID: 1789619665443872995 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 270454a6703d..6e0749779ca5 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 typedef size_t (*iov_step_f)(void *iter_base, size_t progress, size_t len, void *priv, void *priv2); 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