From patchwork Tue Jun 15 09:39:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 1492258 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=0oy+0nH1; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=S/zMGdsq; dkim-atps=neutral X-Greylist: delayed 1760 seconds by postgrey-1.36 at bilbo; Wed, 16 Jun 2021 00:10:40 AEST Received: from bombadil.infradead.org (unknown [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G49Fr5xTSz9sRN for ; Wed, 16 Jun 2021 00:10:40 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TLh146DCbCztu6q7mYAK9U9RBocelnjyFqvsl3RVfKo=; b=0oy+0nH1L1NYel /wb5+G+gCx8dWiNBOUHY5dM0eWJaSbcNVhG514rQKm7Y8tzdULJThCxlSNPNi3mmukunKUFs4s0hb BeP/dq30Kh34OjcH3fJk+4FZU3PIGipXXRgaSCVBYeRkJe1AhebOrfIvQ8w+Z0oI/TR9cqt2Qf205 Yc+2wXflw0A1vwlLq53IYcUL9WHZTFDFzfmbToQHy++epgFpZH808Zjr1GVkLI2Ue9yXNY3vV3OCC Wjl8H4scbpp840l5tWJrc49PFpUp3yuCo13x1U3hjgB7cYy4dvkqtVkTed0asg0zreFvykf6EdcR0 RKH1jeXL/RhVBXtV4C/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt9jL-000SaE-VA; Tue, 15 Jun 2021 14:07:52 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt9Hw-000E8e-Vm for linux-mtd@bombadil.infradead.org; Tue, 15 Jun 2021 13:39:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:In-Reply-To:References; bh=r5EPxRx8XUpVNzjWFhMtqC/QVMGUFhagKin48CSAnyo=; b=S/zMGdsqKAK9LY5QO6oIPSWrf6 W5u7skcY9ljU5u7s8Duj8h/7QTsufitfGvZlAPtyFzBNq/HwcL322yQq/XpHRG0/EH7utcgzPdSNd 14mo/wrLhGjTAlF64fnlI6qln0XVZ6JGl2VtKVUYP4vlmKQFBZ/aSX6sPgBMATXzSKqkyt+tbSdHQ 2AK9ZedwUUEjfJthEjaLdPjU6Nq+OAMUkCvpkNVvT1qrO5gzrMWojAKTxAsRLBFJj00Y5Tjzj9uf5 h68G6UUYV0Q8mzkxpSfzH2Jycks70uXHUpbc2gv2SmOLxxu+w0Pf5ArU2J/u/7TY8xgYUtG3UwtMK xpaeD7sA==; Received: from szxga02-in.huawei.com ([45.249.212.188]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt5Ob-007dxN-RF for linux-mtd@lists.infradead.org; Tue, 15 Jun 2021 09:30:18 +0000 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4G42yq3M9tzZhSq; Tue, 15 Jun 2021 17:27:15 +0800 (CST) Received: from dggema761-chm.china.huawei.com (10.1.198.203) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Tue, 15 Jun 2021 17:30:06 +0800 Received: from huawei.com (10.175.127.227) by dggema761-chm.china.huawei.com (10.1.198.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 15 Jun 2021 17:30:06 +0800 From: Zhihao Cheng To: , , CC: , , , Subject: [PATCH v2] mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity Date: Tue, 15 Jun 2021 17:39:05 +0800 Message-ID: <20210615093905.3473709-1-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggema761-chm.china.huawei.com (10.1.198.203) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210615_103017_016520_C65CB0B2 X-CRM114-Status: UNSURE ( 6.45 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Since commit b35fd7422c2f8("block: check queue's limits.discard_granularity in __blkdev_issue_discard()") checks rq.limits.discard_granularity in __blkdev_issue_discard(), we may get following warning [...] Content analysis details: (-2.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.188 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H4 RBL: Very Good reputation (+4) [45.249.212.188 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Since commit b35fd7422c2f8("block: check queue's limits.discard_granularity in __blkdev_issue_discard()") checks rq.limits.discard_granularity in __blkdev_issue_discard(), we may get following warnings on formatted ftl: WARNING: CPU: 2 PID: 7313 at block/blk-lib.c:51 __blkdev_issue_discard+0x2a7/0x390 Reproducer: 1. ftl_format /dev/mtd0 2. modprobe ftl 3. mkfs.vfat /dev/ftla 4. mount -odiscard /dev/ftla temp 5. dd if=/dev/zero of=temp/tst bs=1M count=10 oflag=direct 6. dd if=/dev/zero of=temp/tst bs=1M count=10 oflag=direct Fix it by initializing rq.limits.discard_granularity if device supports discard operation. Signed-off-by: Zhihao Cheng --- drivers/mtd/mtd_blkdevs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 01bf234e7f3a..6eac1c9c164d 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -413,6 +413,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) if (tr->discard) { blk_queue_flag_set(QUEUE_FLAG_DISCARD, new->rq); blk_queue_max_discard_sectors(new->rq, UINT_MAX); + new->rq->limits.discard_granularity = tr->blksize; } gd->queue = new->rq;