From patchwork Fri Feb 3 15:06:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13127841 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 0CF2EC636D7 for ; Fri, 3 Feb 2023 15:07:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 056B76B0080; Fri, 3 Feb 2023 10:07:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E8E856B007B; Fri, 3 Feb 2023 10:07:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C448D6B0072; Fri, 3 Feb 2023 10:07:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id A99E36B0072 for ; Fri, 3 Feb 2023 10:07:48 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 50B9641116 for ; Fri, 3 Feb 2023 15:07:48 +0000 (UTC) X-FDA: 80426310216.27.C186200 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id 3FF22100007 for ; Fri, 3 Feb 2023 15:07:45 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=jThz1+8n; dmarc=none; spf=none (imf05.hostedemail.com: domain of BATV+416129e804eec9e75a33+7103+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+416129e804eec9e75a33+7103+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675436866; 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=0dnvJ4/YC2qBSRJoUXjkVbZEbeJtTI76nFk14xqdiQw=; b=t+TLGreoD6Mpv7qIlKzFedb9CpA5/68VrF8qbJav6mqgG9uUN+yt3+E6oHj8jyFGPTdPJ9 hT4J3ZBbAixGDVc8qmp020slZgRGTBn/RRUkGIP/xJJr4DnDL3M8kd9jd/JJRq+9V6/AQC C5edfNKQTbJ2LY6QsJBS52WxXfjdD/Y= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=jThz1+8n; dmarc=none; spf=none (imf05.hostedemail.com: domain of BATV+416129e804eec9e75a33+7103+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+416129e804eec9e75a33+7103+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675436866; a=rsa-sha256; cv=none; b=xQx/CeeCgAqqNIorAJqrQSVqU2kRiCvI5cd5kllg6dqmlB3/6p7OIQlnnuU3QyTKRtiaCk pnSyBeM1CRCmcKspj8zLku32CIH5RYLRc5aoi+5HX23U7nhPVKAwe1j252waiIlgiTDxs/ AkR8QsBuAN8Z1fPtkejmy3dDuhUqH2E= 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=0dnvJ4/YC2qBSRJoUXjkVbZEbeJtTI76nFk14xqdiQw=; b=jThz1+8n2gvxR38Zi9f42VmE45 A0CQMmeY4zEOFyZVpnGrj7P3ElL65WJv08LoA8qb4oLRV9x/A+fETre1KW3oI0WTHrjKsgFn+udP9 s8a7hrQusDgbFYCjIl78yvwptpj2jEEGnKDDzqCGq/bYeCWCTdbYIGBEdQ6rFkqzFD5JMgegY/DME 2+tmqE2azh6NMd1kOiaut0xU3w249YI9lKsJhI7VvYjZLGRpGu26md2fN2faz+WSsNcmtIb3zqiwu pTf6YtHpE9SOvDbM4uz3U03Q9zSNtoPuZYSLX0u2MBqlOX+a5b/Mm5OP0GBEkpqNc/X1qmsSVgNln AYxdeXlw==; Received: from [2001:4bb8:19a:272a:910:bb67:7287:f956] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pNxeB-002ac4-UN; Fri, 03 Feb 2023 15:06:40 +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, Johannes Thumshirn Subject: [PATCH 01/23] block: factor out a bvec_set_page helper Date: Fri, 3 Feb 2023 16:06:12 +0100 Message-Id: <20230203150634.3199647-2-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230203150634.3199647-1-hch@lst.de> References: <20230203150634.3199647-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-Queue-Id: 3FF22100007 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 3uhxndmorgpsrr1rrpr7hx1g6ejm61iw X-HE-Tag: 1675436865-956229 X-HE-Meta: U2FsdGVkX18wC5ZA1OWDY5VF4hWoEDHkesx3nmtd/Zuigqtqycictwxqyg8l6JXfdJmUT8MR6pCCFjay7P02Un6HsSe/8tssHvUk0wf1ameMtroLGPrOzdD1ZL+5qy5b2eHK5YxCdb/r0PXVtTKvn23LvZXO4GjO8LAn2iHd9i6dVCO+SHR/Rd4Wc2tNMqzg5/I2WCRiKU5WihjNCFDl/wa86P6W143Ylf+4gKCrDNasLsl70PoSaGqQ9ZVrvDJjHMUfiMZuA9KHsV0/u+FoCR6z0FNGOxW8ATA7LX1hAbnAvOV7RHhgm0OL0AwxsWEIRDFgXTI9hhoF7jTfQ1jLXRhwb4tUHeM+QvqMYVdDNdLkVL9D/FT5nIe29vADJ7BN5fvNP7nGn/Ztyu3BhPB1A0Ywf1hVSDMZ1pAfA6epts4rxnpjHfAflcJnA/LXqtkMyfTHJbB5Fn6jH7rASOH5L7MG0sylDhNryKYbGqQDZvxZuFMya/LfII95lmuKvyEgBNkodhDPxSUNpzJYyq7gMKrJOWteuFTkM+Z+CTTOi2uhV35jayCgvwJZBSrguwHFuwkbf9R5Z7zC4dShHjru3qJMH0xY+DzFmNxKG24qbEMlIdOHoCuAHlJ8mBZ2R+UmAqgDcIZO+rzL5EY/25WuMOwtO8LQVl8ggWNMZbesmBlThDTn21accP34Tr9Tj0d3pF4QK7cKGtpkUa03m197YyASMvyIkyX782gDaN0jEcOWVoYHTUOd0wXyeCo5PhrMVnBdVeVKD1KTUv/AtiU6tHMytDyDIqWyeQLAobSpzkXqM0Dd6Ysrlon8mlkm0sBz8Imx9X4ry+NwNLtFmr43AmpfX6zve/p/OlQiqA/1mSwvNbyhfQa7y5JH29Cqah5uivH9Hac4lRTU2QExDhwkIsMu2G1ZX+8gxGdAJ8p63Q4ZBWU630/yPuULKhnwpS/IhqWMfKUslSIigohJAkT g+d3KjHX TKhEH1AKCIQ5ZRUxA6+u0/JR4Wo28SkqiUNnppkYX/76vZJj4KQ9VpiBdnFXyTMrlX8V2NEmiZ0FnWML3zIH/+M76U0eOf9RplOAaCzZd3ckJ+nRNKG1M1JZgsQv7vk2EkQLNb+4aJ1Z6l7o5MMI/O46EXjZpANamJ1zLjz7a87OJGDxewDZ63i3KkUtWBJjHhL/9bY1ne2WkCuQU/qnflrxWkESD7Dyge+4Q8dNQkj2UcTnxoPD2sHEdtSixaqEKeMrsRBKYAm7JCnt9W/pE3EFCZhowaoG2scWzdGF7m6EB4HNdGRIcJU0BaoqY42ptgC/xG9yCjkgJKt4NB0jFlch4L3aNgmRTBINO4+pZKs5qmZixzQNs+LSH9Hyi+MVXydrj7FbbYxZZkh3zf4m7nToxnDtKqXTZ2wWLpfdH6HsaBYl/TN0xEpZzunprKak4xf/LKnYlLGgxtORovRUSqi1w0jVNPs2wmlwxJCpM3yU+wEmdH+bUzEEK+WfaQKOYkonMuqyJI12IwCn/pg8Vn0zJY2S9mivI518UhKVcNuJ9otPkfrG+vE5j4A== 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: Chaitanya Kulkarni Reviewed-by: Johannes Thumshirn --- 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 */