From patchwork Mon Jan 30 09:21:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13120630 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA287C6379F for ; Mon, 30 Jan 2023 09:24:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA0906B0074; Mon, 30 Jan 2023 04:24:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A55686B0078; Mon, 30 Jan 2023 04:24:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87C236B0075; Mon, 30 Jan 2023 04:24:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 72B2D6B0074 for ; Mon, 30 Jan 2023 04:24:00 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 31905AAA0A for ; Mon, 30 Jan 2023 09:24:00 +0000 (UTC) X-FDA: 80410928640.27.ECDC658 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf02.hostedemail.com (Postfix) with ESMTP id 78A3480002 for ; Mon, 30 Jan 2023 09:23:52 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dhP5pRXP; spf=none (imf02.hostedemail.com: domain of BATV+3ca177389f0c7d0d5156+7099+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+3ca177389f0c7d0d5156+7099+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675070634; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=w4kKntDuy29BQaIkx4v+gO5Mr7Op4d5AzstW4NmjqgQ=; b=mZevPd/lzBxUyZa6esgaY/OFh6kEjlug+7i29EkcyUF6MZnS4tgpeL3wVtQvpFoqOPiTOW Ef846YpGfJQHNZGip9TKTRjjMfzrFwbQy8RL4PmzpHHe9zqoX9YMBo9ODF1VO6k/wpQ4lw pNxcFNhX69jpMBrhlV9d2UkNfORBYzI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dhP5pRXP; spf=none (imf02.hostedemail.com: domain of BATV+3ca177389f0c7d0d5156+7099+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+3ca177389f0c7d0d5156+7099+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675070634; a=rsa-sha256; cv=none; b=kKKiRGWRf1vKs/34YKs9h1P59YQeZG7XJLFQvYmKlFfU7bm38+t6cVS6KfIc31NSGl4qH5 pJFoWx9Livjy0AKc2LD0oKJszcL7ZcXiqTQ72knjTdquH16By9P4ADEU0sVcJ0KiEXemRn hOkQIIzkpkaMJ7eIPOaEO5mNni87hco= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=w4kKntDuy29BQaIkx4v+gO5Mr7Op4d5AzstW4NmjqgQ=; b=dhP5pRXPs7QKG7qsUwhXqREoym zFzrmsc54uPZ3WPKRuV0WfgPkfnihth42MiqynU5Q/EDc9fWWebRrTHXAwUzGN/QJoApdfPiDDX0N /HmkaUaiYxfZXLR3z9hdV2llYBIbYlCe2dMJ6F0EqHVStN3Uz7UWDdL6oJBZcAAt0p+6fB6iGbjPD Nd/Ok11pRhrv+rkkmvwJZn5tR6ROXiqwJ2nZx3e7mQ0MNb0CMx12gTe0I5RWQiaLYIPF7aZ5ee0FT Y0XEhRZP9VSnQWzR1IGwBoRJV/D+7pYsUL1N+aAD7VKEQrSA2/9TIqep6pIrHdjX4TAXBBgOIMZ0Y QNuMFv5A==; Received: from [2001:4bb8:19a:272a:732e:e417:47d7:2f4a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pMQMV-002nyZ-Kh; Mon, 30 Jan 2023 09:22:04 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Ilya Dryomov , "Michael S. Tsirkin" , Jason Wang , Minchan Kim , Sergey Senozhatsky , Keith Busch , Sagi Grimberg , Chaitanya Kulkarni , "Martin K. Petersen" , David Howells , Marc Dionne , Xiubo Li , Steve French , Trond Myklebust , Anna Schumaker , Mike Marshall , Andrew Morton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Chuck Lever , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, kvm@vger.kernel.org, netdev@vger.kernel.org, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, devel@lists.orangefs.org, io-uring@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 01/23] block: factor out a bvec_set_page helper Date: Mon, 30 Jan 2023 10:21:35 +0100 Message-Id: <20230130092157.1759539-2-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230130092157.1759539-1-hch@lst.de> References: <20230130092157.1759539-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 78A3480002 X-Stat-Signature: u4qzwc4o1pf3cau6gigcwfx46doej3g7 X-Rspam-User: X-HE-Tag: 1675070632-392545 X-HE-Meta: U2FsdGVkX1+nLgpW+cjaefMQqhLDv/6lOkSMjpikrHccjLBjq8MKh2I3Aikl4qKL2LOGXyTzBvxZIrxELGpjMgNqNyzPG/dlKGdJlLFL0ZzJqwo1zimcZgeHTWa8+agL955aNl2h1x2ti8BJyWMPDPaempODhkjDWCP+D5m0eihIRhJHQspy0fzaZefk7pbHvbELvlFyw6LtHu4ovnNyyixQJY+irwo299SpAjQbFiKIV8uXKPzbKbYongbPi/a3m2Ze3Va4Z0funJJyKgeLeP3EeiM1MYpNTRY2Z5sP/tTspxjMmmXH+baK90sM6AazsUzCa698+42iS9swyR9tFzVrrKcd79Q5vUodWOXtKJFmVWJKI/2wGeEtZqfay4HJlvmMm4aveqtq2zoNN7mB1/Y6tXqpO/CdQ39TcgdV0Je3tZUfaxu8iv37oCUBwcNgtrDpdZJq5HlE0tGyUkPN8dBhDI0BRG8z7Lq9RmqVXYpb4kRtPVqOEAk36ZoXXP3kjKMFKglV7m2ctbTKHuTcMUjvwU07z2HCZLthuKjBSVqKu0rfqGmIAz+6vtZ7zELpEX+FasjRVqkB8+Mi+HUY0f8LJybAngrg1BH5Bsc52MhMTqkziTahwR1kjT7VdK+i2f8AgWn8+7Y+jZb71Qp7wh2kUMETq700ugHTVb9fAgUb8tl/Uvu7nM+J3h6x+wy3ustklUd/UgkMpSN7WdJs3nuGGjpsW4X4YmmC9tub6cLNwA/0qd2o96pRCmpkZygpsjZyEUdyJnh8xb3pIlVX8tb6ayoLUtap4m/ZekgnIs+YCn/JTHbqPy561oKqyEgXaf7FMi2P08UtTqIu6NrSGQQZkUd3dXY3+wvLIp2JQ3xI7xaVxWpPGjMFJsT/UizcHyvcr5697HECUatsraEC2OfnhuQHBSZWJggQgNg3ixVptMmKhaBD3v+HYXos+bG7Dmp/NU3Q2C8dupeYPwv 8Ls+VtEa /9w97YkFhvCgGbVPY0Mp6zUcRansncXPEKdtEhXAjYK6Cx59mVAmoIcHHQndvzrSMNAAiVS/zZqSzJ91IYZFsLTksUCMXigaP6asSYYEFvFNMgQiNEVuxoj1w8PpXP2tewMcnm8gtRjH20Dml5okkAZH1etZRMV/9v4abrFwjCeuB1LMwrlaHCoE5/Sex4pC30w9Ei5Vu5luRCtI7dOOOVXRjvQWuvoeQuR3dD/hEd/t2QiAfpBX0v6J9lmDrUdG1psHVBscqBh4A47Knp8pVnv62DsAQ3Q+elIsLaROsbJg7wIcZfpUtoVLIy5WU8ixhkWytqu7T/09ECgKLleRydH6ImRXxIs3YhScFzqh9FkAxyF0RiGRcFdz4Y7iMVIh6+yc7DMA3aQNrc5WTpG6QIW0/prGkds+FDsHa3BXbcffaNtLXxOjuvL57xwHlofLHT1SWZy+Mva1amMiKNUvzpSvrxkHbSq8Eo7AB X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add a helper to initialize a bvec based of a page pointer. This will help removing various open code bvec initializations. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Chaitanya Kulkarni --- block/bio-integrity.c | 7 +------ block/bio.c | 12 ++---------- include/linux/bvec.h | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/block/bio-integrity.c b/block/bio-integrity.c index 3f5685c00e360b..a3776064c52a16 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -124,23 +124,18 @@ int bio_integrity_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset) { struct bio_integrity_payload *bip = bio_integrity(bio); - struct bio_vec *iv; if (bip->bip_vcnt >= bip->bip_max_vcnt) { printk(KERN_ERR "%s: bip_vec full\n", __func__); return 0; } - iv = bip->bip_vec + bip->bip_vcnt; - if (bip->bip_vcnt && bvec_gap_to_prev(&bdev_get_queue(bio->bi_bdev)->limits, &bip->bip_vec[bip->bip_vcnt - 1], offset)) return 0; - iv->bv_page = page; - iv->bv_len = len; - iv->bv_offset = offset; + bvec_set_page(&bip->bip_vec[bip->bip_vcnt], page, len, offset); bip->bip_vcnt++; return len; diff --git a/block/bio.c b/block/bio.c index d7fbc7adfc50aa..71e411a0c12950 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1029,10 +1029,7 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio, if (bio->bi_vcnt >= queue_max_segments(q)) return 0; - bvec = &bio->bi_io_vec[bio->bi_vcnt]; - bvec->bv_page = page; - bvec->bv_len = len; - bvec->bv_offset = offset; + bvec_set_page(&bio->bi_io_vec[bio->bi_vcnt], page, len, offset); bio->bi_vcnt++; bio->bi_iter.bi_size += len; return len; @@ -1108,15 +1105,10 @@ EXPORT_SYMBOL_GPL(bio_add_zone_append_page); void __bio_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int off) { - struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt]; - WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); WARN_ON_ONCE(bio_full(bio, len)); - bv->bv_page = page; - bv->bv_offset = off; - bv->bv_len = len; - + bvec_set_page(&bio->bi_io_vec[bio->bi_vcnt], page, len, off); bio->bi_iter.bi_size += len; bio->bi_vcnt++; } diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 35c25dff651a5e..9e3dac51eb26b6 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -35,6 +35,21 @@ struct bio_vec { unsigned int bv_offset; }; +/** + * bvec_set_page - initialize a bvec based off a struct page + * @bv: bvec to initialize + * @page: page the bvec should point to + * @len: length of the bvec + * @offset: offset into the page + */ +static inline void bvec_set_page(struct bio_vec *bv, struct page *page, + unsigned int len, unsigned int offset) +{ + bv->bv_page = page; + bv->bv_len = len; + bv->bv_offset = offset; +} + struct bvec_iter { sector_t bi_sector; /* device address in 512 byte sectors */