From patchwork Wed Mar 29 17:06:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 13192966 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 09983C6FD18 for ; Wed, 29 Mar 2023 17:07:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 906B428000A; Wed, 29 Mar 2023 13:07:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8428B280001; Wed, 29 Mar 2023 13:07:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BBB728000A; Wed, 29 Mar 2023 13:07:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5513F280001 for ; Wed, 29 Mar 2023 13:07:12 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 04C6FAC327 for ; Wed, 29 Mar 2023 17:07:11 +0000 (UTC) X-FDA: 80622566304.08.0347A87 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by imf21.hostedemail.com (Postfix) with ESMTP id D42361C002B for ; Wed, 29 Mar 2023 17:07:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=ZIrosxpG; spf=pass (imf21.hostedemail.com: domain of "prvs=445a3f1bb=johannes.thumshirn@wdc.com" designates 216.71.154.45 as permitted sender) smtp.mailfrom="prvs=445a3f1bb=johannes.thumshirn@wdc.com"; dmarc=pass (policy=quarantine) header.from=wdc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680109630; 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=BpRyH3T+b0hPPGGNCaeUc0CsD3++4ChCfoIiS/mbSiI=; b=ypiYYuvas7g2Q/RaQOlyIRQzD3seeGI7DSUafwS7S3wMtlHFRAfyhvl6sNl6K9A+MCADZ+ yD4/TUiQTsDWYbcGnP19tEfz4jtkQNceDPfJjUWIPirkRSg6eoYvp9glve9tx+3JvDPNBN 2EScuZQJo6ToYqKJFKJEZCawPVfJsFc= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=wdc.com header.s=dkim.wdc.com header.b=ZIrosxpG; spf=pass (imf21.hostedemail.com: domain of "prvs=445a3f1bb=johannes.thumshirn@wdc.com" designates 216.71.154.45 as permitted sender) smtp.mailfrom="prvs=445a3f1bb=johannes.thumshirn@wdc.com"; dmarc=pass (policy=quarantine) header.from=wdc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680109630; a=rsa-sha256; cv=none; b=vx4EzkO6lig5uflixw8us5YEM+nFEObn7RZUsuP3t5T2jEYn+QXtBX8x3VpZYys+Rt0H1E Jl11yASQ7Ta3xz5MsPNyZk9p+RRZocVWMP+yeCpa7Z143YatRvt5yLVA1eYxa9pOXeaivq tapPx2+/cYWUpWLns4v65y8c9Fqx9NY= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1680109629; x=1711645629; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I1IOtKJu7Qm2q7N0lw4Ylfd8zAyg7sJl8PUDn+a8a0Q=; b=ZIrosxpGG7V5WkgkT5DqWcZVQyJFRK7chxbgT8bC7CgOVtNtu8lWSq4W MSoRZJ4cx0+NIfk/O09nYoWU+YhbGhryswF2I4W6IYdOgisZqmrE5s5dG onH+xMe+RBBlfCblZbIA88dcIyxf761apdzqMvz5g9yAIw1IasDeeesYa Qf1EClgN3XFVw1cgm+WSdnkk3p2bdqwEDZOl32Xnt0TwemRGqD+HKfgpW 4rKNqpQV7BZvInMA4fzycYmV6c6YijrDUBOAYWLHq0Rkejp151nJnljca uoviX8IKM3dj4FJHWzRAPp/KYTL860zNkRsQZK3gFMRpKiYMJt7jjfKCo g==; X-IronPort-AV: E=Sophos;i="5.98,301,1673884800"; d="scan'208";a="226807106" 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; 30 Mar 2023 01:07:09 +0800 IronPort-SDR: XUrHDAOl+hVDwOhm/UdyQmgt7MOB5bvbRY0w7gaIc4PtiKEMq7HNTQg2AtPSLfjlgSt5y8/VCx fhGWXBIoTSeJzZNEjdMH3T4K2lOmOb+OSWN6atrT4KqWIxW8dCqUkatmrnuPPNC1JJ8rtCuQbE eU2vE9exIfREON5wV7BRTtDB1YXGb7pFDa09X42/G2bz6SHgvFgD28ujEGsEdwKnCODJ8l9pfs LQ1dOKT+1hiZmvoSEteB4jKACeRBqzb6QGCzr1cA4qPVr4WLYvcXfvFc9U8e4/0k2RP47VRUe4 HYA= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 29 Mar 2023 09:23:18 -0700 IronPort-SDR: viCEK69jTCbLVPYfSPHd/6CBJALlqph49HjUR1colbGaK0Lgbfrebvo8dwmNEmOHMHTZRkfRQB vvHWoJpYznlCku1pvW+JJdGG7HzrUkK08/8VC9+32lQr+nLMcEMoNPch20WVqgI3us1Vxa+4Ca C6Ko1isbeJ080GTeYV4qNaRBsBV8XLQ6lMr+xyFq9eqWcHMYCbmZbt6NVCkNrT5F3zDoUBT4ZW fFd3cyh6qwWEcmkuDYxsFiuAvwvdEKoHMo6Gz1nS4Cl/UXPxkpMxZvew6C33popOLndwg3upAA xww= WDCIronportException: Internal Received: from unknown (HELO redsun91.ssa.fujisawa.hgst.com) ([10.149.66.72]) by uls-op-cesaip01.wdc.com with ESMTP; 29 Mar 2023 10:07:08 -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 , David Sterba , linux-btrfs@vger.kernel.org, Johannes Thumshirn Subject: [PATCH 17/19] md: raid1: check if adding pages to resync bio fails Date: Wed, 29 Mar 2023 10:06:03 -0700 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D42361C002B X-Stat-Signature: m3tsucoymizua6167zknhtoy89ed3ffb X-Rspam-User: X-HE-Tag: 1680109629-263853 X-HE-Meta: U2FsdGVkX1+n6y6FqSaWepIGlLFGR+QW+jVSeHSpIhd/5vN8jI3n9Tf830gSsuqrA9zV8OYdwZilwxFiB5wL9vUu5VPE8a+SUF+M1aK6LM326DBDw9rqwPNrMaujGpdySPlGszbiTJ78va4m4NpY/7sRaBDK5QFDsNHi3J+K++AfoU0HRcAl6WlUdZsQxYpIGsoLQZJxUVPZNkiEAmroBLA1/8mLMRTOxoq5STvFRifin3Fx8FWCMuC0h4T2Ot889Y7pj5Pg0A1g+yEVLj2k79gQmZmLvj9A4eflWZdiy7IHw+6LjRCk18PkmdJ09x9UofmZxiz8FUd+7Im2K48HQ2l39JF6Hd7WldU6jYjX4AFdpRc81FdKsru96fUC0h0ssfolyeiawHSP8k4G0lQJsaL7g/VnG+Fo1/6PZnAs/1baGAHycwNbVlI9aCltaVA40Gh7zTws4RwiUIDlHc2MyN5MoCJumbUkrTv3cLmd/h+8YuAhqQOC8YtCFkUyDwrUo3pFCFaSoNUiJ6Wr+kNTIquGRDn62dGQB83NBgNgGrUzZcJmGAVwp5333/2DVCaSC7cJa1B6YCotPJwde82e25WL3HWt4rOC2SUVMZaCNjPZ6cXmjmq9I4G5meJKYz3SULpPharMdJEuOmAAS/2gnY3huvgVBU9H/vx+Pa8XNLEkpuwiuwhCI7/y1ZzTC+bxGj6WvrqEbjinZTmEPTitgBZz+IIzdjjj+qwWP1mUjGLiBEovAiO3Oc8NMZHQhDECtopjZ2DhsXdK1J9C63N8Vt9CSpryVyTzKtUYsQf2L3al3qywyFnf8sIi6PHedE9FH21jXu7jdI81oR5wY3WW9vHjKP0xdl8/H87wHH6KHRq4HPwfjs4R1NXwDDeUA2priRjbQkcrYfOOeXackM81sMD4APpQIrEzbuR9p0K0rL0hCHS5Sraa4aYHpQug2l8Dfht7Q5FqzXI/ll4atpD 19ZyhzCC GrsKvQQetWvMttPIhB9VUbxBjvFe5M8osk2CHj54dXEkVsOfqCKujuYSeCU3E/XWpf9d1n4XFXFbDNsO8b0ntIcs75P3lO+bNKdWJpddm8cM90NrUGVjIronTH8aKUvTu/x0QNVd8AUE68ZzpMfT3fk5hwN6+Gf0N0VPuP5/qMhUq4brGqWHpDXM2wWPGYD0kDQgoUG6aFmO9W0N8IDwdaPk7BgSOf8G8k5gImCKhAMRnrCLNopFUF9hei6OSsaZ3MnCkIh6L4R2J+O4BMUcpv8NIf0Iu2F9uLqeUG3yVUNH1R0wTrnszS9ntNI16rRHGWNcm+IooHF5TaQh87Ns75mpMZlJfrY2aEDHNqpPvQ44PXRe+lOKd1uS7KQ== 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. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien Le Moal --- drivers/md/raid1-10.c | 7 ++++++- drivers/md/raid10.c | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index e61f6cad4e08..c21b6c168751 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -105,7 +105,12 @@ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp, * 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..5682dba52fd3 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3808,7 +3808,11 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, * 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; @@ -4989,7 +4993,11 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, * 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; /* XXX: is this correct? */ + } } sector_nr += len >> 9; nr_sectors += len >> 9;