Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp282768pxk; Thu, 1 Oct 2020 02:11:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxyY1xL9Y7YweBIlsETt+OKYqyTcqBbNDPkCQmaST/VdGZrlzkKz7RNB/Km8XFMOs9YCkr X-Received: by 2002:a50:ab86:: with SMTP id u6mr5519909edc.158.1601543467108; Thu, 01 Oct 2020 02:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601543467; cv=none; d=google.com; s=arc-20160816; b=NJsQj5o8L1jfa0YCoWkW9tFdnw8+Z9jkhxX7OBAmHWwspTADFcVrD3YYkPhJdFS8Yg ngH1JwKUfGX17J4CtCuy0cSmkHcBCnhwg7Uv4umgb2T/VDQ6EgKBwNZmMrG+M4AHQQCi emDlFDk6FF6T6RvQLSmEw1qWtxW4MOovMbjR+cfkZtN9yp1T1czVrXp9HQIXapOPbV8O /x0mvONLwxq3kF09fjywIZczg0J9W4nMg0KtvHwgQuttzQPSp6fQlEW05fhau7mDLGr/ XUdCA38usFeBwA+g0r5w2d6wJg6hHZ5EOnOTXfCCtmbnCoaYQSQUeFLNXCHkM7KuuZ+r rlMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=Q5av8GozIvireVYdt9G10nUQZ3K+jVy5r2SwPzklt+0=; b=XjJM+mEjVjQNoeGtnpFEj+qGSGFsE8dm4xZ4EldfiJFqxtRqla/Lx/pfOpQv5y1JJz cH1bNMnCMaJG8Dxf2U90HMBL8M7EIAnZ4pRIl+dyynKAWfGobzibkKDbAu88pS0LmrFZ qBE9YqelqiAx25jbg50yiV9hNS1twEFmtp8CHJvD9yO3LpoLtuEuGV6s5Jw34ZNMfkKN oC+qo/uqUzfXIdKNR2bfBwQtcGZSbkIt7idB0Ch8q6PWUydySLLIKaUzm94yhDsEu4DN 3PlNDFpu3wBCfEHXs6aQbycGZsjNJPUI/3aI19fQ3LUGyov9BLJtTG3X9uVFRf1Kr17t U9lQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ha21si2987377ejb.147.2020.10.01.02.10.43; Thu, 01 Oct 2020 02:11:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731661AbgJAJHY (ORCPT + 99 others); Thu, 1 Oct 2020 05:07:24 -0400 Received: from mga05.intel.com ([192.55.52.43]:17532 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbgJAJHY (ORCPT ); Thu, 1 Oct 2020 05:07:24 -0400 IronPort-SDR: eJgSfV6cm6EhjIjjLHH6HVrqLAiMom05acmijyT5nOo1XBOAnU444D9GI5xldZaEOU24Khqngo z3th1fNhTXwg== X-IronPort-AV: E=McAfee;i="6000,8403,9760"; a="247406051" X-IronPort-AV: E=Sophos;i="5.77,323,1596524400"; d="scan'208";a="247406051" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2020 02:07:23 -0700 IronPort-SDR: LHJfdaouM04KujBSY6KQ55RXm2gWd0ZNryOEbWrYQOsPPMckGkmnD790J5IXK8EMHXf53CDT9k P+rsss8dSYVQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,323,1596524400"; d="scan'208";a="458048812" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.190]) ([10.237.72.190]) by orsmga004.jf.intel.com with ESMTP; 01 Oct 2020 02:07:20 -0700 Subject: Re: [PATCH v3] mmc: core: don't set limits.discard_granularity as 0 To: Vicente Bergas , Coly Li Cc: linux-mmc@vger.kernel.org, Linux Kernel Mailing List , linux-block@vger.kernel.org, Ulf Hansson References: <20201001071824.24995-1-colyli@suse.de> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: Date: Thu, 1 Oct 2020 12:06:31 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/10/20 11:38 am, Vicente Bergas wrote: > 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=--) >> pc : __blkdev_issue_discard+0x200/0x294 >> lr : __blkdev_issue_discard+0x54/0x294 >> sp : ffff800011dd3b10 >> x29: ffff800011dd3b10 x28: 0000000000000000 x27: ffff800011dd3cc4 x26: ffff800011dd3e18 x25: 000000000004e69b x24: 0000000000000c40 x23: ffff0000f1deaaf0 x22: ffff0000f2849200 x21: 00000000002734d8 x20: 0000000000000008 x19: 0000000000000000 x18: 0000000000000000 x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 x14: 0000000000000394 x13: 0000000000000000 x12: 0000000000000000 x11: 0000000000000000 x10: 00000000000008b0 x9 : ffff800011dd3cb0 x8 : 000000000004e69b x7 : 0000000000000000 x6 : ffff0000f1926400 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 discard 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? Very low I would hope, but that is no reason not to have backups :-) > 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_queue *q, >> q->limits.discard_granularity = card->pref_erase << 9; >> /* granularity must not be greater than max. discard */ >> if (card->pref_erase > max_discard) >> - q->limits.discard_granularity = 0; >> + q->limits.discard_granularity = SECTOR_SIZE; >> if (mmc_can_secure_erase_trim(card)) >> blk_queue_flag_set(QUEUE_FLAG_SECERASE, q); >> } >> -- >> 2.26.2 >>