Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -19413,6 +19413,7 @@ F: Documentation/admin-guide/blockdev/nbd.rst
F: drivers/block/nbd.c
F: include/trace/events/nbd.h
F: include/uapi/linux/nbd.h
F: tools/testing/selftests/nbd/

NETWORK DROP MONITOR
M: Neil Horman <nhorman@tuxdriver.com>
Expand Down
7 changes: 7 additions & 0 deletions drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,13 @@ static int nbd_start_device(struct nbd_device *nbd)
blk_mq_update_nr_hw_queues(&nbd->tag_set, num_connections);
mutex_lock(&nbd->config_lock);

/* The device may have been started or reconfigured while unlocked. */
if (nbd->pid)
return -EBUSY;
if (config->num_connections > 1 &&
!(config->flags & NBD_FLAG_CAN_MULTI_CONN))
return -EINVAL;

/* if another code path updated nr_hw_queues, retry until succeed */
if (num_connections != config->num_connections) {
num_connections = config->num_connections;
Expand Down
1 change: 1 addition & 0 deletions tools/testing/selftests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ TARGETS += mount_setattr
TARGETS += move_mount_set_group
TARGETS += mqueue
TARGETS += mseal_system_mappings
TARGETS += nbd
TARGETS += nci
TARGETS += net
TARGETS += net/af_unix
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/nbd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/nbd_pid_race
/nbd_multi_conn
8 changes: 8 additions & 0 deletions tools/testing/selftests/nbd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: GPL-2.0-only
CFLAGS += -O2 -Wall -Wextra $(KHDR_INCLUDES)
TEST_GEN_PROGS := nbd_pid_race nbd_multi_conn
LOCAL_HDRS += nbd_common.h

include ../lib.mk

$(TEST_GEN_PROGS): nbd_common.c
7 changes: 7 additions & 0 deletions tools/testing/selftests/nbd/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CONFIG_MODULES=y
CONFIG_BLOCK=y
CONFIG_BLK_DEV_NBD=m
CONFIG_NET=y
CONFIG_UNIX=y
CONFIG_SMP=y
CONFIG_SYSFS=y
Loading
Loading