From patchwork Tue May 30 15:49:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13260562 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 1F2C9C77B73 for ; Tue, 30 May 2023 15:50:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D16C6900015; Tue, 30 May 2023 11:50:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC434900005; Tue, 30 May 2023 11:50:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3DC7900015; Tue, 30 May 2023 11:50:19 -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 9C539900005 for ; Tue, 30 May 2023 11:50:19 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 66BD01A0294 for ; Tue, 30 May 2023 15:50:19 +0000 (UTC) X-FDA: 80847358158.12.31BFA25 Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by imf10.hostedemail.com (Postfix) with ESMTP id F0540C0023 for ; Tue, 30 May 2023 15:50:16 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=qyQ2od5k; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf10.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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685461817; 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=coh5CBUvVZIC7R6lhSdYV3LoxqSD+fY+F1rkUy818H4=; b=8op8nZMi64qzYWCfe1rqiZD/RcEYCKvoTiTHQHBlB+JKQ8kzvqt5/FaGIsWk4noeixr4H4 uaD8+1M/7JNf7WSEaaH4oH9up9uW9ZhmLcbOZHqafMj61Qwr++slBsbIpAI/ltta3MJ8Oy Y7sUqvTm5mVflmykL7S+jO1eb90jpaY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=qyQ2od5k; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf10.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" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685461817; a=rsa-sha256; cv=none; b=BSN9PgDWPaw7KgdsBOWDgFEMIJO6og2fz+vbfN7lRXcuw5SKDOwreScqK4w2pALH0LomA+ IDcKZyIBIMxPsZ7D14NOKIrXRP3v2+nHwws7oXXWP0f6OhvAmoa2iyLN9wjisAVRAqFCIX BqQzY/79gMylIg+PP6nBLjYh9ZNnWJo= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1685461817; x=1716997817; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KgD+R+FU9CwRmwQAVm8lMGGwTIZNIyKz56pAeZ5nm90=; b=qyQ2od5kBNEp88da12RB3b3yQgaEjqEkUo2MMsupMv94MeXaTFuaG3Dn 0WeaEkd8wlKFS7e5KduWhy0xy/mUVivukpixN0nHgG9Pi6toMolM9TcBt 2Mw8zlTf2gU2xUecd26i+Ke0CaeiD7FWxJfmWRDcXTrq/3+d80H9cOGkD jMogxOzjjfdAK+8AMkCrumWfOFwbKBMosOW9nqx6+anHRmaOihGgN3MYV qAlQRGPq26vHhgRbMG5IdsbGUI65KJct9sp4OIpiHylO2TDhzpSzzGQN7 EvgtYtW4Q5bf4ZsBwdn0f8ucVe+BFSIdd15viHgt5o1h8hqfoITDjBNJD A==; X-IronPort-AV: E=Sophos;i="6.00,204,1681142400"; d="scan'208";a="231905756" 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:15 +0800 IronPort-SDR: ttbEKiv4NBl+fJxNR2lfC49YfbJpgCMu0XqY9oFJz0/ZAEH9BJxcxyJnwL5Lq1KzLbO27QqQWV JLRKtGu08KbncKbHys3hViGjnaodDPH7VYfcD04o163JXzMd3SnjtCkidO6sOATyZNtJiozevq r21z5MWsunVds1Izk3KCXK7EJ7SQSlNiPB9tizZvle3Ldr3TTgr9OXu6KiRccJrZZWJ6G0G1On uiiojfl5FMH1eaKgUAuOEwPjKeBDcV0ddPaLrI6o5nueoC35kXsdmto621LE3maTxsS8XMCtMc 9jM= 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:27 -0700 IronPort-SDR: 7c9W4va7M7i7mOYdzqZM8x7PuIzd8bUXS81kk72ffccwZ6ZkU4gnwE7FR84LvLjYB86fEAuYwt cXn5GwLOtz5LieaQs84gdIlp6RO2hZOK/Ic6UwD4MNGrVkqvJ5LsygmJvgCDU0mJKU4+2g9Rib NOa0IbGiRr60yWN5pk4jtqYmp4DsQOvrRO9O0wvUsb0lo8oWhw/bmV6Xf7GGSKfY/bdv8SGb7j X21UMdAublIFCrvsHnUfL3ViWaZJVFO/anGXJGxTYW7s2jPCdwz49/iJqACLwkL9I9X1q4xZdH KrA= 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:12 -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 15/20] md: raid1: check if adding pages to resync bio fails Date: Tue, 30 May 2023 08:49:18 -0700 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: F0540C0023 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ig319rwn63uh4h38pjtu4w38wd7p3ncf X-HE-Tag: 1685461816-538730 X-HE-Meta: U2FsdGVkX1/iV/9QsJASXNt2pRywzvgIXVVnXbq+5MVfUCZe6m07sdbVSwWwaQ1DEc+jgJwt2SCXI1Lfpr60AwwkvgFQFUD1CyZfgAO9PCsaS3w5ARGkn2hcqnxGv5uVjYkiWHjOJsNwk6u6E2GN7+tN3e9tR31nn5PyUYUmcadowXNRXCrEpdTgJWYQEj6kn5cP5Aed4CT5VTjKzpXuWO6XElSiZ89j1kJvRZ8Ulr/m5lvarHP75mI7iIDFPkAkQd0ROIrwe1ITtIiMu9/md4RXZ1HYjz3rL2Yp+cDPGXnoxUUVie7Civd9Q0oBYQTrN9fMiysc0fOYoTl4yci2lHezr78x5xPp/bff1YfBwSQGize6kwgMvpPKden53I/ERFAWYwStn08Wd0PeuuIbw47PKXboycYarNut27+eojL1aAYiUoYoQvPLUj98uiedsH4wjwJgu0zwMx7P7z63M9NQaLnRzrFe2JfB5cD4+gzKgT2T4GWK3zznvQAK4A08MTB0rJUKMGaAkbrQ/0pedmkIhaUXL3kkBGgD5jHKNDXkClLFcFqVG3Vb9YynfNI94tvqmYTDizxi+r0tpgmcJ0Qvp00htF/G51pARWY+oDH+FLVYucs1bGAGPuKaxDEhKv41ePZU2IxWc9a+uH6OLZl3O64h81qWq7yWg08ipjX53Kz6yS5euY8t5gDN9YkyKvcWtXNN76pJSXSL7hELdW7hLqtx7X2BUyOewEF7PlJ/UxMKUjFj4EKneUvR2L+rXdSbkf2IKAbpVoLEOBB3Z76bIVss1eqLpXESMzk+yrY+evfIPRSPta0xqZX7UlaPXBNreuEiTOm2to80+I7t3OsqaXBXsPPdZtve6Wlc8zYMJ3fiFoFXjxbjBsk7kp3XT6/IakVDp72yoK9D3DsgmB4Vm3qtefYLPhcTGLcA29ru90Q9llOIN0wwvb6tLHQC2/2F8WMZW6j95gvaLlS s5wCHwIJ ItC0JAs2uUXQeuhprB2a8zYhC2SuRNG0JbSNO12wvhMqhBO6wXW8lWGr3L/kzJadSwg75G4DkYgB8BsO56A/JN02tNeDUbZqvI9cWQvsviapI2fPDsZXLHMF+4Lj5qO9T0Jdihjnia+IVEYByBbHBmtslSRAw3eywg9W9E5BwbCPvsVGE9WQ0jk+yCCumO6ru5nRp5Xk9JdMzNnUxbTBPhnl7TCR4cU1Oa9JqrgnnYsmPaI1YsCFyncf2JPpEgHShtUCB9mcCG7CvTKGYAWzwikVxv9geIbXLLycjhUc2gtqs95vwWx0N6DOAJA3xDId0w4CzNASS5ZGT9KM1UmGXodYeYUqozae7e2MniYCNMc0J5Vb6oXRIUbcXeAfQaQXCFFMisQnalw00hh5chH33HfYK+5dccle1jvO0 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. 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;