From patchwork Tue May 2 10:19:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13229209 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 65D0EC77B73 for ; Tue, 2 May 2023 17:53:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5CC16B007E; Tue, 2 May 2023 13:53:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE5596B0080; Tue, 2 May 2023 13:53:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5E776B0081; Tue, 2 May 2023 13:53:29 -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 A238E6B007E for ; Tue, 2 May 2023 13:53:29 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 75D10AEFFB for ; Tue, 2 May 2023 17:53:29 +0000 (UTC) X-FDA: 80746062138.11.868A30A Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by imf05.hostedemail.com (Postfix) with ESMTP id 20D93101687 for ; Tue, 2 May 2023 13:19:53 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=SvKjxrAL; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf05.hostedemail.com: domain of "prvs=479dded8d=johannes.thumshirn@wdc.com" designates 68.232.141.245 as permitted sender) smtp.mailfrom="prvs=479dded8d=johannes.thumshirn@wdc.com" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683033622; 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=A3Uxb7ToyZzCXpo6dytQ6jfGB5eFnK50HXW6JYeP39Q=; b=z7Q5KCXm1gmS3lNVK+B/Uu27G/L4szuQl3w/xlMbIpX2nTQbBEYCxNC5NP6Quo7NVQE9nA DlsdA6seArqBQTao58unaWWMUT/EVDRvCJAFGT1Qr7wkcCTWRpQJfukeOOLJcHTFGPEkmB MBApyLNv9o7z4dQjOZkDz6TGt8FrHCg= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=SvKjxrAL; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf05.hostedemail.com: domain of "prvs=479dded8d=johannes.thumshirn@wdc.com" designates 68.232.141.245 as permitted sender) smtp.mailfrom="prvs=479dded8d=johannes.thumshirn@wdc.com" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683033622; a=rsa-sha256; cv=none; b=fxRDcYQd8Nv0IzPLufsYcX60d3SxHOpkhq4s1OesI1BVXnfaBV6G8mAlrcH8oF6wvPmUTK nyZ3EtFvi8N/EmnR7nGlDJuqvCxat11ONkUfqzzZVl2jBFHTeknTs43MmomKgE0njYo4vZ Bj128FtrfgctrBBZWr32m+4xFkxpiGg= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1683033622; x=1714569622; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=V5SKzmXLiqYlN1FT56vogdtjTkaUplMsRNtsQa39yz4=; b=SvKjxrALszII4WRxX+ChsAFfeX78PCOyLeOh54vPI6kI43XKw9agwi25 aGZmw4GQIFgMTyjqVWLcOvibdMuTY8xfZrKYKFEjHukBUQRxqRuk/IxKc wIR83EZC5pvZQAfs8E8FEQ0CVNJydMTPrBPXChNvgYQ5OnBDzVH1QHuML o/iAgL3brb5tgL+/VNW8LZwcqwfYkcc+aHeFkoklcV8sLATJbWn6/8OOr wQaPgqSu+woPEQ0su4H40DKl+Mg5RiMHRp2Ot3/ubqhhyuo7kDs4WckTY x7f4lolXxGLk2jIlsjL4R+KdNKUDk9HNdQq+M9cBLZzC9geHQKOFN3eSc w==; X-IronPort-AV: E=Sophos;i="5.99,243,1677513600"; d="scan'208";a="341747221" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 May 2023 18:21:49 +0800 IronPort-SDR: 85viGowTjS2O3YT9HkEnj45k4Cp0HglTRBoD3utV7EK9UL73pCaePLORpIrI8J7WU5HUwwOTEk BciuAbwJhPz78iECwTChfNAQPNbC6fwn2IiZkgRpwa/0G9KvG76caase5tweenN/MPVexliin3 8Fy3f3VVeiEdEQmwAUPEiai2k/yu/wWT5L3s50JnZzIKMOQHFpsKdJLjYiGvjec8U/8GkglQkc gDKqlokLmbBb0+OjrSCpHycO52uxFQhVlwjn4Awg+FNbK4I8/hCNfsVPWd4OTEDgSaAwV0KAtQ fNs= 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; 02 May 2023 02:31:37 -0700 IronPort-SDR: h/+Uzz4d3DSZxkslqyyemyuLPtMI7jhBm8cQQC8WAsiGwmug14lleOQVx+xkHcNGsmIX7lpU55 87VMP+4tfW26aWu+a5oN3DVTq3PFVs2iF9WR+8oTmTwDIaFXmRGIznTUpQ4aZU0a4rymtj3WZj kk/AGz0dRlK1ZycoHqrgPH8iVANoXrBCJuUG9lP22ljDr/8WOx6RnsE9CFJXzzQSnh3bYujqEQ 6hczuVykrgqMnIl3wnx+DJrdhTydW+7Qj1cYcXsZMgrNIFeXRvMoDlU7CYgbRhYHjf2G0hJiZj X44= WDCIronportException: Internal Received: from myd008205.ad.shared (HELO localhost.localdomain) ([10.225.1.100]) by uls-op-cesaip02.wdc.com with ESMTP; 02 May 2023 03:21:46 -0700 From: Johannes Thumshirn To: "axboe @ kernel . dk" Cc: agruenba@redhat.com, cluster-devel@redhat.com, damien.lemoal@wdc.com, dm-devel@redhat.com, hare@suse.de, hch@lst.de, jfs-discussion@lists.sourceforge.net, kch@nvidia.com, linux-block@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, Johannes Thumshirn , Damien Le Moal Subject: [PATCH v5 16/20] dm-crypt: check if adding pages to clone bio fails Date: Tue, 2 May 2023 12:19:30 +0200 Message-Id: <20230502101934.24901-17-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230502101934.24901-1-johannes.thumshirn@wdc.com> References: <20230502101934.24901-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 X-Stat-Signature: 5q41ddfk4uxjb6fir65w79wxqrz4pggj X-Rspam-User: X-Rspamd-Queue-Id: 20D93101687 X-Rspamd-Server: rspam07 X-HE-Tag: 1683033593-135805 X-HE-Meta: U2FsdGVkX1/h5n6zY0PujXdUCC4rK++dM+64e5ANBQ/nCa7HXecwrsF59ud6Aw8pIEvCyo8ncaQOq/Hk623ZYEV4YyfixHpcvhxkckhGKSTmnX0RPg6FgPaJOKFBeJclDgp/gjwkTCc+uCeeSkHBcMdQvmFvGD9JcwT2rsydgyxPb/ki7GNg217Zfo5AMTe8GIlSDE0wvcIRdUgANih/PFT6j4MUNCMO40ooYMYT/iVPRfYUQP+FMw+oUEHd7TVZua+eB+Z4tG3wVWHSw3m8LmpeUMZ7ivmLr7UbpJ7cGVVjTpudYCki/evqFsCZbcTkpizmecBxEKSw1agT8CDliZ3V6GkcmNrFabwEtfRkDqBFOry87F9ylWuy8xclYwv0FqaM51LCkzJNLG/dbM/DU0gPLeZG4wUp4zrV3JXMDTndybNMZGhUqNeJucfxBjSuTi+aPsEI52axQDuAH/WzD5oDePYJx4TMWmBVZavMX+CVxYpvDKkT83Cwld96RqPvQTsAi2FpcQz+mVpKWbAtRxRgXLzmDOW2k2voki/1VOkZ2pkcNjUEaNG73lo12OCI8r19en6ijtUDRxLrtBN8MTLHkpQeYyk96NkB/XZOhkxF8RItxWSUOQeFKfc7zgBrrudWGlZKRyRVYGfsZ5JGeaGwU3h/rUnXlywtNx1xLvPcrVpgc27fy3ox9FRjtq2ieMOXNakUz5MjwgadPjtwnmJrpvJsVITThnTr3UwEMKpIwD8HEC92MgtwwZ/9QotNsMYxrANu8ieioF8jCBzGvZz1FErOhkbEUzRSRpziAxjKsuD1+gtBGEfBpUW3gOKd7CXxjP9PF8VrVecMkvrOdAOq9A/pbaVrUyIHPBAKNFsJhEOfLM3l78jM96ftXY4UJPcbMZofZcrAg08mS90c5q6FOw9NqrgBbJMeVYGmZd0HmBjjIwARWWLjcOEyDT4IUxgyNxHhG7OMgVM0mxb 9iPxkeTY zXT0tfL04bwUibJAj7nz3GuFO0baqPDHtFuZYJR58WM60nlcJLNXj/OdKRx/wbDj4RHy+D6Zp/WaH2L1P0YSjUdoZPe+iKgT+7VjNtMtivR2pN8bHC7JpLF57kp2mydi/e48/neDK8Lc1Zw6LBvyB0bN0VrI3XtPgvohC5uthP1TMVUozX1P0l0pY5Q== 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 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 8b47b913ee83..b234dc089cee 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; }