From patchwork Tue May 30 15:49:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13260563 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 1223CC77B7A for ; Tue, 30 May 2023 15:50:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8F71900016; Tue, 30 May 2023 11:50:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3E71900005; Tue, 30 May 2023 11:50:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A076C900016; Tue, 30 May 2023 11:50:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7E84A900005 for ; Tue, 30 May 2023 11:50:21 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2AD9E1A0252 for ; Tue, 30 May 2023 15:50:21 +0000 (UTC) X-FDA: 80847358242.25.2379752 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by imf17.hostedemail.com (Postfix) with ESMTP id 19E8D40016 for ; Tue, 30 May 2023 15:50:18 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=hSIo2sbc; spf=pass (imf17.hostedemail.com: domain of "prvs=507b913ec=johannes.thumshirn@wdc.com" designates 216.71.153.144 as permitted sender) smtp.mailfrom="prvs=507b913ec=johannes.thumshirn@wdc.com"; dmarc=pass (policy=quarantine) header.from=wdc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685461819; a=rsa-sha256; cv=none; b=cQfTMQ3e89ZtQE+EMKQ7Flttf8oVxWpONPdRyN6VvSxGoDaXrV6XHuoLEdXLcCEastZNsY kaK3g54HFfwEkTlm/QaYQv+bfQu+DiBr+nO20B3bg/hHtKus7/JIt9WI4Kg9pJSEO3uAVH 0n38uxVJQ5rTUu8HtzpZ3hytN/N7pfg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=hSIo2sbc; spf=pass (imf17.hostedemail.com: domain of "prvs=507b913ec=johannes.thumshirn@wdc.com" designates 216.71.153.144 as permitted sender) smtp.mailfrom="prvs=507b913ec=johannes.thumshirn@wdc.com"; dmarc=pass (policy=quarantine) header.from=wdc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685461819; 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:dkim-signature; bh=vIj6KpJJXGI4GjCHBbNFJm1+SIz5iVkLzC/I2Fd0ozs=; b=31iR6BwWmQOb6PucjfUGT++mPbj0lXTcEFA/JaaI95G30YCdTYzR2BvVxKNWIQbGFEdTfc uLVzHbYIsS1J1AZyq5Da5DFcW+Cg++EUMyeairsfwdKFXpN6fXSTw4kgw0B7dtMe4ruKiH zAiGp2cpayYZiI67HfC4A2yWVMHz+FM= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1685461819; x=1716997819; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C+NYxtWZcIKLiQW8aZvWShDgl/gtDFIUIUOTPRiObYM=; b=hSIo2sbcpYOrUNQzqel25PTYTKAmi4gAzLVjO1nQ3ZLfuYhfYcwOIQzn gdJc+c5mtY5hUxwC6A7K1gqL/UHT5DlYKPdgCC8xhBnvbTwP/3evUNslU UtXEmcSFEvsWcH4FOCGS6Zabz/HQJzlh1CXhciHb5qIHf++frU41zPvrD M2q+e27AFIcjoukUVYNhURUiUV5UP055410skWpuOb3Tv+rI4JhXokVKu AA4TvDgv1bO6S1YHsbrjpPSyHB7CjJXHdPkrI/lNHWS44ZlQmVllTU8Vg DWZAoJI2Lj9frV92Tk9ThPqkfcu6uoyc00VO5BAWCiMz8f4lU8L2HyePD w==; X-IronPort-AV: E=Sophos;i="6.00,204,1681142400"; d="scan'208";a="231905769" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 30 May 2023 23:50:18 +0800 IronPort-SDR: f4s5+Rv6NqbD4Lo+bf7LrBlu3vtGMViLxeBROHa+pLDoeChFmDWvGCR5sCsYTBtcPyD56Lw7x0 dOGlfh4HVV0Oal4rnkqQ6NuW/y87a2SGlS5eTQEhZS/uqMa5ms7JiCU+hapetE7j2cuHyA3Dn3 MfXenBKinnY+DLdLi/ijic68PPA4BUOOu+F4Kq+PFGbn4hAR2HfpN/QDcoSmCbHr98jMQLIDUE u4MEj4j33bVnhiMPcmHu6nF3UI8rzN2ICGPFhQhs6KcjGNu2NHSl14sNi7INj9aGTIudy3E4AE 3J0= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 May 2023 07:59:30 -0700 IronPort-SDR: nWMXgYPXj9My0dJwx11mPIKRe2pSzWz6O3nUVEtHmwd7YXnITNPMVp+01mOZjGN5zhcXbH+IdK m4NVW5MyTKxZspeJpQdq/5lcWtTCTrtHWknfnsfGCvolyx2j0ZqjEnJPHzs6IqRD93mSDPBKaJ W3wnvvvnGzwMhFNe3tC3vpLamIMSeTnweXnIJe6DaIylSDsi76tjZmEcCIggRMz2kCpsmYogzT umSo039ixODhCfl7GjDCN2dVBtWEhKpEVTPbeeTLYiBLVoeQNEC7m5EzM08Q+jnw67MjY23eAu xTo= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 30 May 2023 08:50:15 -0700 From: Johannes Thumshirn To: Jens Axboe Cc: Christoph Hellwig , Hannes Reinecke , Chaitanya Kulkarni , Damien Le Moal , Ming Lei , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, dm-devel@redhat.com, Song Liu , linux-raid@vger.kernel.org, Mike Snitzer , Matthew Wilcox , Dave Kleikamp , jfs-discussion@lists.sourceforge.net, cluster-devel@redhat.com, Bob Peterson , Andreas Gruenbacher , Mikulas Patocka , gouhao@uniontech.com, Johannes Thumshirn , Damien Le Moal Subject: [PATCH v6 16/20] dm-crypt: check if adding pages to clone bio fails Date: Tue, 30 May 2023 08:49:19 -0700 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 19E8D40016 X-Stat-Signature: j4bbuiyf3ajnqrch37trm8tsnbr1hcns X-Rspam-User: X-HE-Tag: 1685461818-42181 X-HE-Meta: U2FsdGVkX19wJ0dAUYsmZFEm8RS4mzuNqM7g2/JwenpjgmYSCrktXApmdA3RBJQiuSharE4ewCH4i9eO3pyEfjiT1gNv9tmQIW2TkkRsE239UJyQzGpEZ3AsqU9km1XPtRAIlWk46e/+ONhsTgiyelw9DjpVt8AlUqmGct47OY1m8S2VlhArUnMV4GstENNVrJumTT7jgUvTHS79+5q1XceDPc+n0nd6VWbHb/bHjLFjlYnft+bQr62+inXyaVrnltAleIhOwkHbnX7ekMQEO6e4PiiPeI7RDUPN+DnfBIRGogVy9rtnXifDMJhlmY3Y1rR8IzfSR7ekb5EmQ7YBDJGadT8Wjf2mgRSuTLsHf8kRx/tWLEq/BT6uwNdOqTOjoC/z5CItqHvozqT1yIl9ShyzEV6U+XXpgYEynSECfcnzMlXVvSJadwxZKo92gTPy2XC2Twy375Clbd/jmaHVSoWW7Ix9XE5E+l7HYEcRYy8ybvBNCD10DNLEsyv2sEAMb+I6dLOhREfWWofFAlfn933gqNFDaJ8qzlbCQovz/Q0ddqaHTVVEegC1td8DaZfmG+ZYBkcuGPskpdcpqybxFihdD9mvx7mlBSVYjVSCS+GQdfwv6Bcy+UeM3SLW5vk+oUDHhQkGTtLlQRkCnfwr/aFfYLgNvjfgVZHkgyDgsHKAOsbyUk0R+QZ6qHMfmFUe5ofwnUHQ0NZGD7JvFiH4nyivybVQOIknr5uLKy1hNQN8ZeNSmHJpgvWhZDdgJI8qa0m67f3df8qUEH9g06vZF8A3BxM2kw/iKqrkqVqjMGCEOvBLh2FrzpMdd69LF8r+/e5dsfD5q0w5bLDIa9O/638sz1+XWPkIZOatxax5AYbN4l3+l2Tb6SNcOHr/r09LerWjcNsoUmYAwpTJhJzSw/WJXqBt8bZUEUgeZhepwk6dh8js4fUFQPqg7AENbKq50JhPm7jEe3do4om3SB7 ncMYskaJ 6xI6hBDCWzuGehkwuOdSXdg/SOVcPb/IqGEiBbEMlrtlaP8ZhsjgrY1n1SDoYLKrQm9KkQPEamMd/vSuXBe8jIzU7CJVxPjSDciTNiyRdjKLTOQRh5OWfxWf/4YJMmG82fMg85D8xf1lL1ub/aqokr2z135eFxJwGKdQ85Q1EnD5RxsQhK4YOYaw4eGXenMKBN3W3bj6GmpbofF0EYRfzN58R9o00Valt5Byl03OySVeCuadvHsl0q03AgHeTlSl5KYp8I1lqYwZid7b5aJNHDmMvzw94BjPW91Y8KggcMEJDf2mvi6XyxHwQDPEeRkc+eL6g9BbOUPWfQtjfy4ubV5GJfSVTtVvImG5l 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: 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. Reviewed-by: Damien Le Moal Signed-off-by: Johannes Thumshirn --- drivers/md/dm-crypt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 8b47b913ee83..0dd231e61757 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -1693,7 +1693,10 @@ 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)) { + WARN_ONCE(1, "Adding page to bio failed\n"); + return NULL; + } remaining_size -= len; }