aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/nbd.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fb.com>2018-05-23 13:35:59 -0400
committerJens Axboe <axboe@kernel.dk>2018-05-23 15:27:26 -0600
commit6df133a1495f8c497d0f53005296ef5421752620 (patch)
tree60b79b815157ca3664ecbc8f3586126da7b8dfb5 /drivers/block/nbd.c
parentblkdev_report_zones_ioctl(): Use vmalloc() to allocate large buffers (diff)
downloadlinux-dev-6df133a1495f8c497d0f53005296ef5421752620.tar.xz
linux-dev-6df133a1495f8c497d0f53005296ef5421752620.zip
nbd: set discard granularity properly
For some reason we had discard granularity set to 512 always even when discards were disabled. Fix this by having the default be 0, and then if we turn it on set the discard granularity to the blocksize. Signed-off-by: Josef Bacik <jbacik@fb.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to '')
-rw-r--r--drivers/block/nbd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 1147e4680c80..bdfbb2a7018c 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -236,6 +236,10 @@ static void nbd_size_update(struct nbd_device *nbd)
struct nbd_config *config = nbd->config;
struct block_device *bdev = bdget_disk(nbd->disk, 0);
+ if (config->flags & NBD_FLAG_SEND_TRIM) {
+ nbd->disk->queue->limits.discard_granularity = config->blksize;
+ blk_queue_max_discard_sectors(nbd->disk->queue, UINT_MAX);
+ }
blk_queue_logical_block_size(nbd->disk->queue, config->blksize);
blk_queue_physical_block_size(nbd->disk->queue, config->blksize);
set_capacity(nbd->disk, config->bytesize >> 9);
@@ -1050,6 +1054,8 @@ static void nbd_config_put(struct nbd_device *nbd)
nbd->config = NULL;
nbd->tag_set.timeout = 0;
+ nbd->disk->queue->limits.discard_granularity = 0;
+ blk_queue_max_discard_sectors(nbd->disk->queue, UINT_MAX);
blk_queue_flag_clear(QUEUE_FLAG_DISCARD, nbd->disk->queue);
mutex_unlock(&nbd->config_lock);
@@ -1502,8 +1508,8 @@ 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 = 512;
- blk_queue_max_discard_sectors(disk->queue, UINT_MAX);
+ disk->queue->limits.discard_granularity = 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);
blk_queue_max_hw_sectors(disk->queue, 65536);