From patchwork Mon Jan 24 09:10:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12721770 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6ACFBC43219 for ; Mon, 24 Jan 2022 09:11:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.259774.448389 (Exim 4.92) (envelope-from ) id 1nBvO9-0003uA-4u; Mon, 24 Jan 2022 09:11:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 259774.448389; Mon, 24 Jan 2022 09:11:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nBvO8-0003tj-WB; Mon, 24 Jan 2022 09:11:48 +0000 Received: by outflank-mailman (input) for mailman id 259774; Mon, 24 Jan 2022 09:11:47 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nBvO7-0000If-D3 for xen-devel@lists.xenproject.org; Mon, 24 Jan 2022 09:11:47 +0000 Received: from bombadil.infradead.org (bombadil.infradead.org [2607:7c80:54:e::133]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a75d4a2f-7cf5-11ec-bc18-3156f6d857e4; Mon, 24 Jan 2022 10:11:46 +0100 (CET) Received: from [2001:4bb8:184:72a4:a337:a75f:a24e:7e39] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nBvNu-002kBG-B5; Mon, 24 Jan 2022 09:11:34 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a75d4a2f-7cf5-11ec-bc18-3156f6d857e4 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=zt4z0CCqxTu0ALe3IrRHpwIG3ETXoc3mZtIYo6QdQDM=; b=s3e61xH669mdB88dsM0ako/6hm YsdPOFv/+9bUrCprVe09zHwO1lKRo1xqZckfy+k3aI4O7evk+RiB0/o5y50HMgqybj6V8nydnHaqX mtMq31ULR3tuFniaKuzrkBKWQ9GLcEOIxcmh7CseGdVBvrlGNE+yQfMA1Ozavs6cDairUaII9NR8y ph4Ax4aY8fmmukVLpqEVBHr+JV24FvfuqKG6PehkdijYQ2882QgOVHZuvUklnkTyQ1NRkwXensI+H fb2buJqmJs6jYMIPQO5OmkHhgR28rV4GqNdGzaVKM7k+in5ebCQTHOLDzcJGZZNvSIJF2PMIzPxhK 4yVDZYeA==; From: Christoph Hellwig To: Jens Axboe Cc: Pavel Begunkov , Mike Snitzer , Ryusuke Konishi , Konstantin Komarov , Andrew Morton , "Md . Haris Iqbal " , Jack Wang , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Philipp Reisner , Lars Ellenberg , 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 09/19] drbd: bio_alloc can't fail if it is allow to sleep Date: Mon, 24 Jan 2022 10:10:57 +0100 Message-Id: <20220124091107.642561-10-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220124091107.642561-1-hch@lst.de> References: <20220124091107.642561-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 Remove handling of NULL returns from sleeping bio_alloc calls given that those can't fail. Signed-off-by: Christoph Hellwig --- drivers/block/drbd/drbd_receiver.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c index 6df2539e215ba..fb59b263deeef 100644 --- a/drivers/block/drbd/drbd_receiver.c +++ b/drivers/block/drbd/drbd_receiver.c @@ -1281,14 +1281,13 @@ static void submit_one_flush(struct drbd_device *device, struct issue_flush_cont { struct bio *bio = bio_alloc(GFP_NOIO, 0); struct one_flush_context *octx = kmalloc(sizeof(*octx), GFP_NOIO); - if (!bio || !octx) { - drbd_warn(device, "Could not allocate a bio, CANNOT ISSUE FLUSH\n"); + + if (!octx) { + drbd_warn(device, "Could not allocate a octx, CANNOT ISSUE FLUSH\n"); /* FIXME: what else can I do now? disconnecting or detaching * really does not help to improve the state of the world, either. */ - kfree(octx); - if (bio) - bio_put(bio); + bio_put(bio); ctx->error = -ENOMEM; put_ldev(device); @@ -1646,7 +1645,6 @@ int drbd_submit_peer_request(struct drbd_device *device, unsigned data_size = peer_req->i.size; unsigned n_bios = 0; unsigned nr_pages = (data_size + PAGE_SIZE -1) >> PAGE_SHIFT; - int err = -ENOMEM; /* TRIM/DISCARD: for now, always use the helper function * blkdev_issue_zeroout(..., discard=true). @@ -1688,10 +1686,6 @@ int drbd_submit_peer_request(struct drbd_device *device, */ next_bio: bio = bio_alloc(GFP_NOIO, nr_pages); - if (!bio) { - drbd_err(device, "submit_ee: Allocation of a bio failed (nr_pages=%u)\n", nr_pages); - goto fail; - } /* > peer_req->i.sector, unless this is the first bio */ bio->bi_iter.bi_sector = sector; bio_set_dev(bio, device->ldev->backing_bdev); @@ -1726,14 +1720,6 @@ int drbd_submit_peer_request(struct drbd_device *device, drbd_submit_bio_noacct(device, fault_type, bio); } while (bios); return 0; - -fail: - while (bios) { - bio = bios; - bios = bios->bi_next; - bio_put(bio); - } - return err; } static void drbd_remove_epoch_entry_interval(struct drbd_device *device,