Skip to content

Commit

Permalink
nbd: don't clear discard_sectors in nbd_config_put
Browse files Browse the repository at this point in the history
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 <hch@lst.de>
Link: https://lore.kernel.org/r/20240229143846.1047223-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Mar 1, 2024
1 parent eabf5df commit 7ea201f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize,

if (nbd->config->flags & NBD_FLAG_SEND_TRIM)
blk_queue_max_discard_sectors(nbd->disk->queue, UINT_MAX);
else
blk_queue_max_discard_sectors(nbd->disk->queue, 0);
blk_queue_logical_block_size(nbd->disk->queue, blksize);
blk_queue_physical_block_size(nbd->disk->queue, blksize);

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

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

mutex_unlock(&nbd->config_lock);
nbd_put(nbd);
Expand Down

0 comments on commit 7ea201f

Please sign in to comment.