Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3700291pxm; Tue, 1 Mar 2022 03:49:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzLfZlg7fmYDhCCMzd5WKTeQB3YZAIBLnbgGxeatXArbTPzIkUQGTXbM/WJCDjp0beTtr79 X-Received: by 2002:a62:75d2:0:b0:4f1:a27:4466 with SMTP id q201-20020a6275d2000000b004f10a274466mr27251750pfc.47.1646135393839; Tue, 01 Mar 2022 03:49:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646135393; cv=none; d=google.com; s=arc-20160816; b=GlbwyBKEVXdnp7/yO9tkrW6WJSr2hQjE70TPCFl+yNaOsPzjF0pH7b0GWzhBuOxnaP Jg/zal/nT6VtfvteS5sukpa2gGb0VWqakPjGNWlsMoxHwiH9YFo4UgBud8nAv1Z/gTfF i3NwKhffqXFa7qai8F5aJmTbjIw3J0rdld/su9BNF2KByzsKBtSJ1+DCfSTRxB7rf5A/ Nc19VLdj8qufpiDfLzJJEh+s1nBmyUKkuuJVdEKDLiBLygkNenAaJDohiWZ7QoK+kEoH zmnJYi+Zlgo66/lS/Vf5V8Rd4qhgxbddSEnJjTodInta85P60dAbuvZDI3ylmWtfAVI9 B1Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y0hYS9Vtv04cgL8ZGlvJWTccJmGVHbCFCF4GFhHbI+k=; b=dumB3MGtPwmWc77bB/kVBJ8VIk1CFXFuYWhgu+IJdzMF+Ruz5ZZyk77b0cvi3BxJVa HRspIEGCeuxRhGpYlGhhKhHElvaBoMyQNFgwL8b/NETFqduiOrhjToS4NJN7wTdNAbng gX79ngvTC4B6H5hGkgs288wizIO3wdX+lXdx99MR4F7LlaZ17XKccPiMUXNLUIbTOn02 w9x45sZOkriBYlsXSts4Erb3evL9wgcSvATg+cQhAfPwDFZHQ0GSs7aucusO+N4XYb+B C4omsba37EXRbYhRPid7FbpQpy8kuzElYQ0gaMP3JlCO9Dp4fI3Lljst7jiZRBiOO96c W62A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="KrUZYt/F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o13-20020a056a00214d00b004e1d44a8cbdsi10857316pfk.311.2022.03.01.03.49.37; Tue, 01 Mar 2022 03:49:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="KrUZYt/F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233583AbiCAIrR (ORCPT + 99 others); Tue, 1 Mar 2022 03:47:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233559AbiCAIrE (ORCPT ); Tue, 1 Mar 2022 03:47:04 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A2A489301; Tue, 1 Mar 2022 00:46:23 -0800 (PST) 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=Y0hYS9Vtv04cgL8ZGlvJWTccJmGVHbCFCF4GFhHbI+k=; b=KrUZYt/FtwvMDhmKfrKOZwaUF/ y30krvFNu6YsGMZraYH0fcq4oPPnY95iUtPMlj75kiTwVtWMSH0BJnNukaR0S2Ft3s69HMgrIWX6K B0ynYtp7X0fTcyMXfSrgbZJzA94+ja3EHtfPXHL0SnUUmsHSW6WbFd60AJRdT6OzvneHhPg0Sst0p OeOakIR9zPYim8mgxvBseVPaOllGxf4ZXcYomixrPyRC2jlT8J9Xdr20OR4AmtU9Wpcx1CrSOfEsd Wa6o6tAN3u2T+UMXIdY38qusyVicUx3wWnxgZXDjrV8abEGBM8LTkPAwdNpNLHZQR6daK+dRRgLH/ xdUK0+cA==; Received: from [2.53.44.23] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nOy99-00FfSF-3j; Tue, 01 Mar 2022 08:46:15 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Coly Li , Mike Snitzer , Song Liu , "Martin K. Petersen" , Josef Bacik , David Sterba , Phillip Lougher , linux-block@vger.kernel.org, dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, target-devel@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: [PATCH 5/5] pktcdvd: stop using bio_reset Date: Tue, 1 Mar 2022 10:45:52 +0200 Message-Id: <20220301084552.880256-6-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220301084552.880256-1-hch@lst.de> References: <20220301084552.880256-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just initialize the bios on-demand. Signed-off-by: Christoph Hellwig --- drivers/block/pktcdvd.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 6aec11ed185d8..e4ee7856483cf 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -525,7 +525,6 @@ static struct packet_data *pkt_alloc_packet_data(int frames) pkt->w_bio = bio_kmalloc(frames, GFP_KERNEL); if (!pkt->w_bio) goto no_bio; - bio_init(pkt->w_bio, NULL, pkt->w_bio->bi_inline_vecs, frames, 0); for (i = 0; i < frames / FRAMES_PER_PAGE; i++) { pkt->pages[i] = alloc_page(GFP_KERNEL|__GFP_ZERO); @@ -537,26 +536,20 @@ static struct packet_data *pkt_alloc_packet_data(int frames) bio_list_init(&pkt->orig_bios); for (i = 0; i < frames; i++) { - struct bio *bio = bio_kmalloc(1, GFP_KERNEL); - if (!bio) + pkt->r_bios[i] = bio_kmalloc(1, GFP_KERNEL); + if (!pkt->r_bios[i]) goto no_rd_bio; - bio_init(bio, NULL, bio->bi_inline_vecs, 1, 0); - pkt->r_bios[i] = bio; } return pkt; no_rd_bio: - for (i = 0; i < frames; i++) { - if (pkt->r_bios[i]) - bio_uninit(pkt->r_bios[i]); + for (i = 0; i < frames; i++) kfree(pkt->r_bios[i]); - } no_page: for (i = 0; i < frames / FRAMES_PER_PAGE; i++) if (pkt->pages[i]) __free_page(pkt->pages[i]); - bio_uninit(pkt->w_bio); kfree(pkt->w_bio); no_bio: kfree(pkt); @@ -571,13 +564,10 @@ static void pkt_free_packet_data(struct packet_data *pkt) { int i; - for (i = 0; i < pkt->frames; i++) { - bio_uninit(pkt->r_bios[i]); + for (i = 0; i < pkt->frames; i++) kfree(pkt->r_bios[i]); - } for (i = 0; i < pkt->frames / FRAMES_PER_PAGE; i++) __free_page(pkt->pages[i]); - bio_uninit(pkt->w_bio); kfree(pkt->w_bio); kfree(pkt); } @@ -950,6 +940,7 @@ static void pkt_end_io_read(struct bio *bio) if (bio->bi_status) atomic_inc(&pkt->io_errors); + bio_uninit(bio); if (atomic_dec_and_test(&pkt->io_wait)) { atomic_inc(&pkt->run_sm); wake_up(&pd->wqueue); @@ -967,6 +958,7 @@ static void pkt_end_io_packet_write(struct bio *bio) pd->stats.pkt_ended++; + bio_uninit(bio); pkt_bio_finished(pd); atomic_dec(&pkt->io_wait); atomic_inc(&pkt->run_sm); @@ -1021,7 +1013,7 @@ static void pkt_gather_data(struct pktcdvd_device *pd, struct packet_data *pkt) continue; bio = pkt->r_bios[f]; - bio_reset(bio, pd->bdev, REQ_OP_READ); + bio_init(bio, pd->bdev, bio->bi_inline_vecs, 1, REQ_OP_READ); bio->bi_iter.bi_sector = pkt->sector + f * (CD_FRAMESIZE >> 9); bio->bi_end_io = pkt_end_io_read; bio->bi_private = pkt; @@ -1234,7 +1226,8 @@ static void pkt_start_write(struct pktcdvd_device *pd, struct packet_data *pkt) { int f; - bio_reset(pkt->w_bio, pd->bdev, REQ_OP_WRITE); + bio_init(pkt->w_bio, pd->bdev, pkt->w_bio->bi_inline_vecs, pkt->frames, + REQ_OP_WRITE); pkt->w_bio->bi_iter.bi_sector = pkt->sector; pkt->w_bio->bi_end_io = pkt_end_io_packet_write; pkt->w_bio->bi_private = pkt; -- 2.30.2