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: 13216888 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 874FDC6FD18 for ; Wed, 19 Apr 2023 14:11:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0FE43900010; Wed, 19 Apr 2023 10:11:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EDB00900007; Wed, 19 Apr 2023 10:11:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D7C9B900010; Wed, 19 Apr 2023 10:11:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B7D6B900007 for ; Wed, 19 Apr 2023 10:11:01 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7E2D81C5F7C for ; Wed, 19 Apr 2023 14:11:01 +0000 (UTC) X-FDA: 80698327122.04.6EAA1C6 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by imf21.hostedemail.com (Postfix) with ESMTP id A1A931C001D for ; Wed, 19 Apr 2023 14:10:59 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681913459; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/zlw+dyGlfnLYWyTWZyG7072cksvgegzTzOhlPnlIpY=; b=WpwGRRl/2eJ6bZ5yDs6WwgsWfsPDu3q+czJoVq+qHYkEojf/v0/MYb2+3lQje3aMFO+GPm rrFJgCTN8l8b8PeQjoLqNlHKxc5VJyExDRqfWUEMvI7rVMoZlrXnuxseRcKci+VcqdzKrg 9FqVtWtsGjbU09XUGqasA3G+LQuOFKM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.221.52 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681913459; a=rsa-sha256; cv=none; b=yj40bm8h99ntqmcfJJcow2qfQRfwBn6XiwDh+L1AgXAiphkMwe97eGB6/iuTt4Fgm0fifn uaKOcJA8KYrd95VVLKbo44lbsxfrXIVweuRlQnfxVr53qJtBnXAXGi5k4Pbfa3Ouq3zaZP UIlzf3iia7/1oG046X19pBzzLfbHGRU= Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-2f55ffdbaedso2092638f8f.2 for ; Wed, 19 Apr 2023 07:10:59 -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=OHd6A3VeS3fuYmak13O4lmKMp8LE/5Qx/l40LG+BFSvJu8Q14YgYxrICc4BkuTylc0 hLTSHvF4URuwCxwUulbySSoaWu0lj8gAmFWV30H07CosSubKYR2mQh7AY/ZQm107O05y qaWTYBhKbGrdwCVKBq+/uC3X9Wg1kAegcb1lAd3plB4v4j8t72Gc4rDJ6oAYPgTl3K10 Nyuw8yKAZfI1cjQfaLs6HFh+8XejNVGKtu6g+jdtVQfcA3xyL+4/W7C8m8AsEwmkcldR Y97JB9XLlEDAUrYckZ1b72jv+lixfcxj2ekoJPzUjudkFNW8r+kt9NXPbx8w+1wHWKsP Mv4g== X-Gm-Message-State: AAQBX9fe28gQ0bxjgrVMj+P+ATlUbfdQyQHx6+ymZCKSGTZYBU+z7TaO +0cVGjGROueTPhx2B8h8W6I= 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 X-Stat-Signature: mrsz33zix518u8mx9sn3c6ziqbgou79x X-Rspam-User: X-Rspamd-Queue-Id: A1A931C001D X-Rspamd-Server: rspam06 X-HE-Tag: 1681913459-260574 X-HE-Meta: U2FsdGVkX1+Z+oEWWxhCdrlcCL48DS3SScPwqhYy14WlfbA2rbM2ne45wS/1KWUMPJ7M6YiuCk2yMFqVRdnD99n0YvEaXGPNrrIitgz4+L7lXHEDo7ivT69pFPuqbDgoAZSQ1BsdH2d7CflMEJyIFdg/TQXvPkSWemk69ZwqVq66SnedbCKZNfcGZ4ZPoJRInXh1Fop3oM6T6gFytYEQDaTdi8fuZ8fNeM8Rv9WLLAZviGB4FCkUU2MqOZhm+6VkltgFr7R0QfCG8VWJCPSuY8LIorwslS7WxG8lfp5axaOT5maS6zlS+eh8KEhGYGzf7oLF6kZYUnyGln3f74BJ+Tv8MhiSTZultJ0KgS0YP8nAgX9DK8UUaczipjgaeT3OcHpb792V0OcZN+9LuOL4MLvX5/JxFa87+uL+kjjkzc6klFiTsG7IW/U2N2+Eoiw7bhDGzv2u1i2p9eMaZ07crBAEOu9SkJwHwPEC1aNgEwP/xBRvlM9FX/S89qUrro5DVW3zUcjOqTyG4X9zbKuplYKkQuYKM1bgDgX8XblTA796AlV7DuMkhAl9ZUOvJErSp+CH2YeDCyBgIxZQ2vDbrD+fdsFMTx3Flx3KuAwbBZImkzyrMg6MaJD/7uZrvHo8MJGHL5VvGzRkWpvhIGZJ2q3n5iPRds28ECBZkZTRMSkLZGfmRc6xbVbcV09AYO6LOtI9TuulC8ojZt2U5vBQW0kKGCxRl4kOtQ5zoUPs/SWFAZ3cdKcrFDAqX+OoyRlmAWcYQRLhecBl93TxznN/yVHeBwI7ApmFCaegIxS2DInckzLy+zso3NkfRlqag/aBiD6V6AcOOQJTwz20otBHcu2DaBkidzUiMMhqzDMl5SBWR2gCpAwOGj9lTNsk+JOyOnQ48A6oDmLFKqsWMT440HI8etoQ1gUslqSWxW0TaJaMIpqUbJVWdMl8OVzWlPlJkdMXsDN/wk63YxCjzPx 0uNtxzkM 053qqtRST13YwALEMUZxDMgyxt/4uRroKDPq2jk9ZtM+PsYtprj4OGQLufI0UvF7tYx0g3lcpsbpDsMqlveeRVGMSZgNucjLZgkDX+K/1HOW2ebD5PMgtlk/S4uxAQXUob+RtXZtNn/xEJzzyeszXrOMdlkeleLmih0XkefHrUaUIyCVjtuWzh+NtYH7Ius1cdn/elh7+CpxbPOBLTdSn9r/p1nDdqRsCy1G+DScTc0izNLkYjjOAVfNTc6oyeMZVYW4YoNkf8RctENp7zymliYmGWxwpdcpObKZfyWCM5gRK2Tq8TYhzGqzz0C/IBNlzYGsiOShj/tAhrLz535OmsfDyn4DQvJEMev6YomlNCmknGfXkbhDMSGTli+/O3lLJd11cfpBC1ri77fx5Sfns0dQia5IyM/CC6aPNc9/IDWy5ojOADg+skCXPAOHcAWNUN2PPQorpRxGNC+14x3odGGRssBakTUEFwOmXs0dxH34Fr7gA+fyLJbP4Mp1nrWtriceWyOxHaR66ekk0lOqjHTdpcfd/oqlOfb0+gVUlxXmcOpbBUxmZVk7x4A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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; }