From patchwork Wed Mar 29 17:06:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13192967 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 5D408C761AF for ; Wed, 29 Mar 2023 17:07:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED2FC28000B; Wed, 29 Mar 2023 13:07:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5C25280001; Wed, 29 Mar 2023 13:07:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD5A328000B; Wed, 29 Mar 2023 13:07:15 -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 B9A2A280001 for ; Wed, 29 Mar 2023 13:07:15 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 95E8FC0B8F for ; Wed, 29 Mar 2023 17:07:15 +0000 (UTC) X-FDA: 80622566430.14.3679CB9 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by imf21.hostedemail.com (Postfix) with ESMTP id 613E81C002A for ; Wed, 29 Mar 2023 17:07:13 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=Yr1xDxNL; spf=pass (imf21.hostedemail.com: domain of "prvs=445a3f1bb=johannes.thumshirn@wdc.com" designates 216.71.154.45 as permitted sender) smtp.mailfrom="prvs=445a3f1bb=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=1680109633; 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=upu32c8Yqy1t899K4t0IfOcHUkkaZO+LrWd5EvSYkRw=; b=EuplyVrgnTGu/7NbBeryh5DxcEh+pKUY/cLZuc1LCHXM6fMdH6WtAgWu4RywP1JhP1O9kI oYYDBw4folManJ7KarJEpkiXrhlW3hFTufCLRHLQOr2OiuRt/NOUeC/H1BGQg/C75ch9ps ctez7GLqRQKlbI8GXTcG6j2taN38sm8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=Yr1xDxNL; spf=pass (imf21.hostedemail.com: domain of "prvs=445a3f1bb=johannes.thumshirn@wdc.com" designates 216.71.154.45 as permitted sender) smtp.mailfrom="prvs=445a3f1bb=johannes.thumshirn@wdc.com"; dmarc=pass (policy=quarantine) header.from=wdc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680109633; a=rsa-sha256; cv=none; b=B42o3Hib+FnYSR80263SBjvjFFJWJkwkbYFhwkmSCIJ/9ihgJWiiW0hFZCWT9SDbr/nACP GeyLZ7PEwQVqJN7+r4X8L9qWFE+H0BWAP2Bkl/HdS8Wu5v9JJ7kb4/o02S+62BBkiwLFRO AHVmSxbePZiHCDqGJP3SRl7UqaslGic= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1680109633; x=1711645633; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=813zYQzJ3ygRpxAxwRlfdubSOcWGUy1xvUxQHtIWz2U=; b=Yr1xDxNL/woJd+YGSKL7n751e0sUkh6SULnqPto1geuEjdUpSmn2zXFM BP2e8edXcwK2AXZAsW/ru9pNMjuekID3gbVJaUMpQoCLCAo0BBlTnO6DE aihlx3BsDowyRwAMzUrwvxanol8qhz5d6T49QigBS1m2WNP7OBk3NSwzG 7klunoVeYT2WO5/HETvKfOdqn6tDc52SWi5eFOy7GsRlG/vszQMPS1EW+ zZEWsiYZo3UKJvPOZv+KU2FcBgih7X26do265LVakqoDQnoUWlnRMwydX Yc481bGElYP7z06O+BI8lJT11odtfXpqU6zomCSEAyU1uSkncnzTAdl+W Q==; X-IronPort-AV: E=Sophos;i="5.98,301,1673884800"; d="scan'208";a="226807116" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 30 Mar 2023 01:07:12 +0800 IronPort-SDR: SwCVCaAuw8bqa5z6KUm7ITR6KeoplEsfMxPC39upsyuKONvczjMP3qn6dpe/a9JSxTORh32G5O ez0lYTltH0Q+oyrTOELYVpYBc4Ppyz/i6fVPKlDU6Q8ek3KiyAkXtd9wUKH64hJwNGzt3isoNI pQl9mHKW7NJuxxUzBWM7nZaddiWttuTuL7C1FK8roRHS+4hp3ySfGyFJLBr5XE3JRPawShyt49 nww6RVyLWz3J9T903VHFI9za2d+pzDgRVKANeNrQT1g8W1L3b/Jg1jcbUaZKqEfsSMaPaxqjUn ky8= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 29 Mar 2023 09:23:21 -0700 IronPort-SDR: 5x6F8sxMltI4WaB27lEorTzv/W+x0JlN7rg04JjPfd38UU2ZZm/8DVpEHZF7Dz1SymcLD61OdU pMAulltziCw14vrFFK29xsFqr89kB9UbrC7cwH7R1RI8Lt7mmLGDYyj8PgO4p5chUbgRB50fDX pEWQG9uo914V+cwk1EfVh6hsltWKfNnh9Gqxgm0AGxlxSe7pa8UIAv+zE9lP4gByUZGpAjJ+IZ Lyi/Xsr9WvBwip9Y4KMe0trG46KV0zl+LFfsw1hbin01REWR95Nk66NcjalZz84eqJSVFLmHCh l0Q= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip01.wdc.com with ESMTP; 29 Mar 2023 10:07:11 -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 , David Sterba , linux-btrfs@vger.kernel.org, Johannes Thumshirn Subject: [PATCH 18/19] dm-crypt: check if adding pages to clone bio fails Date: Wed, 29 Mar 2023 10:06:04 -0700 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 613E81C002A X-Stat-Signature: dqxjthdsskmwrogpf1b6jdqszzw59kjg X-Rspam-User: X-HE-Tag: 1680109633-739314 X-HE-Meta: U2FsdGVkX19Dm9irgQU35nbMa+ei7OHsurzdx7BmbFUWbwGE+tzQlW7jJglMVhx1SJahC114PEhfHueCNi42PQuTtwnQl9wOev4x0gSf5Wx6P6kg0SLadtOxY4eykZvWHqxJRF/XhZkPyOKjLGsLnOf8LaITvvvn4OIRHxS8j7wxpgnMEzQd19F5dbsZ5SJbibUhK+ByS5wIEzLELhGE7+PdS3AgJ0XR4KRO2pg1nZF8oTO3rCgLLmm8t1RvtMSkfULDKmwEpEWlVjz8mf3IK/Avs+ygjW++Ct/wdZBgrD+u4bV2X0Sfakaa3MzJfwH76whrLccJeczk5nRC4k1GGvgaIQzBm6w4QWG5NvYCy9b11KWd7d4lOSmD5Qap+u5tWIX6aiFqNI4ua/NxvgAxuU0xQus1JoNuy+90GQ3dmIk2fWH3dz/7GzzydlReWdyZJHxDzr5/ABX5LeZrrpANBhq2sO/YctB0c7H/ItGQh3VnLj5TkAIf1bvqsj7lQTi6eqa44Et6GpYB48S+4f8ZDpQPYpJosSAW9317YebjtSyIx+jOF1khakRL/7dBNpnKi4nnbI5bLE8YsP/kIMG5VVrzSOcC02RnQz98pofXQ+3aOPwSKaBhY2o4PTgvTa6o3b+xKXPVlULjWrdWRphSlmDaBQQuWaL3UaJwtyxul4FmeW5VP1zLGcG/+dneaNvQl/YZuFPYlPRtbfuE/soc+OmQqCQ486Mvu107q3uM7SgjVbm8CFjf0EGBfJqdIEpAnLPbb8ygFKYKUSoFOoaTkUrO/m19nGtKzuGeekBAKUoDzUAd5VmOQcB1cv5ygD01f8cnX/oGyaak4lmn0TNN5OV1OPN2ekbmNfjaAkA9/AlH4NThqn89zieEZLGncvsNCgjZvRxs0rdjh6ZvD10E9Q1rLGmYTFN5FL30ZmVrqrf9mDHxbV5g5xrksBCN0i+osOhA9XlfHE0Cq2tBYMq c8/a3cKC XgZpQjrpTpjnzMfudfQlauDm1QilD1ttpVPj9GtO8DGQ069yZLDvdxZLZ1cbAqG+3ILdCULr1GqAIj4j7kU/+ukvo40gY+suj1ZDLfteOqdCW+IojeIp56HtuQ/vWJceZI8TihhfU8KydCcT8hegHwdWmcb8eRohvfv3hFwb4tyznS0GQlJCkmujKab8yeN1gKQeHoJiC1AvgRKvG0yylm9sWgCYb1hDtdZ9kfzpOTFL5g/04WNRKe4XLAPXwUSO9eXXletk2VYT2mBVeOjsilDZ6LVjSwmaMhYYcsjkrtVOGvlEXppLLXj1QOsoF9CYGD2eyxkt+HnbC01HCs25C3kB1Lqn3NJwCzZAE+aHF6BMRcixlzTos2fEOWQ== 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 bail out. 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; }