[PATCH v3 3/6] 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, yangerkun@huawei.com, linux-block@vger.kernel.org, nbd@other.debian.org
- Subject: [PATCH v3 3/6] nbd: remove queue freeze in nbd_add_socket
- From: Yang Erkun <yangerkun@huawei.com>
- Date: Mon, 13 Jul 2026 14:56:41 +0800
- Message-id: <[🔎] 20260713065644.1637594-4-yangerkun@huawei.com>
- In-reply-to: <[🔎] 20260713065644.1637594-1-yangerkun@huawei.com>
- References: <[🔎] 20260713065644.1637594-1-yangerkun@huawei.com>
nbd_add_socket can never run concurrently with inflight I/O:
- netlink path: nbd_genl_connect calls nbd_add_socket before
nbd_start_device, so no I/O can happened when invoking nbd_add_socket,
nbd_genl_reconfigure cannot too since it won't call nbd_add_socket
- ioctl path: NBD_SET_SOCK cannot be called after NBD_DO_IT with
the previous commit, so capability of nbd will keep 0 while
invoking NBD_SET_SOCK
Removing the freeze in nbd_add_socket to speed up nbd device startup.
Signed-off-by: Yang Erkun <yangerkun@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 a15553ab4b97..0755b7046ed4 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1272,7 +1272,6 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
struct socket *sock;
struct nbd_sock **socks;
struct nbd_sock *nsock;
- unsigned int memflags;
int err;
/* Arg will be cast to int, check it to avoid overflow */
@@ -1283,12 +1282,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;
@@ -1335,12 +1328,10 @@ static int nbd_add_socket(struct nbd_device *nbd, unsigned long arg,
INIT_WORK(&nsock->work, nbd_pending_cmd_work);
socks[config->num_connections++] = nsock;
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: