linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity
@ 2021-06-15  9:39 Zhihao Cheng
  2021-06-18  7:52 ` Miquel Raynal
  2021-07-15 22:50 ` Miquel Raynal
  0 siblings, 2 replies; 4+ messages in thread
From: Zhihao Cheng @ 2021-06-15  9:39 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr
  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 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 <chengzhihao1@huawei.com>
---
 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;
-- 
2.31.1


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

* Re: [PATCH v2] mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity
  2021-06-15  9:39 [PATCH v2] mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity Zhihao Cheng
@ 2021-06-18  7:52 ` Miquel Raynal
  2021-06-18  8:55   ` Zhihao Cheng
  2021-07-15 22:50 ` Miquel Raynal
  1 sibling, 1 reply; 4+ messages in thread
From: Miquel Raynal @ 2021-06-18  7:52 UTC (permalink / raw)
  To: Zhihao Cheng
  Cc: richard, vigneshr, linux-mtd, linux-kernel, yukuai3, Christoph Hellwig

Hi Zhihao,

Zhihao Cheng <chengzhihao1@huawei.com> 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@lst.de/

> 
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> ---
>  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;




Thanks,
Miquèl

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

* Re: [PATCH v2] mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity
  2021-06-18  7:52 ` Miquel Raynal
@ 2021-06-18  8:55   ` Zhihao Cheng
  0 siblings, 0 replies; 4+ messages in thread
From: Zhihao Cheng @ 2021-06-18  8:55 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: richard, vigneshr, linux-mtd, linux-kernel, yukuai3, Christoph Hellwig

在 2021/6/18 15:52, Miquel Raynal 写道:
> Hi Zhihao,
> 
> Zhihao Cheng <chengzhihao1@huawei.com> 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@lst.de/
> 
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@lst.de/

> 


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

* Re: [PATCH v2] mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity
  2021-06-15  9:39 [PATCH v2] mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity Zhihao Cheng
  2021-06-18  7:52 ` Miquel Raynal
@ 2021-07-15 22:50 ` Miquel Raynal
  1 sibling, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2021-07-15 22:50 UTC (permalink / raw)
  To: Zhihao Cheng, miquel.raynal, richard, vigneshr
  Cc: linux-mtd, linux-kernel, yukuai3

On Tue, 2021-06-15 at 09:39:05 UTC, Zhihao Cheng wrote:
> 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 <chengzhihao1@huawei.com>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel

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

end of thread, other threads:[~2021-07-15 22:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15  9:39 [PATCH v2] mtd: mtd_blkdevs: Initialize rq.limits.discard_granularity Zhihao Cheng
2021-06-18  7:52 ` Miquel Raynal
2021-06-18  8:55   ` Zhihao Cheng
2021-07-15 22:50 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).