From patchwork Wed May 31 11:50:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13262053 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 1AC6BC7EE2F for ; Wed, 31 May 2023 11:51:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB4256B007B; Wed, 31 May 2023 07:51:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A64616B0089; Wed, 31 May 2023 07:51:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DEB38E0002; Wed, 31 May 2023 07:51:40 -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 7FAC86B007B for ; Wed, 31 May 2023 07:51:40 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 58990AE490 for ; Wed, 31 May 2023 11:51:40 +0000 (UTC) X-FDA: 80850385560.01.6DD3CFB Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by imf10.hostedemail.com (Postfix) with ESMTP id 39A2AC0024 for ; Wed, 31 May 2023 11:51:38 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=aMQ9y8SP; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf10.hostedemail.com: domain of "prvs=508ef2a02=johannes.thumshirn@wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=508ef2a02=johannes.thumshirn@wdc.com" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685533898; 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=FHRiaNGH8GsP9cu8M1JwbyzXVk8Y8PZLkCnUdeYJEAw=; b=Y4sql++lD6JjIbmet69SjZa8+iEu2zisjyCAGQg+x+n5e770p/yrlx9jm+b1JIbjeKZ8hK cioONQjQhZbm7fQLWPOegKmL1iPwxlmg5Z6K5agVhSZXX6hmKJM9yoip7/vo9na3L5Wfw0 HqwUTzqOywFdqGU4emedcYG+oNMxPhU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=aMQ9y8SP; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf10.hostedemail.com: domain of "prvs=508ef2a02=johannes.thumshirn@wdc.com" designates 216.71.154.42 as permitted sender) smtp.mailfrom="prvs=508ef2a02=johannes.thumshirn@wdc.com" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685533898; a=rsa-sha256; cv=none; b=BeSN6KPBFhN2QhG7yilioBDt/lgsK1+rdJkiBW3SXf/pbybzuWLHAVsUR3SOGfOpLjhIcg Kk5Jw2+yCag2iNTRlJBpFL/qWqrRj+Jl9CIk6xgHhPFMm9JV/EqkW0uqGBB1p3TLcRGmo+ I2gXCG0CGBSYqFeroguL+XZLk9XwYXo= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1685533898; x=1717069898; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6E0YSkUBZHvEVigQ1cP3fDbvdT5Seq5Rp2IoJ9HugPk=; b=aMQ9y8SPa2l21zcvmCfYEgrX5gFDWL+2lan1mbR211KN06SbMvji1Jyr zSsLNg+/l2keASOVm0rxxa5L6zp2UNsum5W1JU2+Cfmdb/qqtz8iMYZGV 7YOX0w0y5/248R5POF4xwNgYm76Pae9cmTFt4p0xr/YjigHTo+m5Bwi76 S80NdU/xRq7CKLaJYlbjvmsfCmivrWoNf7rtI3uKrZ/1uaTTl0i/hSSIL ONZgt8s5CxIBzN+xqaRy85QuP0unP+1c6A43Xde8eSGy5YAA74IU2PseV nbt13+N8yjGoaaJZbtXt7Oy0DzLd9Y4lLfyzf9DSAncKv1/Kto/QidSUQ Q==; X-IronPort-AV: E=Sophos;i="6.00,207,1681142400"; d="scan'208";a="230207478" 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; 31 May 2023 19:51:37 +0800 IronPort-SDR: CU2Nayw0gQfHU52EB7QC8/nTTPU3LqUOp8gpPfRxcR2p7mFI2wV6pxYXHHGNAaxKGEj1RPnZpS PJeLLDSKXV+2OhL187kuoKsTzgmfAj0eb1PaSL1i8PLDs+xX0M6Xw20XXhZKZTOW/EgAPgd4Xu PeBbCqibo8M+d8YUhfzOgrd3qN9TwuysYZwYklyWj0iqGS/J4TwNgu9ovl13w8F8RBu1p6dkB6 lK0dFLH/WcKp4+PP9PPZXmWWmLBsUtlMC/Xoqcrn7KBOVOzQympzV6kdEIFYEhcCttTVbirINZ Qig= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 31 May 2023 04:06:30 -0700 IronPort-SDR: dj9wdSmathvJ1jOI9aJAqtcU+ByV1jbR7k6k/UPOi9YViazTXsL8jm7ytyX8fRKf6g8on0Tw5c l8RC/N/qurdeB7sQNWHsX61rXiF6IyZIV6RgzzkT88Nv8OOVuY+L5Aad77sOASOny1yPabjYNl gfA4qWBFySa/pn1UC+0Ui4ujsIjkOFt5upt4p23k3JYTaHIYineLkqgSOpgReCb8j2J9o19Hi2 IsqVmYyiFwI3cXTnXxXq2BtR4lvT+jp7R2bqCuuxAAIFYdFWMXE7jRgd22L3cDz6QsfNcuAWwk Up8= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.6]) by uls-op-cesaip02.wdc.com with ESMTP; 31 May 2023 04:51:35 -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 , gouha7@uniontech.com, Johannes Thumshirn , Damien Le Moal Subject: [PATCH v7 15/20] md: raid1: check if adding pages to resync bio fails Date: Wed, 31 May 2023 04:50:38 -0700 Message-Id: <33aea4c271220dc9bcab58c4b7bec478c1511142.1685532726.git.johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 39A2AC0024 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: difa3p73p7r3bx79wtucwxijb6bib6dw X-HE-Tag: 1685533898-450443 X-HE-Meta: U2FsdGVkX18aRY5c5JY6iuWzLxVNbBzPW3WYUnnXDOCLL6yS3dM+LdCHokYrw3GZgSG4MWFnXzY3yootlfhwLon9lNdpztlgFiTQCedt7p4sOS1lyr7xbPG3c3gDMCIVHDYrfSOn16+ji85MWxSXePVcGb+VsUYa72ACfKI6gCS9IsHU2TdCz6EM7oasihzpZrjjwDxHXk1aKGPz1lcQScWDj4J2AqiEG2SGL8pLi4ypuqemvTXWEhggu8QOWy35x3cTT3hUZsAatl+9hBuscLDDvdhJ+Iis4qgTrztlg2VRMXSvKMLcQYSq99lB0K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i6EQQx7EnZ7mQX9NgHORNt7 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 resync bio fails and if bail out. As the comment above suggests this cannot happen, WARN if it actually happens. Technically __bio_add_pages() would be sufficient here, but asserting the pages actually get added to the bio is preferred. This way we can mark bio_add_pages as __must_check. Reviewed-by: Damien Le Moal Acked-by: Song Liu Signed-off-by: Johannes Thumshirn --- drivers/md/raid1-10.c | 11 ++++++----- drivers/md/raid10.c | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index e61f6cad4e08..cd349e69ed77 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -101,11 +101,12 @@ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp, struct page *page = resync_fetch_page(rp, idx); int len = min_t(int, size, PAGE_SIZE); - /* - * 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 4fcfcb350d2b..381c21f7fb06 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3819,11 +3819,11 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, for (bio= biolist ; bio ; bio=bio->bi_next) { struct resync_pages *rp = get_resync_pages(bio); page = resync_fetch_page(rp, page_idx); - /* - * 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; @@ -4997,11 +4997,11 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, if (len > PAGE_SIZE) len = PAGE_SIZE; for (bio = blist; bio ; bio = bio->bi_next) { - /* - * 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; + } } sector_nr += len >> 9; nr_sectors += len >> 9;