public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mtd: ftl: Initialize rq.limits.discard_granularity
@ 2021-06-13 11:29 Zhihao Cheng
  2021-06-16 13:22 ` kernel test robot
  2021-06-16 19:39 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Zhihao Cheng @ 2021-06-13 11:29 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, boris.brezillon
  Cc: linux-mtd, linux-kernel, chengzhihao1, yukuai3

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 while formating 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 in ftl_add_mtd().

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
 drivers/mtd/ftl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index 9b33c082179d..fb31e33b8a77 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -70,6 +70,7 @@
 #include <linux/hdreg.h>
 #include <linux/vmalloc.h>
 #include <linux/blkpg.h>
+#include <linux/blkdev.h>
 #include <linux/uaccess.h>
 
 #include <linux/mtd/ftl.h>
@@ -1029,8 +1030,11 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 
 		partition->mbd.tr = tr;
 		partition->mbd.devnum = -1;
-		if (!add_mtd_blktrans_dev((void *)partition))
+		if (!add_mtd_blktrans_dev((void *)partition)) {
+			partition->mbd.rq->limits.discard_granularity =
+								tr->blksize;
 			return;
+		}
 	}
 
 	kfree(partition);
-- 
2.31.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-16 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-13 11:29 [PATCH] mtd: ftl: Initialize rq.limits.discard_granularity Zhihao Cheng
2021-06-16 13:22 ` kernel test robot
2021-06-16 19:39 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox