From patchwork Tue May 2 10:19:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13229214 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 9F002C77B7E for ; Tue, 2 May 2023 18:02:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BB906B0072; Tue, 2 May 2023 14:02:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 344A56B0075; Tue, 2 May 2023 14:02:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C0FE6B007B; Tue, 2 May 2023 14:02:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0782A6B0072 for ; Tue, 2 May 2023 14:02:15 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9BE571615F2 for ; Tue, 2 May 2023 18:02:14 +0000 (UTC) X-FDA: 80746084188.10.E465AEE Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by imf05.hostedemail.com (Postfix) with ESMTP id 75133101671 for ; Tue, 2 May 2023 13:19:22 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=LWpiLqFs; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf05.hostedemail.com: domain of "prvs=479dded8d=johannes.thumshirn@wdc.com" designates 68.232.141.245 as permitted sender) smtp.mailfrom="prvs=479dded8d=johannes.thumshirn@wdc.com" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1683033587; 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=NgNLaHU9QWlESCBVKUtXudFIcgaF0fvH8qy0QANXYag=; b=ZG8C5Tj1bdtznF5cgDkEYt5iX8Tst6KF6Ya9Rp88Tw/s/+GdeM3uEOwsn974Fos4wK3Xl+ b20WYd1Uf0qwtBQGloV80I8rWuYDrj0w/sQQJyPoDSlNPAYzbE4jDUGFeeaYLlWOomQG3f 67TRtpuMoasMjMl0DYqqdRsuT5PfHj8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=LWpiLqFs; dmarc=pass (policy=quarantine) header.from=wdc.com; spf=pass (imf05.hostedemail.com: domain of "prvs=479dded8d=johannes.thumshirn@wdc.com" designates 68.232.141.245 as permitted sender) smtp.mailfrom="prvs=479dded8d=johannes.thumshirn@wdc.com" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1683033587; a=rsa-sha256; cv=none; b=Owmi89kQQ4zZpfgEWWenxAGF96Yrnkvov3kOPsjcghi4GhhFN3mKIuahVI8un/LffKeTye EBDD1I45bq6w5sLJVSVJr3PggABR1RufoyuquVDaPJn5yGbLaFf2MHib4CwY6jE/iUAQuE o/iy6BrpJFKUQN36KF3NVgsB2Bb6+aU= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1683033588; x=1714569588; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sbko2e75SNzKYCeOJLmxzwzkVRoxsgBH9ZlWCz9oYps=; b=LWpiLqFsdbSe7rQIY0qipj9HdXN0dQZCzSdkfg6OXPpDOx0yTqmgaNMK gZK8Uex2gS5nr2OutzlhbJsebvgANGBOeIoiYqONWU3e3vfUgaTk0HYqA TKWQ5BAt4CpBI9xtPb5sKSumHXw2UjehfhEWdUMC/a0PMAsaq2zjDalrM 8TOFMTC7HHvh7u5WWuB2XXGszRcrBjDkMNboInpwK+6tiB3y2OQKpxnWo Us7BC5TW5Z1XWPST7h8qqBMNnkDWSzoQ6nwJnuvnwwrnv3yMYdNTQkctw N/J3ebz2Nf170uzPqATeVs0CSKsc0wH+sXsQysh53vzksOwEEyT7sAuW/ g==; X-IronPort-AV: E=Sophos;i="5.99,243,1677513600"; d="scan'208";a="341747214" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 May 2023 18:21:45 +0800 IronPort-SDR: He+GrAOQ3HgRlzVqoF//s024/7AIGA7e3uJ6yd046s2kU1fkwttWgNjaKbbMf+jhHSOEwNRro4 Dhvc9+uORVJr7BoJCcR/i8Jkkf6HOMOvvv3aPI7zGB3y7CNF1OBkzqW+rx5oEKJU7JNIeTz9ZD y4uVHA2tgCQK9C7DGFq1/gIdnQVQ7nXKShj1WSjO+qBLFkE0KM2Hzd+74ZU1+Fyw4V0wI4Kex5 1rGkSRHw9cRKyID9JlJKCY0DzMD0JISh6uuooq6HMKmkOYSEW1unb4VuyWVTDrR9vcZUQLzM3w bRY= 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; 02 May 2023 02:31:32 -0700 IronPort-SDR: ZWr6Qm7aWZaY8bdOiwef1PvSCYtgS9U9pquupOCJUQGWN9visATuWUPqvCvOMfvdDLIKZAhW8J 8PvGJ51TwreVCGTmty9sPSqI6NH5c9sZK7RjKgSCX/HDyjXRo/PbJcwapaM/ecHhWIXqz7Kl8U jgHztRbeeu58xdyiqpFqsVBRJgUjSHLJlzeswv16TnR3VZpldJyULjW+gWhIkfd2QZoJCL1ndd 3CxfOoIKDBYHgQDbb+Rc/apQ3FCRJszz/CpBb5cAqd5m4klOwv27bN++AJvOZeHo32NNrFKhtY YR4= WDCIronportException: Internal Received: from myd008205.ad.shared (HELO localhost.localdomain) ([10.225.1.100]) by uls-op-cesaip02.wdc.com with ESMTP; 02 May 2023 03:21:41 -0700 From: Johannes Thumshirn To: "axboe @ kernel . dk" Cc: agruenba@redhat.com, cluster-devel@redhat.com, damien.lemoal@wdc.com, dm-devel@redhat.com, hare@suse.de, hch@lst.de, jfs-discussion@lists.sourceforge.net, kch@nvidia.com, linux-block@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, Johannes Thumshirn , Damien Le Moal Subject: [PATCH v5 15/20] md: raid1: check if adding pages to resync bio fails Date: Tue, 2 May 2023 12:19:29 +0200 Message-Id: <20230502101934.24901-16-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230502101934.24901-1-johannes.thumshirn@wdc.com> References: <20230502101934.24901-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 X-Stat-Signature: tueihcazwtmk6rw359nd8u16ufdjccjd X-Rspam-User: X-Rspamd-Queue-Id: 75133101671 X-Rspamd-Server: rspam07 X-HE-Tag: 1683033562-137780 X-HE-Meta: U2FsdGVkX19zX2RAF3S61wTJfjLIB99n5myEiwS2+Z6CWqmRQg9N9e5DHyM4rfb/DDV4h4p8gpFIjs8lCBfI8/NJMAkHeJR+9WlE13/kzG94VomfaguqQnowy+J4056ygBRha0oVm2/23R8pA/VMBcsCZFx9O7wXn8F92PGxRlNwhg3u+PnpDPiDYeLOqkBjEWLhtkMUAD4EPa8RS3r6GY1fKU3lpG7UA8eR7w5qhrOcR4WJdirmcYk2uIeKbue3jxqm/mi6kkvPsKnBcaq3S2qyf2j9ZZyi39PV2K9+bMm5+HBREnZtPL2gHEW7GEDuMjGpnaXhoTFZRjGJ37X/PNTx5s4+c1JwcbMnvH4QyeIbVcZBOcGULrX08AW6phkNZoeSd6XrMmiRFhCyOgkrXQPl1SLn1tbpxhQ0gS9GUM6Yv1oa9pbwNVl7HnXYoIWA3BZ8161WMcNfp164GC24ofymzFYgO6h/7DNib2Axn8Z2Jtsphh/Kh1JpdOckyixZisLlix5zsgaBQTvXxMdv7oKspjGamdCZaoR19CUWonxv2ACTtJe6y56imlB/FiZ46J99Xq75LuK2/IKywjryP0VN9dVGNv6LqqBYye55rJzcuoSsGPobZGg76cqG2pGJTk1UfnRjEUqYC8d0T3mNPBkFoqKCMctQYCoorL7e4WCV4y91QOQb8SPtl2zaCTm57/3rYChBNHwcKrfPuMQAbKEvFIYwl+1m5/8049zvRFg6HDv3swSTfoviGwXK2edoncwF3f6YHz6laH3LQqDZDslcTaVQZlCRJrU5bPN6yK1MEWkvs4x1uc6c0za+2flMMK5oZULNQANzmq+1YM/TRZx/08ZyT2iNcyaZacH4p18iIITEGSaEJJvHNe9Ht+9KEtslum0i8f53bkASbGeqJko1GbD2kA9//wDrjgDPq7cJhuVgLrtT55sJJuOJlOF5mCjmSOx8+0J1xPCnt7V 4d2DPB+k P9bww8fKT0rAE3sAuvgZu2WVQnTvLM4T70V3dq+rkjb5DsB6HCklZ0i/1My08iflkeO2+kXuDK+EbaBZ2zRrCcCENhiwCkAognfoxnHv92nou982+D5x2dp3D4kheUBL4h/3+//FdGOnFgZ1E5g+T+PT6QOWmNyrcPeB8eWrVQPbATJmQ0P9eWWxo/g== 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;