From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Coly Li <colyli@suse.de>, Mike Snitzer <snitzer@redhat.com>,
Song Liu <song@kernel.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
Phillip Lougher <phillip@squashfs.org.uk>,
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 3/5] target/pscsi: remove pscsi_get_bio
Date: Tue, 8 Mar 2022 07:15:49 +0100 [thread overview]
Message-ID: <20220308061551.737853-4-hch@lst.de> (raw)
In-Reply-To: <20220308061551.737853-1-hch@lst.de>
Remove pscsi_get_bio and simplify the code flow in the only caller.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
---
drivers/target/target_core_pscsi.c | 28 ++--------------------------
1 file changed, 2 insertions(+), 26 deletions(-)
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 0fae71ac5cc8a..bd8ae07273f14 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -823,23 +823,6 @@ static void pscsi_bi_endio(struct bio *bio)
bio_put(bio);
}
-static inline struct bio *pscsi_get_bio(int nr_vecs)
-{
- struct bio *bio;
- /*
- * Use bio_malloc() following the comment in for bio -> struct request
- * in block/blk-core.c:blk_make_request()
- */
- bio = bio_kmalloc(GFP_KERNEL, nr_vecs);
- if (!bio) {
- pr_err("PSCSI: bio_kmalloc() failed\n");
- return NULL;
- }
- bio->bi_end_io = pscsi_bi_endio;
-
- return bio;
-}
-
static sense_reason_t
pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
struct request *req)
@@ -880,12 +863,10 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
if (!bio) {
new_bio:
nr_vecs = bio_max_segs(nr_pages);
- /*
- * Calls bio_kmalloc() and sets bio->bi_end_io()
- */
- bio = pscsi_get_bio(nr_vecs);
+ bio = bio_kmalloc(GFP_KERNEL, nr_vecs);
if (!bio)
goto fail;
+ bio->bi_end_io = pscsi_bi_endio;
if (rw)
bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
@@ -914,11 +895,6 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
goto fail;
}
- /*
- * Clear the pointer so that another bio will
- * be allocated with pscsi_get_bio() above.
- */
- bio = NULL;
goto new_bio;
}
--
2.30.2
next prev parent reply other threads:[~2022-03-08 6:16 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-08 6:15 cleanup bio_kmalloc v2 Christoph Hellwig
2022-03-08 6:15 ` [PATCH 1/5] btrfs: simplify ->flush_bio handling Christoph Hellwig
2022-03-08 22:07 ` Chaitanya Kulkarni
2022-03-08 6:15 ` [PATCH 2/5] squashfs: always use bio_kmalloc in squashfs_bio_read Christoph Hellwig
2022-03-08 6:15 ` Christoph Hellwig [this message]
2022-03-08 22:08 ` [PATCH 3/5] target/pscsi: remove pscsi_get_bio Chaitanya Kulkarni
2022-03-08 6:15 ` [PATCH 4/5] block: turn bio_kmalloc into a simple kmalloc wrapper Christoph Hellwig
2022-03-09 3:06 ` Martin K. Petersen
[not found] ` <CGME20220331211804eucas1p28da21f2dfd57aa490abffb8f87417f42@eucas1p2.samsung.com>
2022-03-31 21:18 ` Marek Szyprowski
2022-03-31 21:22 ` Jens Axboe
2022-04-01 4:57 ` Christoph Hellwig
2022-03-08 6:15 ` [PATCH 5/5] pktcdvd: stop using bio_reset Christoph Hellwig
2022-03-08 22:10 ` Chaitanya Kulkarni
2022-03-30 14:29 ` cleanup bio_kmalloc v2 Christoph Hellwig
2022-03-30 14:37 ` Jens Axboe
2022-03-30 14:49 ` Jens Axboe
2022-03-31 16:34 ` Qian Cai
2022-03-31 16:40 ` Christoph Hellwig
2022-03-31 16:48 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2022-04-06 6:12 cleanup bio_kmalloc v3 Christoph Hellwig
2022-04-06 6:12 ` [PATCH 3/5] target/pscsi: remove pscsi_get_bio Christoph Hellwig
2022-04-06 16:25 ` Chaitanya Kulkarni
2022-03-01 8:45 cleanup bio_kmalloc Christoph Hellwig
2022-03-01 8:45 ` [PATCH 3/5] target/pscsi: remove pscsi_get_bio Christoph Hellwig
2022-03-02 2:57 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220308061551.737853-4-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=colyli@suse.de \
--cc=dm-devel@redhat.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=phillip@squashfs.org.uk \
--cc=snitzer@redhat.com \
--cc=song@kernel.org \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).