Re: [PATCH v2] mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity

From: Zhihao Cheng
Date: Fri Jun 18 2021 - 04:55:08 EST


在 2021/6/18 15:52, Miquel Raynal 写道:
Hi Zhihao,

Zhihao Cheng <chengzhihao1@xxxxxxxxxx> wrote on Tue, 15 Jun 2021
17:39:05 +0800:

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.

Can you please verify that this is still needed after Christoph's
additional fix:
https://patchwork.kernel.org/project/xen-devel/patch/20210602065345.355274-10-hch@xxxxxx/

Hi, Miquel,
I can still reproduce the problem after [1] applied.
I look through this series patches and I didn't find out 'rq.limits.discard_granularity' has been initialized somewhere. The patchset is aming at reconstructing to avoid boilerplate code in drivers?
So 'rq.limits.discard_granularity' still need to be initialized in mtdblock driver.

[1] https://patchwork.kernel.org/project/xen-devel/patch/20210602065345.355274-10-hch@xxxxxx/