diff mbox series

[1/3] nbd: don't clear discard_sectors in nbd_config_put

Message ID 20240229143846.1047223-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/3] nbd: don't clear discard_sectors in nbd_config_put | expand

Commit Message

Christoph Hellwig Feb. 29, 2024, 2:38 p.m. UTC
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>
---
 drivers/block/nbd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jens Axboe March 1, 2024, 4:09 p.m. UTC | #1
On Thu, 29 Feb 2024 06:38:44 -0800, Christoph Hellwig wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/3] nbd: don't clear discard_sectors in nbd_config_put
      commit: 7ea201f2cc1da999b9a0a23ea20b64eb2c4719a9
[2/3] nbd: freeze the queue for queue limits updates
      commit: 242a49e5c8784e93a99e4dc4277b28a8ba85eac5
[3/3] nbd: use the atomic queue limits API in nbd_set_size
      commit: 268283244c0f018dec8bf4a9c69ce50684561f46

Best regards,
diff mbox series

Patch

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 9ee9587375fac3..384750d5259fb8 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -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);
 
@@ -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);