mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCHv2]brd: set max_discard_sectors properly
@ 2016-04-15 14:24 Jinpu Wang
  2016-04-16  1:50 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Jinpu Wang @ 2016-04-15 14:24 UTC (permalink / raw)
  To: Jens Axboe, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 170 bytes --]

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.

[-- Attachment #2: 0001-brd-set-max_discard_sectors-properly.patch --]
[-- Type: text/x-patch, Size: 1113 bytes --]

From a5db7d1acdb54b7f188eb916f711733e34da5b5f Mon Sep 17 00:00:00 2001
From: Jack Wang <jinpu.wang@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.wang@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..a5e3c0f 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


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

end of thread, other threads:[~2016-04-18 13:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-15 14:24 [PATCHv2]brd: set max_discard_sectors properly Jinpu Wang
2016-04-16  1:50 ` Christoph Hellwig
2016-04-18  8:34   ` Jinpu Wang
2016-04-18 13:55     ` Jinpu Wang

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

all inboxes | Powered by JetHome®