From patchwork Wed Apr 19 14:09:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13216887 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 B66B0C77B75 for ; Wed, 19 Apr 2023 14:11:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B328490000F; Wed, 19 Apr 2023 10:11:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A950C900007; Wed, 19 Apr 2023 10:11:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 90F9A90000F; Wed, 19 Apr 2023 10:11:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6D690900007 for ; Wed, 19 Apr 2023 10:11:00 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 356D5160171 for ; Wed, 19 Apr 2023 14:11:00 +0000 (UTC) X-FDA: 80698327080.25.51BB02D Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by imf30.hostedemail.com (Postfix) with ESMTP id 18DC080012 for ; Wed, 19 Apr 2023 14:10:57 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf30.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.221.54 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=1681913458; 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=C0hLQVWAy93GtM7oc6TpMOtkbIMql7YOXfxv+ovXyBI=; b=0HuJug44moPVXhOGWK7oeEcX09Z7e3ryhhMYLtTKGNOu3mG4F8n9AwW0iMnpBE5uOZfilk ag4HgDZQ80jBIXe3Lqe5Mr28N154eLQPq42W8dezwvm1fsCQ9JCAop6ZpS/qcuO617zXBw vBcbnbR96C/i43fNACowcp+EBMM9N9Q= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none); spf=pass (imf30.hostedemail.com: domain of morbidrsa@gmail.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=morbidrsa@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681913458; a=rsa-sha256; cv=none; b=dGY/ux0QO9qZz5pd4KRd7y8sAysQ28ge6XQA6iZsKVz2XFTlWVfpTrMTFoF1m85HZWDVzx 5FevekhjuIM07wonw55NdZFUl1PpzLyMavYU57n5gsoz+ex3x9XulrwrJLMmVxhvUzZbw6 LccnnqQC+g0uz2J2DUvrD6qwFeXTbkk= Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-2fe3fb8e2f7so703059f8f.0 for ; Wed, 19 Apr 2023 07:10:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681913457; x=1684505457; 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=C0hLQVWAy93GtM7oc6TpMOtkbIMql7YOXfxv+ovXyBI=; b=LKtRs68TwmfiEXFcb8UYvhBT6AQ0oxPloCKvnL0Pv/HA5F+poePAroEfe3HdEc6DVZ YOVxWl9hYyoSdLKqPPn+V7hvY5Lc6ItLC1I3JovGJzKMNSmlj9cBKZq5LEXcMKdzZHgS NM1dJfAdEK9KXJEFK50CppJ3A9Pl8dXmSIbK+k7j3B5pMIwUfp5FoIxZaBOHun7aF4da Bp7ibn5MEKmvjEVg/8CLet+7mv2ihG8rX6qJ4Q1J+wXCXX52Ki5cBcM7U9edhsKMUOZI 7dCe/uskKlGpVCiMaClAolKzOGUWQgBcJe+AKDxG0eoSIHqb4/MMY/sCc4m60OK9Fr8s N2uA== X-Gm-Message-State: AAQBX9flCKqWxGAh/TdAFPWgmqU+L6eXJMMxw7zGcH9FxNAlPWhV25c/ 3dZm+LMaej7eQeWjehhX+q4= X-Google-Smtp-Source: AKy350aVLE+txxcZm9LeX2yItutcTFI6YYsrFgCoIWHLD8EDS9H+yj3niCnWRjhD3VeCviDrTQZ6vw== X-Received: by 2002:a05:6000:1a47:b0:2ce:d84d:388f with SMTP id t7-20020a0560001a4700b002ced84d388fmr5447194wry.40.1681913456733; Wed, 19 Apr 2023 07:10:56 -0700 (PDT) Received: from localhost.localdomain (aftr-62-216-205-204.dynamic.mnet-online.de. [62.216.205.204]) by smtp.googlemail.com with ESMTPSA id q17-20020a5d61d1000000b002faaa9a1721sm7612089wrv.58.2023.04.19.07.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 07:10:56 -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 v3 17/19] md: raid1: check if adding pages to resync bio fails Date: Wed, 19 Apr 2023 16:09:27 +0200 Message-Id: <20230419140929.5924-18-jth@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230419140929.5924-1-jth@kernel.org> References: <20230419140929.5924-1-jth@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 18DC080012 X-Stat-Signature: 4mh4zz4wwmsqzew8w16j1yahjfq7chnn X-HE-Tag: 1681913457-592529 X-HE-Meta: U2FsdGVkX1+Mw16xvV3Y46HwON1WUgywKhF018BFjkx2mfCfEZqDrYhtPX0N7jyVh+IKxGlscOmlimMF8CunWw8oKsPRfrgNp54QyxLWj+0JFE3eraXXzDk2kCwFBJLnlXk1lnMPVQbahc3E3H5qc8/NBujI/JI4GT7yaC0N6itCn4ZVKorMHFfp9utKyFKkHgSqC6dgyZJmbmeJebU8pK2ocYiWqEsAieLFMuzPwDK2my3fNbcN/yKJn+mu3cotUZtewKtn0mmjtl8VqxX6YW3JIontpiJMAHqgCiPBntnV82GpTjRObY/kkb4tCA8CgB2a9XsqePMTiYQbmDoiyRWIhv7lMQzoiRJCTVDw+5TWmxBHb8lLQs09RldENNgZPbeRe/tLIqH8AVnApJX0iG3SB4OHt/zdE85/rL66ltqkTWQrRxjUUEOyE9ZssGLR7bFWttCSgKT4ac/0kyZXD/PjXj4bap/rkk/Z5YpkR666FtgkF8EWBdxlWmqW+qB1zaixlEwwGo4FB7cDA6ItV7J3QenS1xrIOiA6REUHqTKmNITeTMicm3cKWjpXfCjw7WCH5D211TOYgTMF2e7up4ykDyrzk4IAyj2wtSJCPnZUOSVPjqStMsbmx72/ZUUyh/83i9xDDxYFezjsFdNOGh0HUh3iUCLdF1gd84EjnqQi7ueVpDpDQhWAh3KOPccEzj5NcZ7n4vlejaEMooaYo1uIULvQtcLxjcrfp42Pf69rrp2/T5MgV04HiT3XNyPld92jfPnoQbElVETrZjJ4V9KN4sXB2ySECWnvILhivdor0v8qU7HJu8p5J1ri//C5m4dh8SCAAd4lvVcTRl5Sm5w1zgNB+xSmt5r4zG2HmBUEiTlcKE68FUEXDy7/OZrJmflXQ4aXmAPL0XXIqfjbluAetEln7Bv7ig2bDys6FZdmu6DYxfX5n/U0Qfu2B0HfKnKHL2PnrCFH0lRdl/l mEC7T+56 olvlUZpq5w6pei/IJYdYy6HIv/I9MtPWXdrB2GdfUffXyar/hCMoacYgq1hzzo8lN6EziDQftK/6V6XP21znhkrcNwww1MqhXKvU9p0BpC6gmww4wNN+aed3jKS42rrsXxQhmmp0+e5AVp533FOIbjLjKaat163zNTH7o+DP045d7iGflFl109alQxtpcZuaqSkThYER/qI2ISSsYX4NdzzD7fUAPcRa99LAqFiqz68dGuDPjVrbfUVOySeYOWBe9y6o91kVjwbdzyidpxHouMaE8IfZKokU0XlhoS3CWZLCDimBECQPUU3C+z7CgSuW4MZlrxUyTVA/rJSi+0+aZoq4VGyOsKIUUXgRpKnzEE40E2NFoaZsGD63gl5SBJkEVohwTLfgomwcBTGc+ToZg9O67/TNjWV8caB7yv3T7ogo+nfgXIOOWA4h+RrUscRRcuQOuZNo20YLJC6ELmupiPLuHsVVvK6GCtvkUxUIOAzee16ShvcTmfP0moy7XrDj+glU7AwlTKfTcbMi0U25LKvmFStFYJUvP0otm1ldCWRpQiOpMNaYIZd+vkA== 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;