Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp268230pxk; Thu, 1 Oct 2020 01:42:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdLcAqrbaSkon6BopfYmeJRNkNqSIV5fNhaneqwy1GNK0ByM9d30hBnQLKQ5GE0/0W0t4d X-Received: by 2002:aa7:cf96:: with SMTP id z22mr7240282edx.120.1601541753441; Thu, 01 Oct 2020 01:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601541753; cv=none; d=google.com; s=arc-20160816; b=tYJQbxuvaF7NiDw4POM+AvaSQvNlAF24l3TZkN6MIbR4jZ+VaJ7zcbTL8iuRqD7tBV ulMvBvDAH5vTDLCkP0/pYy9GIwHtrE34ywAR02UbRsPAV6ciGAwLdwNWbb76vUa9jyhS jdKjkekp3IS9QTyKqAK1Z5kbfG/AuiUUoTWWg3ECQ68t1yCedPn6vXHIIuC+YWXWdm9Y OdmlPdWhKq9JEUbJZTvRSB4g7hmwFPvaTfXmgBbjsuGTqAZkuxi9BjA58WfXBhkcSNIN qrW8UQPD3rL678af0d3f/5d3Jvw1nQx6h3bRN/v72KlKvXRsWYMlsgZ53L3mH8cKJcht LkEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ON+opjPHh020IQmczBcWo4ofg8g1dUfmPb5G/fCa/xM=; b=Ov2uYCCLgB5Dsi7N3izam6ISklV5cmpag9580d0+llszmxh+QOLMhDPBynwp/MFLfE WuMbs9h2GmC/KjpQ4O+TFLuyPOw5mc59mlbiEhiBYBQGHbQ58i8uE/gQVdGHvNWh8eRg Di4cc0pq21qWiUMJ5Wdf10cPyk4q2TWvm1E+PG98hdLdCizUrchiePXvgX2qn5V/Czj2 SXY4GWe6YyVr9wJG5QZmQV447hNQgnq7K2ejIuSr0+f1yVRJa1Ds5z8pr76GNeKuRks4 74dtSEEaBy0M1qSg1u8wBCgidnd9DFfROFU+T2XS1pAOrC8D/uqpA6pD2PIkzey9+hMJ ZD4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UxT+icRR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si3165094ejm.389.2020.10.01.01.42.10; Thu, 01 Oct 2020 01:42:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UxT+icRR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731611AbgJAIia (ORCPT + 99 others); Thu, 1 Oct 2020 04:38:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725892AbgJAIia (ORCPT ); Thu, 1 Oct 2020 04:38:30 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34D37C0613D0; Thu, 1 Oct 2020 01:38:30 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id t12so5314816ilh.3; Thu, 01 Oct 2020 01:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ON+opjPHh020IQmczBcWo4ofg8g1dUfmPb5G/fCa/xM=; b=UxT+icRRDjkJqTwowa+yksEbAFoaVgOcdX5i9ootPoFm8eByk2RqgID5LGYe4eDu+T 9LXj64mErLGO7AOnF1xcqEEZm1MnXZQ7jGrb+YFY91tXtjJT701jIWv6k6KNW9DEdScX c///UmuzY8emR42MbtkBvPP3MJeRHqTGtrRfdTKeiiMzM0MoAwuby/T+l3OU9w9WmBZR P/DilkKhwM73elyF+ptm4Ua8L7M951+8F/WI0FUJOy7ELDrUiYyZyZVSfWwreuvDmxJQ D0zdRWhhUQ3iQc17bzKO8U3RqgRinzFx/PEsDFJnCphHTBxu3MrcRtfI481Fhx//8CkD dzeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ON+opjPHh020IQmczBcWo4ofg8g1dUfmPb5G/fCa/xM=; b=iLvfe4mVySTqnlPMMB3G+eO04KyRia4Xc3baLh8QnPTQ0uEuP0M6IBypIBwsX6qFQB QnHtNCOfaijLzwmpx4P0qcezP7kXryQFzTPm2SOgJvC8PnCpsqddV8TA0JheSJHSptoN zAZ4cKcZBVh1Uml82LMuVWyUyAetII3+ekWUXLYENpXwBfTlDBjCqnt1lRp3KFuTPXwg Z2QI5NPQINsEuiFRfeMqfufr+r9UGXOp5sHkDKM+2FHaQcHCEJchDItNudSUp+pqsE9G QLA98JBpfacLsr6HgK/ZyYY/XPF8POHCvP8OdH0tDvHUASqnK+TfHEUrDue2KHh2qhGu RPYw== X-Gm-Message-State: AOAM533DmECNP/IxqCrfv9c6HfoklgcS6D/NbsNb/wCmf0Tn/Ua6uZjA fSC4jY2ii40T6DnjAP6JmieT5/F4IJqFSmDkLAQ= X-Received: by 2002:a92:aa8f:: with SMTP id p15mr1639564ill.100.1601541509515; Thu, 01 Oct 2020 01:38:29 -0700 (PDT) MIME-Version: 1.0 References: <20201001071824.24995-1-colyli@suse.de> In-Reply-To: <20201001071824.24995-1-colyli@suse.de> From: Vicente Bergas Date: Thu, 1 Oct 2020 10:38:18 +0200 Message-ID: Subject: Re: [PATCH v3] mmc: core: don't set limits.discard_granularity as 0 To: Coly Li , Adrian Hunter Cc: linux-mmc@vger.kernel.org, Linux Kernel Mailing List , linux-block@vger.kernel.org, Ulf Hansson Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 1, 2020 at 9:18 AM Coly Li wrote: > > In mmc_queue_setup_discard() the mmc driver queue's discard_granularity > might be set as 0 (when card->pref_erase > max_discard) while the mmc > device still declares to support discard operation. This is buggy and > triggered the following kernel warning message, > > WARNING: CPU: 0 PID: 135 at __blkdev_issue_discard+0x200/0x294 > CPU: 0 PID: 135 Comm: f2fs_discard-17 Not tainted 5.9.0-rc6 #1 > Hardware name: Google Kevin (DT) > pstate: 00000005 (nzcv daif -PAN -UAO BTYPE=3D--) > pc : __blkdev_issue_discard+0x200/0x294 > lr : __blkdev_issue_discard+0x54/0x294 > sp : ffff800011dd3b10 > x29: ffff800011dd3b10 x28: 0000000000000000 x27: ffff800011dd3cc4 x26: ff= ff800011dd3e18 x25: 000000000004e69b x24: 0000000000000c40 x23: ffff0000f1d= eaaf0 x22: ffff0000f2849200 x21: 00000000002734d8 x20: 0000000000000008 x19= : 0000000000000000 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000= 000000000 x15: 0000000000000000 x14: 0000000000000394 x13: 0000000000000000= x12: 0000000000000000 x11: 0000000000000000 x10: 00000000000008b0 x9 : fff= f800011dd3cb0 x8 : 000000000004e69b x7 : 0000000000000000 x6 : ffff0000f192= 6400 x5 : ffff0000f1940800 x4 : 0000000000000000 x3 : 0000000000000c40 x2 := 0000000000000008 x1 : 00000000002734d8 x0 : 0000000000000000 Call trace: > __blkdev_issue_discard+0x200/0x294 > __submit_discard_cmd+0x128/0x374 > __issue_discard_cmd_orderly+0x188/0x244 > __issue_discard_cmd+0x2e8/0x33c > issue_discard_thread+0xe8/0x2f0 > kthread+0x11c/0x120 > ret_from_fork+0x10/0x1c > ---[ end trace e4c8023d33dfe77a ]--- > > This patch fixes the issue by setting discard_granularity as SECTOR_SIZE > instead of 0 when (card->pref_erase > max_discard) is true. Now no more > complain from __blkdev_issue_discard() for the improper value of discard > granularity. > > This issue is exposed after commit b35fd7422c2f ("block: check queue's > limits.discard_granularity in __blkdev_issue_discard()"), a "Fixes:" tag > is also added for the commit to make sure people won't miss this patch > after applying the change of __blkdev_issue_discard(). > > Fixes: e056a1b5b67b ("mmc: queue: let host controllers specify maximum di= scard timeout") > Fixes: b35fd7422c2f ("block: check queue's limits.discard_granularity in = __blkdev_issue_discard()"). > Reported-by: Vicente Bergas Hi Coly, Adrian, would you like me to reply with a tested-by? before testing it: what are the chances of losing data? Regards, Vicente. > Signed-off-by: Coly Li > Acked-by: Adrian Hunter > Cc: Ulf Hansson > --- > Changelog, > v3, add Fixes tag for both commits. > v2, change commit id of the Fixes tag. > v1, initial version. > > drivers/mmc/core/queue.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c > index 6c022ef0f84d..350d0cc4ee62 100644 > --- a/drivers/mmc/core/queue.c > +++ b/drivers/mmc/core/queue.c > @@ -190,7 +190,7 @@ static void mmc_queue_setup_discard(struct request_qu= eue *q, > q->limits.discard_granularity =3D card->pref_erase << 9; > /* granularity must not be greater than max. discard */ > if (card->pref_erase > max_discard) > - q->limits.discard_granularity =3D 0; > + q->limits.discard_granularity =3D SECTOR_SIZE; > if (mmc_can_secure_erase_trim(card)) > blk_queue_flag_set(QUEUE_FLAG_SECERASE, q); > } > -- > 2.26.2 >