* [PATCH] nbd: set discard_alignment to the granularity
@ 2018-06-05 15:41 Josef Bacik
2018-06-05 15:51 ` Jens Axboe
2018-06-12 9:22 ` Wouter Verhelst
0 siblings, 2 replies; 3+ messages in thread
From: Josef Bacik @ 2018-06-05 15:41 UTC (permalink / raw)
To: axboe, nbd, linux-block, kernel-team
Technically we should be able to get away with 0 as the
discard_alignment, but there's no way currently for the protocol to
indicate different alignments, and in real life most disks have
discard_alignment == discard_granularity. Just set our alignment to our
blocksize to make sure discards will actually work properly with 4k
drives.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
drivers/block/nbd.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index bdfbb2a7018c..ec9b43c9f7e3 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -238,6 +238,7 @@ static void nbd_size_update(struct nbd_device *nbd)
if (config->flags & NBD_FLAG_SEND_TRIM) {
nbd->disk->queue->limits.discard_granularity = config->blksize;
+ nbd->disk->queue->limits.discard_alignment = config->blksize;
blk_queue_max_discard_sectors(nbd->disk->queue, UINT_MAX);
}
blk_queue_logical_block_size(nbd->disk->queue, config->blksize);
@@ -1055,6 +1056,7 @@ static void nbd_config_put(struct nbd_device *nbd)
nbd->tag_set.timeout = 0;
nbd->disk->queue->limits.discard_granularity = 0;
+ nbd->disk->queue->limits.discard_alignment = 0;
blk_queue_max_discard_sectors(nbd->disk->queue, UINT_MAX);
blk_queue_flag_clear(QUEUE_FLAG_DISCARD, nbd->disk->queue);
@@ -1509,6 +1511,7 @@ static int nbd_dev_add(int index)
blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue);
blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, disk->queue);
disk->queue->limits.discard_granularity = 0;
+ disk->queue->limits.discard_alignment = 0;
blk_queue_max_discard_sectors(disk->queue, 0);
blk_queue_max_segment_size(disk->queue, UINT_MAX);
blk_queue_max_segments(disk->queue, USHRT_MAX);
--
2.14.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nbd: set discard_alignment to the granularity
2018-06-05 15:41 [PATCH] nbd: set discard_alignment to the granularity Josef Bacik
@ 2018-06-05 15:51 ` Jens Axboe
2018-06-12 9:22 ` Wouter Verhelst
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2018-06-05 15:51 UTC (permalink / raw)
To: Josef Bacik, nbd, linux-block, kernel-team
On 6/5/18 9:41 AM, Josef Bacik wrote:
> Technically we should be able to get away with 0 as the
> discard_alignment, but there's no way currently for the protocol to
> indicate different alignments, and in real life most disks have
> discard_alignment == discard_granularity. Just set our alignment to our
> blocksize to make sure discards will actually work properly with 4k
> drives.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nbd: set discard_alignment to the granularity
2018-06-05 15:41 [PATCH] nbd: set discard_alignment to the granularity Josef Bacik
2018-06-05 15:51 ` Jens Axboe
@ 2018-06-12 9:22 ` Wouter Verhelst
1 sibling, 0 replies; 3+ messages in thread
From: Wouter Verhelst @ 2018-06-12 9:22 UTC (permalink / raw)
To: Josef Bacik; +Cc: axboe, nbd, linux-block, kernel-team
Hi Josef,
On Tue, Jun 05, 2018 at 11:41:23AM -0400, Josef Bacik wrote:
> Technically we should be able to get away with 0 as the
> discard_alignment, but there's no way currently for the protocol to
> indicate different alignments,
Actually there is, with the NBD_INFO_BLOCK_SIZE (and related)
response(s) to the NBD_OPT_GO message during negotiation, but
implementing that will probably require some more netlink messages.
(some of this is still being hashed out on the NBD mailinglist; I'm sure
your insights in that would be welcome)
--
Could you people please use IRC like normal people?!?
-- Amaya Rodrigo Sastre, trying to quiet down the buzz in the DebConf 2008
Hacklab
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-06-12 9:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05 15:41 [PATCH] nbd: set discard_alignment to the granularity Josef Bacik
2018-06-05 15:51 ` Jens Axboe
2018-06-12 9:22 ` Wouter Verhelst
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.