Skip to content

Commit 7ea201f

Browse files
Christoph Hellwigaxboe
authored andcommitted
nbd: don't clear discard_sectors in nbd_config_put
nbd_config_put currently clears discard_sectors when unusing a device. This is pretty odd behavior and different from the sector size configuration which is simply left in places and then reconfigured when nbd_set_size is as part of configuring the device. Change nbd_set_size to clear discard_sectors if discard is not supported so that all the queue limits changes are handled in one place. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent eabf5df commit 7ea201f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/block/nbd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
336336

337337
if (nbd->config->flags & NBD_FLAG_SEND_TRIM)
338338
blk_queue_max_discard_sectors(nbd->disk->queue, UINT_MAX);
339+
else
340+
blk_queue_max_discard_sectors(nbd->disk->queue, 0);
339341
blk_queue_logical_block_size(nbd->disk->queue, blksize);
340342
blk_queue_physical_block_size(nbd->disk->queue, blksize);
341343

@@ -1351,7 +1353,6 @@ static void nbd_config_put(struct nbd_device *nbd)
13511353
nbd->config = NULL;
13521354

13531355
nbd->tag_set.timeout = 0;
1354-
blk_queue_max_discard_sectors(nbd->disk->queue, 0);
13551356

13561357
mutex_unlock(&nbd->config_lock);
13571358
nbd_put(nbd);

0 commit comments

Comments
 (0)