From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Pavel Begunkov" <asml.silence@gmail.com>,
"Mike Snitzer" <snitzer@redhat.com>,
"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Md . Haris Iqbal " <haris.iqbal@ionos.com>,
"Jack Wang" <jinpu.wang@ionos.com>,
"Roger Pau Monné" <roger.pau@citrix.co>,
"Philipp Reisner" <philipp.reisner@linbit.com>,
"Lars Ellenberg" <lars.ellenberg@linbit.com>,
linux-block@vger.kernel.org, dm-devel@redhat.com,
linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
linux-nilfs@vger.kernel.org, ntfs3@lists.linux.dev,
xen-devel@lists.xenproject.org, drbd-dev@lists.linbit.com
Subject: [PATCH 05/19] dm: bio_alloc can't fail if it is allowed to sleep
Date: Mon, 24 Jan 2022 10:10:53 +0100 [thread overview]
Message-ID: <20220124091107.642561-6-hch@lst.de> (raw)
In-Reply-To: <20220124091107.642561-1-hch@lst.de>
Remove handling of NULL returns from sleeping bio_alloc calls given that
those can't fail.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/dm-crypt.c | 5 +----
drivers/md/dm-log-writes.c | 18 ------------------
drivers/md/dm-thin.c | 25 +++++++++----------------
drivers/md/dm-zoned-metadata.c | 11 -----------
drivers/md/dm.c | 2 --
5 files changed, 10 insertions(+), 51 deletions(-)
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index d4ae31558826a..20abe3486aba1 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1673,9 +1673,6 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size)
mutex_lock(&cc->bio_alloc_lock);
clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, &cc->bs);
- if (!clone)
- goto out;
-
clone_init(io, clone);
remaining_size = size;
@@ -1702,7 +1699,7 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size)
bio_put(clone);
clone = NULL;
}
-out:
+
if (unlikely(gfp_mask & __GFP_DIRECT_RECLAIM))
mutex_unlock(&cc->bio_alloc_lock);
diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c
index 139b09b06eda9..25f5e8d2d417b 100644
--- a/drivers/md/dm-log-writes.c
+++ b/drivers/md/dm-log-writes.c
@@ -218,10 +218,6 @@ static int write_metadata(struct log_writes_c *lc, void *entry,
size_t ret;
bio = bio_alloc(GFP_KERNEL, 1);
- if (!bio) {
- DMERR("Couldn't alloc log bio");
- goto error;
- }
bio->bi_iter.bi_size = 0;
bio->bi_iter.bi_sector = sector;
bio_set_dev(bio, lc->logdev->bdev);
@@ -276,11 +272,6 @@ static int write_inline_data(struct log_writes_c *lc, void *entry,
atomic_inc(&lc->io_blocks);
bio = bio_alloc(GFP_KERNEL, bio_pages);
- if (!bio) {
- DMERR("Couldn't alloc inline data bio");
- goto error;
- }
-
bio->bi_iter.bi_size = 0;
bio->bi_iter.bi_sector = sector;
bio_set_dev(bio, lc->logdev->bdev);
@@ -322,7 +313,6 @@ static int write_inline_data(struct log_writes_c *lc, void *entry,
error_bio:
bio_free_pages(bio);
bio_put(bio);
-error:
put_io_block(lc);
return -1;
}
@@ -364,10 +354,6 @@ static int log_one_block(struct log_writes_c *lc,
atomic_inc(&lc->io_blocks);
bio = bio_alloc(GFP_KERNEL, bio_max_segs(block->vec_cnt));
- if (!bio) {
- DMERR("Couldn't alloc log bio");
- goto error;
- }
bio->bi_iter.bi_size = 0;
bio->bi_iter.bi_sector = sector;
bio_set_dev(bio, lc->logdev->bdev);
@@ -387,10 +373,6 @@ static int log_one_block(struct log_writes_c *lc,
submit_bio(bio);
bio = bio_alloc(GFP_KERNEL,
bio_max_segs(block->vec_cnt - i));
- if (!bio) {
- DMERR("Couldn't alloc log bio");
- goto error;
- }
bio->bi_iter.bi_size = 0;
bio->bi_iter.bi_sector = sector;
bio_set_dev(bio, lc->logdev->bdev);
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index ec119d2422d5d..76a9c2e9aeeea 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1180,24 +1180,17 @@ static void process_prepared_discard_passdown_pt1(struct dm_thin_new_mapping *m)
}
discard_parent = bio_alloc(GFP_NOIO, 1);
- if (!discard_parent) {
- DMWARN("%s: unable to allocate top level discard bio for passdown. Skipping passdown.",
- dm_device_name(tc->pool->pool_md));
- queue_passdown_pt2(m);
+ discard_parent->bi_end_io = passdown_endio;
+ discard_parent->bi_private = m;
- } else {
- discard_parent->bi_end_io = passdown_endio;
- discard_parent->bi_private = m;
-
- if (m->maybe_shared)
- passdown_double_checking_shared_status(m, discard_parent);
- else {
- struct discard_op op;
+ if (m->maybe_shared)
+ passdown_double_checking_shared_status(m, discard_parent);
+ else {
+ struct discard_op op;
- begin_discard(&op, tc, discard_parent);
- r = issue_discard(&op, m->data_block, data_end);
- end_discard(&op, r);
- }
+ begin_discard(&op, tc, discard_parent);
+ r = issue_discard(&op, m->data_block, data_end);
+ end_discard(&op, r);
}
}
diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index ee4626d085574..5718b83cc7182 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -551,10 +551,6 @@ static struct dmz_mblock *dmz_get_mblock_slow(struct dmz_metadata *zmd,
return ERR_PTR(-ENOMEM);
bio = bio_alloc(GFP_NOIO, 1);
- if (!bio) {
- dmz_free_mblock(zmd, mblk);
- return ERR_PTR(-ENOMEM);
- }
spin_lock(&zmd->mblk_lock);
@@ -726,10 +722,6 @@ static int dmz_write_mblock(struct dmz_metadata *zmd, struct dmz_mblock *mblk,
return -EIO;
bio = bio_alloc(GFP_NOIO, 1);
- if (!bio) {
- set_bit(DMZ_META_ERROR, &mblk->state);
- return -ENOMEM;
- }
set_bit(DMZ_META_WRITING, &mblk->state);
@@ -760,9 +752,6 @@ static int dmz_rdwr_block(struct dmz_dev *dev, int op,
return -EIO;
bio = bio_alloc(GFP_NOIO, 1);
- if (!bio)
- return -ENOMEM;
-
bio->bi_iter.bi_sector = dmz_blk2sect(block);
bio_set_dev(bio, dev->bdev);
bio_set_op_attrs(bio, op, REQ_SYNC | REQ_META | REQ_PRIO);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index c0ae8087c6027..81449cbdafa81 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -520,8 +520,6 @@ static struct dm_io *alloc_io(struct mapped_device *md, struct bio *bio)
struct bio *clone;
clone = bio_alloc_bioset(GFP_NOIO, 0, &md->io_bs);
- if (!clone)
- return NULL;
tio = container_of(clone, struct dm_target_io, clone);
tio->inside_dm_io = true;
--
2.30.2
next prev parent reply other threads:[~2022-01-24 9:11 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 9:10 improve the bio allocation interface v2 Christoph Hellwig
2022-01-24 9:10 ` [PATCH 01/19] fs: remove mpage_alloc Christoph Hellwig
2022-03-22 21:19 ` [dm-devel] " Guenter Roeck
2022-03-22 21:38 ` Ryusuke Konishi
2022-03-23 6:42 ` Christoph Hellwig
2022-03-23 9:29 ` Ryusuke Konishi
2022-01-24 9:10 ` [PATCH 02/19] nilfs2: remove nilfs_alloc_seg_bio Christoph Hellwig
2022-01-27 21:38 ` Ryusuke Konishi
2022-01-24 9:10 ` [PATCH 03/19] nfs/blocklayout: remove bl_alloc_init_bio Christoph Hellwig
2022-01-24 9:10 ` [PATCH 04/19] ntfs3: remove ntfs_alloc_bio Christoph Hellwig
2022-01-24 9:10 ` Christoph Hellwig [this message]
2022-01-27 17:08 ` [PATCH 05/19] dm: bio_alloc can't fail if it is allowed to sleep Mike Snitzer
2022-01-24 9:10 ` [PATCH 06/19] dm-crypt: remove clone_init Christoph Hellwig
2022-01-27 17:09 ` Mike Snitzer
2022-01-24 9:10 ` [PATCH 07/19] dm-snap: use blkdev_issue_flush instead of open coding it Christoph Hellwig
2022-01-27 17:11 ` Mike Snitzer
2022-01-24 9:10 ` [PATCH 08/19] dm-thin: " Christoph Hellwig
2022-01-27 17:11 ` Mike Snitzer
2022-01-24 9:10 ` [PATCH 09/19] drbd: bio_alloc can't fail if it is allow to sleep Christoph Hellwig
2022-01-24 9:10 ` [PATCH 10/19] rnbd-srv: simplify bio mapping in process_rdma Christoph Hellwig
2022-01-24 9:10 ` [PATCH 11/19] rnbd-srv: remove struct rnbd_dev_blk_io Christoph Hellwig
2022-01-24 21:07 ` Jinpu Wang
2022-01-24 9:11 ` [PATCH 12/19] xen-blkback: bio_alloc can't fail if it is allow to sleep Christoph Hellwig
2022-01-24 9:11 ` [PATCH 13/19] block: move blk_next_bio to bio.c Christoph Hellwig
2022-01-24 9:11 ` [PATCH 14/19] block: pass a block_device and opf to blk_next_bio Christoph Hellwig
2022-01-24 9:11 ` [PATCH 15/19] block: pass a block_device and opf to bio_alloc_bioset Christoph Hellwig
2022-01-24 9:11 ` [PATCH 16/19] block: pass a block_device and opf to bio_alloc_kiocb Christoph Hellwig
2022-01-24 9:11 ` [PATCH 17/19] block: pass a block_device and opf to bio_alloc Christoph Hellwig
2022-01-24 9:11 ` [PATCH 18/19] block: pass a block_device and opf to bio_init Christoph Hellwig
2022-01-24 9:11 ` [PATCH 19/19] block: pass a block_device and opf to bio_reset Christoph Hellwig
2022-02-02 14:50 ` improve the bio allocation interface v2 Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2022-01-18 7:19 improve the bio allocation interface Christoph Hellwig
2022-01-18 7:19 ` [PATCH 05/19] dm: bio_alloc can't fail if it is allowed to sleep Christoph Hellwig
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=20220124091107.642561-6-hch@lst.de \
--to=hch@lst.de \
--cc=akpm@linux-foundation.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=drbd-dev@lists.linbit.com \
--cc=haris.iqbal@ionos.com \
--cc=jinpu.wang@ionos.com \
--cc=konishi.ryusuke@gmail.com \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
--cc=philipp.reisner@linbit.com \
--cc=roger.pau@citrix.co \
--cc=snitzer@redhat.com \
--cc=xen-devel@lists.xenproject.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