Hi, blkdiscard fails on brd with IO error on 4.4.5, and latest mainline looks the same. nbd and zram has same defect, I can send fix later, if you are Ok with this fix.
-- Mit freundlichen Grüßen, Best Regards, Jack Wang Linux Kernel Developer Storage ProfitBricks GmbH The IaaS-Company. ProfitBricks GmbH Greifswalder Str. 207 D - 10405 Berlin Tel: +49 30 5770083-42 Fax: +49 30 5770085-98 Email: jinpu.w...@profitbricks.com URL: http://www.profitbricks.de Sitz der Gesellschaft: Berlin. Registergericht: Amtsgericht Charlottenburg, HRB 125506 B. Geschäftsführer: Andreas Gauger, Achim Weiss.
From e39b27a828aacbaf7cd75625538b3105f42a9d75 Mon Sep 17 00:00:00 2001 From: Jack Wang <jinpu.w...@profitbricks.com> Date: Fri, 15 Apr 2016 16:05:16 +0200 Subject: [PATCH] brd: set max_discard_sectors properly blkdiscard -v /dev/ram0 fails with IO errors, the reason seems to be, it set max_discard_sectors to UINT_MAX, which seems to wrong, need to convert to sectors. After this change blkdiscard works. Signed-off-by: Jack Wang <jinpu.w...@profitbricks.com> --- drivers/block/brd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/brd.c b/drivers/block/brd.c index a5880f4..7434248 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -503,7 +503,7 @@ static struct brd_device *brd_alloc(int i) blk_queue_physical_block_size(brd->brd_queue, PAGE_SIZE); brd->brd_queue->limits.discard_granularity = PAGE_SIZE; - blk_queue_max_discard_sectors(brd->brd_queue, UINT_MAX); + blk_queue_max_discard_sectors(brd->brd_queue, UINT_MAX << 9); brd->brd_queue->limits.discard_zeroes_data = 1; queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, brd->brd_queue); -- 1.9.1