[PATCH v2 4/5] nbd: remove queue freeze in nbd_add_socket
- To: josef@toxicpanda.com, axboe@kernel.dk, hch@lst.de, yukuai@kernel.org
- Cc: yi.zhang@huawei.com, chengzhihao1@huawei.com, echo.chenlin@huawei.com, leo.lilong@huaweicloud.com, wangkefeng.wang@huawei.com, linux-block@vger.kernel.org, nbd@other.debian.org
- Subject: [PATCH v2 4/5] nbd: remove queue freeze in nbd_add_socket
- From: Yang Erkun <yangerkun@huawei.com>
- Date: Thu, 25 Jun 2026 16:44:57 +0800
- Message-id: <[🔎] 20260625084458.4171890-5-yangerkun@huawei.com>
- In-reply-to: <[🔎] 20260625084458.4171890-1-yangerkun@huawei.com>
- References: <[🔎] 20260625084458.4171890-1-yangerkun@huawei.com>
From: Long Li <leo.lilong@huawei.com>
The queue freeze was originally needed to prevent concurrent requests
from accessing config->socks while the backing array was being
reallocated. Since config->socks is now an xarray, insertions are
safe under RCU without freezing the queue.
This significantly reduces connection setup time when using a large
number of connections (-C 256):
before: real 4.510s
after: real 0.263s
Signed-off-by: Long Li <leo.lilong@huawei.com>
---
drivers/block/nbd.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 409a655c40f0..953146c85f17 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1299,7 +1299,6 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
struct nbd_config *config = nbd->config;
struct socket *sock;
struct nbd_sock *nsock;
- unsigned int memflags;
unsigned int index;
int err;
@@ -1311,12 +1310,6 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
return err;
nbd_reclassify_socket(sock);
- /*
- * We need to make sure we don't get any errant requests while we're
- * reallocating the ->socks array.
- */
- memflags = blk_mq_freeze_queue(nbd->disk->queue);
-
if (!netlink && !nbd->task_setup &&
!test_bit(NBD_RT_BOUND, &config->runtime_flags))
nbd->task_setup = current;
@@ -1353,12 +1346,10 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
config->num_connections++;
atomic_inc(&config->live_connections);
- blk_mq_unfreeze_queue(nbd->disk->queue, memflags);
return 0;
put_socket:
- blk_mq_unfreeze_queue(nbd->disk->queue, memflags);
sockfd_put(sock);
return err;
}
--
2.52.0
Reply to: