[PATCH v2 3/5] mtd: blk_devs: make discard work on FTLs

Sean Young sean at mess.org
Sat Aug 7 14:45:36 PDT 2021


If the discard_granularity is not set, discard will not work and the
following error is logged:

rfda: Error: discard_granularity is 0.

Since all the FTLs use a sector size of 512, this can be hardcoded.

Signed-off-by: Sean Young <sean at mess.org>
---
 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 6ce4bc57f919..486251e058a6 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -419,6 +419,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 = 512;
 	}
 
 	gd->queue = new->rq;
-- 
2.31.1




More information about the linux-mtd mailing list