Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp308447pxk; Thu, 1 Oct 2020 03:01:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoZkPa2fLHAwY+B+VuS+2jwF4R4jc/4E3VWCn0nxnwN4Xf9wFqvttbSKze79nAVGVPFHQe X-Received: by 2002:a50:cbc7:: with SMTP id l7mr7349901edi.148.1601546499922; Thu, 01 Oct 2020 03:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601546499; cv=none; d=google.com; s=arc-20160816; b=Th3jskBi5AMcqbfGwKRnm2PAFgJDFK37HquilOrYT7k0KMLggv26cX5Z1H/nW/Sw6S cs3gHiGCOlJTQP2PHhEHIMDtzMauVOW5u6QJbP40838oY7g2LmTaAIdj7RUoEfegUKom OZX8owvb4HwotOXJ5vKGebuQMiT0+e9ljYjCqSexVhN+2v2Slb+D03vh8JJh367lQzyv ivNMI57NanvHWSml9eLaSJtKj5BI+YQyACvVQbh6z7Y7ASY4sIlxFmZ0kAUyAcsMH3hg wWF809taFEcnJyNvLDoN10IGx7T8Lp9i6tMA6csXC4I2aLx3Q5LiplMLKeBpLS45pqvZ bIEQ== 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:autocrypt:from :references:cc:to:subject; bh=W5YJAyUlf5B03KL/uOPOHQ0E2PkeF9RZgbeg2xxXs/Y=; b=iNKnB3Gh2IXwL8qbEsuHxA9ZMiuK2eYAxOq/yjmWG+aI0DwQt3792ZGJyICZ+VkoaZ qfAQQwgnsBKiIc6y5BUPaaiL57YyP5gHl/TZ+W3dGmVOPNlGU9ux9J0G3DGZtdR2eoo0 afi1n0pgwbc3C0hHtDz3E7KaAWzSyAyCi55wJov88fG+KmiqdCP7mHpd9KROCO3KNXLe 7qYfjU0lYVQ5H1KIz9FeUsha9IXlkL4/R4NH5b5FM067+Nbz3r5f7w7G660zhQEs6NQ7 b9vfLE3xCcBheeixSpki23RC/bA1qooJOZ2xxEznB/iTl6jpjIZsC0kDXbKm1ev63/6b RVtA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq22si3094020ejb.281.2020.10.01.03.01.16; Thu, 01 Oct 2020 03:01:39 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731704AbgJAKAK (ORCPT + 99 others); Thu, 1 Oct 2020 06:00:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:58090 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726992AbgJAKAJ (ORCPT ); Thu, 1 Oct 2020 06:00:09 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 44BDDACB7; Thu, 1 Oct 2020 10:00:08 +0000 (UTC) Subject: Re: [PATCH v3] mmc: core: don't set limits.discard_granularity as 0 To: Vicente Bergas Cc: Adrian Hunter , linux-mmc@vger.kernel.org, Linux Kernel Mailing List , linux-block@vger.kernel.org, Ulf Hansson References: <20201001071824.24995-1-colyli@suse.de> From: Coly Li Autocrypt: addr=colyli@suse.de; keydata= mQINBFYX6S8BEAC9VSamb2aiMTQREFXK4K/W7nGnAinca7MRuFUD4JqWMJ9FakNRd/E0v30F qvZ2YWpidPjaIxHwu3u9tmLKqS+2vnP0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ARAQABiQI8BBgBCAAmAhsMFiEE6j5FL/T5SGCN6PrQxzkHk2t9+PwFAlxHziAFCRj7 5/EACgkQxzkHk2t9+PxgfA//cH5R1DvpJPwraTAl24SUcG9EWe+NXyqveApe05nk15zEuxxd e4zFEjo+xYZilSveLqYHrm/amvQhsQ6JLU+8N60DZHVcXbw1Eb8CEjM5oXdbcJpXh1/1BEwl 4phsQMkxOTns51bGDhTQkv4lsZKvNByB9NiiMkT43EOx14rjkhHw3rnqoI7ogu8OO7XWfKcL CbchjJ8t3c2XK1MUe056yPpNAT2XPNF2EEBPG2Y2F4vLgEbPv1EtpGUS1+JvmK3APxjXUl5z 6xrxCQDWM5AAtGfM/IswVjbZYSJYyH4BQKrShzMb0rWUjkpXvvjsjt8rEXpZEYJgX9jvCoxt oqjCKiVLpwje9WkEe9O9VxljmPvxAhVqJjX62S+TGp93iD+mvpCoHo3+CcvyRcilz+Ko8lfO hS9tYT0HDUiDLvpUyH1AR2xW9RGDevGfwGTpF0K6cLouqyZNdhlmNciX48tFUGjakRFsxRmX K0Jx4CEZubakJe+894sX6pvNFiI7qUUdB882i5GR3v9ijVPhaMr8oGuJ3kvwBIA8lvRBGVGn 9xvzkQ8Prpbqh30I4NMp8MjFdkwCN6znBKPHdjNTwE5PRZH0S9J0o67IEIvHfH0eAWAsgpTz +jwc7VKH7vkvgscUhq/v1/PEWCAqh9UHy7R/jiUxwzw/288OpgO+i+2l11Y= Message-ID: <443b9ed1-b075-d86d-e734-c9ec78653842@suse.de> Date: Thu, 1 Oct 2020 18:00:04 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; 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 2020/10/1 16:38, 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? Hi Vicente, Please do :-) I will wait for your reply and post a v4 version. Thanks. Coly Li >> 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 >>