From patchwork Thu Apr 20 10:04:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13218306 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 8AFEDC77B73 for ; Thu, 20 Apr 2023 10:06:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26E7390000A; Thu, 20 Apr 2023 06:06:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21EF9900002; Thu, 20 Apr 2023 06:06:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E69B90000A; Thu, 20 Apr 2023 06:06:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 00462900002 for ; Thu, 20 Apr 2023 06:06:13 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C70B9400E9 for ; Thu, 20 Apr 2023 10:06:13 +0000 (UTC) X-FDA: 80701339026.26.0E266BD Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by imf04.hostedemail.com (Postfix) with ESMTP id E6B0F4001A for ; Thu, 20 Apr 2023 10:06:11 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf04.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.221.53 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681985172; 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; bh=NtU3y1Zr3yjzTsE4b676R+MqirB7TojNGzCXkCz9E5c=; b=75pir2HKUq/SfCgFfvQ2D+UfXKSDywo+JGsBa7Mgnpow1BkI8hzG50AFlLie/NpWIETco9 2jUQiiDrrksApdY4BYjcrzeGs+t4yus21Z7ZVX1U7mGnO+eL8rc1rsS6cpfESFl4uW3ZW9 ENbw/tJWM9vkGBsDY9YZkBxOcjVZfiE= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf04.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.221.53 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681985172; a=rsa-sha256; cv=none; b=iamDoZWDOBT523yKDPAnctYy1hwkbkzLS5w2Z9H6B7yIoXfcYsbLyYFkbPwzPO1GTE1LCW L2gQKRUhyfFmSDyV//Wr5C3f0W2NJYynVPtmeYVQLejxdG/wPkwv/dUntawNWcHz0lzwJE LgoWsbvW7iJTsL12cB77MyZ+3dto+Ls= Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-2fe3fb8e25fso287325f8f.0 for ; Thu, 20 Apr 2023 03:06:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681985170; x=1684577170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NtU3y1Zr3yjzTsE4b676R+MqirB7TojNGzCXkCz9E5c=; b=Ys1eWRQLfzJWqnlKkGUll/2Ow1dR8NVnbEMkY60mR7vVGiX6FP9btMs9kvd3QD2dF7 dzxjLXaTsMBw9dMd9rAqvWiWRu01WHuAYItDeRORJf5NjSSlzCVC8CnDTzS9QHy99bQ1 h0pSUJLw6981dPlVVxVy4LpGF2MkMYbyftolXRGKguOQXwrA60UMh84Ad5Ou/JBZyr/I e8+zoXgzKSXxKkwHGCUPCq/WNHFeX0JggiJrXmEHDPVz9G6q2bAFtqO3n3Ls+w7zVuG9 zBCOBOQnWETvxTXOg9dB4YCoJfVGA3rY/M+MaD2ytydL40ZtXNw5fALFz8GTp5nRMJdk ZUHA== X-Gm-Message-State: AAQBX9fsqL5yxSVI2ewDI3ErfIrYiFDJ0fJDYH9KWV2Cgej3lv1aFcQJ VukMT0Gq06mLR6T2KHHurwk= X-Google-Smtp-Source: AKy350Yf43FTKduuCP1kMcXqJDkEawnut9n4ItV54pfFrm9DNgw20nsuo8ykxVcEagPqAFCwlrvDXw== X-Received: by 2002:adf:f4d0:0:b0:2f7:e3aa:677a with SMTP id h16-20020adff4d0000000b002f7e3aa677amr912509wrp.46.1681985170733; Thu, 20 Apr 2023 03:06:10 -0700 (PDT) Received: from localhost.localdomain (aftr-62-216-205-208.dynamic.mnet-online.de. [62.216.205.208]) by smtp.googlemail.com with ESMTPSA id l11-20020a5d674b000000b0030276f42f08sm201410wrw.88.2023.04.20.03.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 03:06:10 -0700 (PDT) From: Johannes Thumshirn To: axboe@kernel.dk Cc: johannes.thumshirn@wdc.com, agruenba@redhat.com, cluster-devel@redhat.com, damien.lemoal@wdc.com, dm-devel@redhat.com, dsterba@suse.com, hare@suse.de, hch@lst.de, jfs-discussion@lists.sourceforge.net, kch@nvidia.com, linux-block@vger.kernel.org, linux-btrfs@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, Damien Le Moal Subject: [PATCH v4 17/22] md: raid1: check if adding pages to resync bio fails Date: Thu, 20 Apr 2023 12:04:56 +0200 Message-Id: <20230420100501.32981-18-jth@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230420100501.32981-1-jth@kernel.org> References: <20230420100501.32981-1-jth@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E6B0F4001A X-Rspam-User: X-Stat-Signature: e8mbms3x1o3kqizaeda65e1knp1iabsc X-HE-Tag: 1681985171-257464 X-HE-Meta: U2FsdGVkX1949ztYaHY2acczByjQ1BzBMxNabwMQZqcAwibAguqWOiZjwo1cfHXUxsdpmAXNK367lNThJGmkUcDOcwTbQtZk0W+Xnu/aR4MIzq5WdgeM1y7J9wavioFR4C/6qg3oN9u/nbQQrSYSHN/SpUJYg+/tLR+/2FcHSTK/vKRALKbIycblYKAM+78ryn8Cd0qsKJoxz3bteafpldJUwchYU881Igru0PKBPRDT6l/vnU/GUXPjhy/CorA4VcFZyowiZmvDOe6K564XSmzA1n0lJFvxrG6lNODJ3PKo1aKOXdu7mO62bJyRNsg0/mDBLwu3WTKJDa/Zs+BS7YeWuVewXFkqgoNC9b77myOEqeIN4/1GYacaI6MS4C05KTBenYqmVN293v9Fi3ZbkoiFfSikrxFtiFXTECUJxraykI2IwG0HX650/uVsH7zw8x6hUlwArRPeLiSCLKbbtfJt0pvtLzAoimNaGaHIeBmvGMgFjbpxKluQ4ClZvSgSuV+L/Vff3hOo+kwtnu03IinmOldsE4NmFJp7nyuJXpsENoSVldMSF9Wu3UkxaL/A07EOi6KC+20UbajYGLstg1h/TnIvsgnGWuLbZa5OcoBXjaPyVS8jUcTnL1oVclrEfkk51rfjnXO7aEGue8ssiFvk1I93b8/Xep8fIZmvSSkKypXImyofT+QSRwolG0Gv/K925lJ6W9hLG/D6KIB/OsoBELEuZ8wcP2YjKvetxvguYULFvR5e5tECtTZAwNie43S5IhRPaCLRN5hMdhCNLuSUZIGb162xP0H5dPYm1n8jgKiVT0c8TTPk5JrDq6Oqb8ZUvJEWY6PJomLCT9pKbI9OJ1S8JABz2VudVwOkMgOBSKkBMr9hbx7oqebu2Pl0cLHk7ESjWTTE5ILNQlU7/w1VirQpObKVOBerqzvzXHwKpAQNhQ+Yt934JPEn1nRnyffHzKhB/xIxck8rR0N wKgcMRlX jnSDXfXBvK/702pAhuxS8mTla7OeYPWb8DnhHbNPaSBjx9t4RNOmcb4/fzdtGMTUeQ1dgeRBiIQfscx5l3pArE5YoboChFQS7XCZ3Umh5CZrjqaSwEsP+FrPbjMmwogJmhAAFD4WoTJECPhpCy2hLwNTrQMxIssG1sfW07GbCiGAfTyUFz+5K/oOl9GmAGYsyK5Bc6Sej8ADVRRGol0pAyr6QkhaupAzlQB14hNZHji6HbfV2IT0mXzw83Okf24QkU+Fo3JGF0u/LQU7LS+aEP1U8tQwhrxC6fioe3QmeEu0CItue4A0tG0e5RegtHOj8vfMhFil2xM7WyNIppTIrff9QFeFPfCoT20CFZXIuyuYZUiYs0m7MJfdgrRjSdRfpvcj0OluUPLa150S5QOQCjjtGzeCpkrGXFanmzF2R3Ny3XRQKz5dks2CjoWtc3omnxca4yJEE4ruyKorEpB55h92b1GNWF/cX2BX6egAzFxkz4Tm9lLuDkbP+l2OssidHvxHVryLbdxUF7INlCH7nc/ItDZBKSXH9JTFOzG1fd+GEsIBaU5wUextw2C0FEvlCqlHY9z8K3Dr/JUk= 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: From: Johannes Thumshirn 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 Acked-by: Song Liu --- 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 6c66357f92f5..59e52cf01569 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3804,11 +3804,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; @@ -4985,11 +4985,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;