From patchwork Wed Apr 19 14:09:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13216955 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B3EDC77B75 for ; Wed, 19 Apr 2023 14:11:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232707AbjDSOLw (ORCPT ); Wed, 19 Apr 2023 10:11:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232226AbjDSOLJ (ORCPT ); Wed, 19 Apr 2023 10:11:09 -0400 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D10E316DDC; Wed, 19 Apr 2023 07:10:58 -0700 (PDT) Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-2f95231618aso1846755f8f.1; Wed, 19 Apr 2023 07:10:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681913458; x=1684505458; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/zlw+dyGlfnLYWyTWZyG7072cksvgegzTzOhlPnlIpY=; b=ONqMj3+A8cqNwSMxHmwFSQFeXXkg7+2D3ZwEoHH3KA/XMVPlTiU0I+CsxdJxTnx1K0 SLPclvBhPdLwwdKczXmHvif93rof+Qfppikp7iMAXXilCQ+F4jbVfjrgCbu41AxnNx9Z HMLIXaM7S/H8JHVQ9iVCbKqPUPWithEyYIawsF/sMxlVcHAhrwZk5IVLbnc6EyYHvpCl QVcSKlKIvc97mnVhMp7c1M5bokcaHWjOzZKNZ5oVcnUPGNyZ6LHbvFGe3y6N1Fyr4Yx8 KCPGNxcqXp2y5ZKPwdNJMFt7j1ZjLMbmYRH0gVfdJnN8t/WKRKYjRBGS40SzqjdccgJd aQTw== X-Gm-Message-State: AAQBX9c3vY/kIXafrAszuWBe/KQ6eElichnLrphOZvpHyEnCqsvhuzcT 4EoRW80yCV3S60mbNah95zo= X-Google-Smtp-Source: AKy350ZBtxc/TGFor4lepp28gxjzMLtfR2kXHzHsofIAAqDJVDxt5jCQYZANHY4xZIooK/Ogo3z5tA== X-Received: by 2002:adf:f84c:0:b0:2f5:d0f:744a with SMTP id d12-20020adff84c000000b002f50d0f744amr4499259wrq.12.1681913458339; Wed, 19 Apr 2023 07:10:58 -0700 (PDT) Received: from localhost.localdomain (aftr-62-216-205-204.dynamic.mnet-online.de. [62.216.205.204]) by smtp.googlemail.com with ESMTPSA id q17-20020a5d61d1000000b002faaa9a1721sm7612089wrv.58.2023.04.19.07.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 07:10:57 -0700 (PDT) From: Johannes Thumshirn To: axboe@kernel.dk Cc: johannes.thumshirn@wdc.com, agruenba@redhat.com, cluster-devel@redhat.com, damien.lemoal@wdc.com, dm-devel@redhat.com, dsterba@suse.com, hare@suse.de, hch@lst.de, jfs-discussion@lists.sourceforge.net, kch@nvidia.com, linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-raid@vger.kernel.org, ming.lei@redhat.com, rpeterso@redhat.com, shaggy@kernel.org, snitzer@kernel.org, song@kernel.org, willy@infradead.org, Damien Le Moal Subject: [PATCH v3 18/19] dm-crypt: check if adding pages to clone bio fails Date: Wed, 19 Apr 2023 16:09:28 +0200 Message-Id: <20230419140929.5924-19-jth@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230419140929.5924-1-jth@kernel.org> References: <20230419140929.5924-1-jth@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Johannes Thumshirn Check if adding pages to clone bio fails and if it does retry with reclaim. This mirrors the behaviour of page allocation in crypt_alloc_buffer(). This way we can mark bio_add_pages as __must_check. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien Le Moal --- drivers/md/dm-crypt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 3ba53dc3cc3f..19f7e087c6df 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1693,7 +1693,14 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned int size) len = (remaining_size > PAGE_SIZE) ? PAGE_SIZE : remaining_size; - bio_add_page(clone, page, len, 0); + if (!bio_add_page(clone, page, len, 0)) { + mempool_free(page, &cc->page_pool); + crypt_free_buffer_pages(cc, clone); + bio_put(clone); + gfp_mask |= __GFP_DIRECT_RECLAIM; + goto retry; + + } remaining_size -= len; }