summaryrefslogtreecommitdiff
path: root/drivers/block
diff options
context:
space:
mode:
authorYang Erkun <yangerkun@huawei.com>2026-08-05 20:29:27 +0800
committerJens Axboe <axboe@kernel.dk>2026-08-15 20:01:20 -0600
commitdb285268df7948f6edbb7c8bb7cd02da3ceec6b4 (patch)
tree7d8e80444d730ddf88a6e7463786d4bc5262d31d /drivers/block
parent285908f554fe32d9ca7cb7c3a03a05144faeb461 (diff)
downloadlinux-db285268df7948f6edbb7c8bb7cd02da3ceec6b4.tar.gz
linux-db285268df7948f6edbb7c8bb7cd02da3ceec6b4.zip
nbd: skip queue freeze when setting size at device startup
Commit 242a49e5c878 ("nbd: freeze the queue for queue limits updates") added the freeze to keep in-flight commands from seeing torn queue_limits. But at startup the capacity is still 0 (invalidate_disk cleared it) and the write cache is off (the previous patch cleared it on disconnect, and nbd_set_size sets it back only after the commit), so submit_bio_noacct() rejects any bio before it reaches the driver and no I/O is in flight. Drop the freeze by checking capacity and write cache state in nbd_set_size. Reviewed-by: Yu Kuai <yukuai@fygo.io> Signed-off-by: Yang Erkun <yangerkun@huawei.com> Link: https://patch.msgid.link/20260805122930.57647-6-yangerkun@huawei.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/nbd.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index cb7c1f8502f4..cb662ae4b91d 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -375,7 +375,11 @@ static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, loff_t blksize)
nbd_apply_limits(&lim, nbd->config->flags);
lim.logical_block_size = blksize;
lim.physical_block_size = blksize;
- error = queue_limits_commit_update_frozen(nbd->disk->queue, &lim);
+ /* No need freeze with 0 capacity and write cache disabled */
+ if (!get_capacity(nbd->disk) && !blk_queue_write_cache(nbd->disk->queue))
+ error = queue_limits_commit_update(nbd->disk->queue, &lim);
+ else
+ error = queue_limits_commit_update_frozen(nbd->disk->queue, &lim);
if (error)
return error;