Skip to content

Commit 4b1dc86

Browse files
Christoph Hellwigaxboe
authored andcommitted
drbd: bio_alloc can't fail if it is allow to sleep
Remove handling of NULL returns from sleeping bio_alloc calls given that those can't fail. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 28d7d12 commit 4b1dc86

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

drivers/block/drbd/drbd_receiver.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,14 +1281,13 @@ static void submit_one_flush(struct drbd_device *device, struct issue_flush_cont
12811281
{
12821282
struct bio *bio = bio_alloc(GFP_NOIO, 0);
12831283
struct one_flush_context *octx = kmalloc(sizeof(*octx), GFP_NOIO);
1284-
if (!bio || !octx) {
1285-
drbd_warn(device, "Could not allocate a bio, CANNOT ISSUE FLUSH\n");
1284+
1285+
if (!octx) {
1286+
drbd_warn(device, "Could not allocate a octx, CANNOT ISSUE FLUSH\n");
12861287
/* FIXME: what else can I do now? disconnecting or detaching
12871288
* really does not help to improve the state of the world, either.
12881289
*/
1289-
kfree(octx);
1290-
if (bio)
1291-
bio_put(bio);
1290+
bio_put(bio);
12921291

12931292
ctx->error = -ENOMEM;
12941293
put_ldev(device);
@@ -1646,7 +1645,6 @@ int drbd_submit_peer_request(struct drbd_device *device,
16461645
unsigned data_size = peer_req->i.size;
16471646
unsigned n_bios = 0;
16481647
unsigned nr_pages = (data_size + PAGE_SIZE -1) >> PAGE_SHIFT;
1649-
int err = -ENOMEM;
16501648

16511649
/* TRIM/DISCARD: for now, always use the helper function
16521650
* blkdev_issue_zeroout(..., discard=true).
@@ -1688,10 +1686,6 @@ int drbd_submit_peer_request(struct drbd_device *device,
16881686
*/
16891687
next_bio:
16901688
bio = bio_alloc(GFP_NOIO, nr_pages);
1691-
if (!bio) {
1692-
drbd_err(device, "submit_ee: Allocation of a bio failed (nr_pages=%u)\n", nr_pages);
1693-
goto fail;
1694-
}
16951689
/* > peer_req->i.sector, unless this is the first bio */
16961690
bio->bi_iter.bi_sector = sector;
16971691
bio_set_dev(bio, device->ldev->backing_bdev);
@@ -1726,14 +1720,6 @@ int drbd_submit_peer_request(struct drbd_device *device,
17261720
drbd_submit_bio_noacct(device, fault_type, bio);
17271721
} while (bios);
17281722
return 0;
1729-
1730-
fail:
1731-
while (bios) {
1732-
bio = bios;
1733-
bios = bios->bi_next;
1734-
bio_put(bio);
1735-
}
1736-
return err;
17371723
}
17381724

17391725
static void drbd_remove_epoch_entry_interval(struct drbd_device *device,

0 commit comments

Comments
 (0)