From patchwork Thu Mar 30 10:43:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13193876 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 2D844C761AF for ; Thu, 30 Mar 2023 10:45:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C56F96B0075; Thu, 30 Mar 2023 06:44:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0803280006; Thu, 30 Mar 2023 06:44:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A80CD280001; Thu, 30 Mar 2023 06:44:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 93CF86B0075 for ; Thu, 30 Mar 2023 06:44:59 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 71E251604D3 for ; Thu, 30 Mar 2023 10:44:59 +0000 (UTC) X-FDA: 80625231918.05.AA439D1 Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by imf13.hostedemail.com (Postfix) with ESMTP id 52BD52000E for ; Thu, 30 Mar 2023 10:44:57 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=pmb3YUMv; spf=pass (imf13.hostedemail.com: domain of "prvs=446327cdf=johannes.thumshirn@wdc.com" designates 216.71.153.141 as permitted sender) smtp.mailfrom="prvs=446327cdf=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=1680173097; 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=kWMGAv61+yAd1z5ZTGvDj+c4NVDTPEzDg6G5r4GL3cw=; b=Yhx8RSdmurAeciUr9rHUiRIYHIlhFjfIGcMu6PCbxXvEp19VLMB3tSMhS1RZVM0sjLcHej By3KZUz82ma19Q7K25Ozt8hJIpqnl2ehbGYEbXgh3wGql1o6zsmniAaTVZzefisHed5lYb PKrhK1dg5RP2XTdsfEX11WFqh2xTg3w= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=pmb3YUMv; spf=pass (imf13.hostedemail.com: domain of "prvs=446327cdf=johannes.thumshirn@wdc.com" designates 216.71.153.141 as permitted sender) smtp.mailfrom="prvs=446327cdf=johannes.thumshirn@wdc.com"; dmarc=pass (policy=quarantine) header.from=wdc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680173097; a=rsa-sha256; cv=none; b=dqaghlxtwsKtTy5wYRF/tSXKAbDEiLL3izD1Zn+UQnPpm5Ket4WADPO6W7UJH+Bpnq3q/O btfzRw3deKgSObXs3qZiObQRmOu0Xf9ZoCK+TNNYcJRPRDT6GGGoE7hTld0m0WNuAKVQ4c 3MqypJJmktr7wjHwxNPI2w5Oyqv0eHM= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1680173097; x=1711709097; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x03Tj5t21oFBp5hacmwnIhr612M3UR5L9WbzmUXqvTI=; b=pmb3YUMvMzVaUGKESeDAaV9FWA+dCIXeEclmhPZb+61aHoVRy5H6157t +OdfQBNrE+zda8F6c4hg3lzQcj9tcuq+ldhGe9r2/DZs52d6LwjPt91If PSQwb9eS4hwFX1gcpTFMyY70dcm+WJR6GcooVbxEbW8pSE5y8nCHrJ+RK wdlfQrDlgduEmlZf++pytvh5LzntIo2Hsr+NuPgOOBnMbplStvI35ciC7 ftYooDN+dZN1sJ/Sj02RacnwDA9ZFqitylAmAc8xhG59mBi2U08P2lUff TuhufRY/7BEj0HTGEQJKKfUCdP5dU0jkpVfihQ6TuFfcRa44CBecKMdPM A==; X-IronPort-AV: E=Sophos;i="5.98,303,1673884800"; d="scan'208";a="231854000" 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 Mar 2023 18:44:56 +0800 IronPort-SDR: ziZLZ7TSbyhxviyOv7W6PTvmP/SKkd/GdT7btaCW9ISAYQl/02oUa0RDguuD+ssqQI+MT13OxO b8SXEOBIYRjRp6YNhfFf3mvwoS4E7JakL+zAzFTVZC52Vxg+70iEUglHTwBV2PPJYRDiZFbwxz wkl+c1B9bhW1FeLoYP4tSe2i/knaMWAshmlKLLp/t97RzJSnq+0t+SwwYGiYYMXF0ChMF6bloZ I/IoPo6+vQd2zquQrIZIXeZwO5ZxrhC09miFEVvXxzp+BAD5V8j1y+eVAW77hrOVa/jkDgn+jJ zM8= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 Mar 2023 02:55:23 -0700 IronPort-SDR: 8tspoTXpxzHmClJsQZ5bC1hIVYMWR7fxHmL7Ag12bGN2b1vX5dZznqIk1xwQtM6kCQBYt4ri9+ uDLHirIHJ+4DA1NFYYbUnI8BA/QPlErIYOwpzv98UE2BAm7hitWSquPo0TfsDDIyCATLOL07Nu HLS4fBI0QUHTKCNPkR12ymqUtn6Ain+2OW6y6kseY1SYoKAuFCRZt7zXjgTS1iH20DB1vpnG2p B++q/+YMWpsASXZesODVp5hf2KtcEe8sIoFQNuEb+V8X1xKBHnSJ33ZRqIMSCLLhRGlFncgf4R lH8= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip01.wdc.com with ESMTP; 30 Mar 2023 03:44:54 -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 , Damien Le Moal Subject: [PATCH v2 17/19] md: raid1: check if adding pages to resync bio fails Date: Thu, 30 Mar 2023 03:43:59 -0700 Message-Id: <8b8a3bb2db8c5183ef36c1810f2ac776ac526327.1680172791.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 52BD52000E X-Stat-Signature: sfcj1zseyjb5gw6nc57x7g8c46ercfp3 X-Rspam-User: X-HE-Tag: 1680173097-102061 X-HE-Meta: U2FsdGVkX19D/rOMeFjI4DHfs7cI5xC5A6+3FgzCL2r4h3KMCbf1Nz84cmYUqGgGMIVDr5wK14FySbBw+Uzs9gwcpoOWU9ngzzRIXtW1oMgR5VSDn3SlzEBs7QEqMCWi9KAEgZ9IC/DfYfKe/oSCRwKOYFIm35hJHsX62+xGEMROmdDeD717zzHUeMGttG3nVquLsM7UQBHSbcbcwzwLUkftSauHIKK6jC/k/YVj5Iwh+xrwtrAWX6vhXViSuUAgNGOmHN2/pwObhuL5rrB4587zoa7Ukrn+1DNWuq7FjxgoaR5NRWambSwETi03pUs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: 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 resync bio fails and if bail out. As the comment above suggests this cannot happen, WARN if it actually happens. This way we can mark bio_add_pages as __must_check. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien Le Moal --- drivers/md/raid1-10.c | 7 ++++++- drivers/md/raid10.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index e61f6cad4e08..c21b6c168751 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -105,7 +105,12 @@ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp, * won't fail because the vec table is big * enough to hold all these pages */ - bio_add_page(bio, page, len, 0); + if (WARN_ON(!bio_add_page(bio, page, len, 0))) { + bio->bi_status = BLK_STS_RESOURCE; + bio_endio(bio); + return; + } + size -= len; } while (idx++ < RESYNC_PAGES && size > 0); } diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 6c66357f92f5..5682dba52fd3 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3808,7 +3808,11 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, * won't fail because the vec table is big enough * to hold all these pages */ - bio_add_page(bio, page, len, 0); + if (WARN_ON(!bio_add_page(bio, page, len, 0))) { + bio->bi_status = BLK_STS_RESOURCE; + bio_endio(bio); + goto giveup; + } } nr_sectors += len>>9; sector_nr += len>>9; @@ -4989,7 +4993,11 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, * won't fail because the vec table is big enough * to hold all these pages */ - bio_add_page(bio, page, len, 0); + if (WARN_ON(!bio_add_page(bio, page, len, 0))) { + bio->bi_status = BLK_STS_RESOURCE; + bio_endio(bio); + return sectors_done; /* XXX: is this correct? */ + } } sector_nr += len >> 9; nr_sectors += len >> 9;