Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp723763rdf; Tue, 21 Nov 2023 15:01:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9pvYgT+f4ZgX1lLqLexTee5OLGXBrhVT8jWTu2JocQGmrmOkk7Gy8BkIg4ej6Cv5w4qDD X-Received: by 2002:a05:6830:2013:b0:6d6:528f:6548 with SMTP id e19-20020a056830201300b006d6528f6548mr920758otp.12.1700607709268; Tue, 21 Nov 2023 15:01:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700607709; cv=none; d=google.com; s=arc-20160816; b=LWaGkmWravjRMDPaxBckrOrjiZKkiINSJBCQTdXp0lknWWeszvVfJ5i6NMDcXFG7H8 vqQh5KPcGazaQ3hy50CwtYwln6GbPmAQcKBUWl4iW5dGtRPM5xJgS6BOz+Za3BbhqHfo HJkaRUTuQELTe7mFzHFhnvKVAAEKekHRw/fQLOCFi8lJUkUWTivkU89qH4OF3ayzmRSL inNYLXskeVnJTsmOWmhg3rhwZBiGs61+VcrFxUMtvAOFunwQ17hMCGI4fouZxNti3a1W j7aKOsooB1SExmfp3xkGigQiQeEFTUG+zGpjb5wp2dJe/4n6LCvcLXF0JB4yVoVUgf2D VPyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WMiZQe4g31F5qr6jjwP979bMRXaOgPFtQHvEYFVg3dE=; fh=O3efhQ8YRWF9SbJmSfBxu1sIGqKgzh1BE87bI7BiATg=; b=DHHiH2SriJBerho5L4MgcDdSSTwtIXlEoCe7ZdcyWAY0eAv34pH+A8AJnPI/133koo ijbIPiCOwk5GnxZVZspptzuFF49gpULqmJ0DNgqKt+fDBYsFi/AjRW99ytuq3alyoq8Z KbagE2aGglT+Pi5IedkR54/3N5CpaT7PRiXaU+Yvv+kvCCjBhbSfU/3srv0hLINk43C4 cPLJ4MSZ/0m81+CI8zyxyaXxzqvmenyaYd8BCOF2vOIPh6aJYQ6GpHk6Wak17j5czm8W DXm3E50On6ZhruBlivZvtQq81b3E/I4AZNzCAyjq3fgrXzhm3E6k7TRQzaJy7M3uR3zp h/ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SSb6iZKC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id v15-20020a056830090f00b006d7e8a26d93si591517ott.349.2023.11.21.15.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 15:01:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SSb6iZKC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 57A098087B61; Tue, 21 Nov 2023 15:01:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234739AbjKUXBM (ORCPT + 99 others); Tue, 21 Nov 2023 18:01:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbjKUXBK (ORCPT ); Tue, 21 Nov 2023 18:01:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3097191 for ; Tue, 21 Nov 2023 15:01:06 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 671D7C433C8; Tue, 21 Nov 2023 23:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700607666; bh=QAfrBafS2Xedk/FBg4PhLH+uYFOCkILDjpuxPhlJVkE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SSb6iZKC0i48lXMnjLAJ2ww+33n/jKVtodY28O7MO5TIR7EzKqfqI7zK0YiK4lTh0 7KLy50Z+JTrofssxAistPkMkJ1b+U8w+ldlsHfdjLO/mZEJh3xnIC0JbEJm8FyVh6p B1sx3u5xw5s9wcAOan/R9y2DbQID6uRzzxnd19Y9gZB1rp47OyLlAnQvd5GoZUxSD1 U7YtSA2k0zFe5ye58eB46HWRuq+ZYD17zdCyE19ME0m8e6kel23I4Y2ekEwZoiyGTM L3mEXFrmfd6mXFBx9c6MsYwnS4401p5jEvTVL/9RgI0lzxhFPuUiTi1HBYmo4viBRS Fs7/t3lGhjv5Q== Date: Tue, 21 Nov 2023 15:01:04 -0800 From: Eric Biggers To: Wu Bo Cc: Alasdair Kergon , Mike Snitzer , Mikulas Patocka , dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org, Wu Bo Subject: Re: [PATCH 2/2] dm verity: don't verity if readahead failed Message-ID: <20231121230104.GB2172@sol.localdomain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 21 Nov 2023 15:01:25 -0800 (PST) On Tue, Nov 21, 2023 at 01:55:29AM -0700, Wu Bo wrote: > We found an issue under Android OTA scenario that many BIOs have to do > FEC where the data under dm-verity is 100% complete and no corruption. > > Android OTA has many dm-block layers, from upper to lower: > dm-verity > dm-snapshot > dm-origin & dm-cow > dm-linear > ufs > > Dm tables have to change 2 times during Android OTA merging process. > When doing table change, the dm-snapshot will be suspended for a while. > During this interval, we found there are many readahead IOs are > submitted to dm_verity from filesystem. Then the kverity works are busy > doing FEC process which cost too much time to finish dm-verity IO. And > cause system stuck. > > We add some debug log and find that each readahead IO need around 10s to > finish when this situation occurred. Because here has a IO > amplification: > > dm-snapshot suspend > erofs_readahead // 300+ io is submitted > dm_submit_bio (dm_verity) > dm_submit_bio (dm_snapshot) > bio return EIO > bio got nothing, it's empty > verity_end_io > verity_verify_io > forloop range(0, io->n_blocks) // each io->nblocks ~= 20 > verity_fec_decode > fec_decode_rsb > fec_read_bufs > forloop range(0, v->fec->rsn) // v->fec->rsn = 253 > new_read > submit_bio (dm_snapshot) > end loop > end loop > dm-snapshot resume > > Readahead BIO got nothing during dm-snapshot suspended. So all of them > will do FEC. > Each readahead BIO need to do io->n_blocks ~= 20 times verify. > Each block need to do fec, and every block need to do v->fec->rsn = 253 > times read. > So during the suspend interval(~200ms), 300 readahead BIO make > 300*20*253 IOs on dm-snapshot. > > As readahead IO is not required by user space, and to fix this issue, > I think it would be better to pass it to upper layer to handle it. > > Signed-off-by: Wu Bo > --- > drivers/md/dm-verity-target.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c > index 42b2483eb08c..d242e50ec869 100644 > --- a/drivers/md/dm-verity-target.c > +++ b/drivers/md/dm-verity-target.c > @@ -668,7 +668,9 @@ static void verity_end_io(struct bio *bio) > > verity_fec_init_io(io); > if (bio->bi_status && > - (!verity_fec_is_enabled(io->v) || verity_is_system_shutting_down())) { > + (!verity_fec_is_enabled(io->v) || > + verity_is_system_shutting_down() || > + (bio->bi_opf & REQ_RAHEAD))) { > verity_finish_io(io, bio->bi_status); > return; > } Thanks, this seems reasonable to me. As with your previous patch: what commit introduced this issue? To me this looks like a longstanding issue, maybe dating back to the original addition of FEC support to dm-verity by commit a739ff3f543a ("dm verity: add support for forward error correction"); do you agree? Can you please add Fixes and "Cc stable" tags to your patch? Thanks! - Eric