On 07/21/2015 06:32 AM, David Disseldorp wrote: > Currently iSCSI network portal listener kthreads are spawned regardless > of whether a TPG is disabled or enabled. LIO also accepts connections > and handles requests (E.g. SendTargets) via disabled TPGs. > > This patch-set ensures that network portal listener kthreads are only > spawned when a TPG is enabled. I have reviewed the patch set. My only issue would be to group the patches differently, so that they stand alone, i.e. delete a function in the same patch you stop using it. But they seem functionally sound. I consider my issue a nit, however, since I am not the subsystem maintainer. So please add my Reviewed-by: tag to all of them. > > This behaviour is demonstrated with the following test: > ---- > #!/bin/bash > > echo -e "\nEnable tpgt_1 and add a (3260) portal - should spawn iscsi_np kthread listener" > echo 1 > /sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.hex-7.x8664:sn.9350a8ae6bd6/tpgt_1/enable > mkdir /sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.hex-7.x8664:sn.9350a8ae6bd6/tpgt_1/np/10.160.64.64:3260 > netstat -l > ps -elf|grep iscsi_np|grep -v grep > > echo -e "\nDisable tpgt_2 and add a (3261) portal - shouldn't spawn a new listener" > echo 0 > /sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.hex-7.x8664:sn.9350a8ae6bd6/tpgt_2/enable > mkdir /sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.hex-7.x8664:sn.9350a8ae6bd6/tpgt_2/np/10.160.64.64:3261 > netstat -l > ps -elf|grep iscsi_np|grep -v grep > > echo -e "\nEnable tpgt_2 - should spawn new listener for existing (3261) portal" > echo 1 > /sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.hex-7.x8664:sn.9350a8ae6bd6/tpgt_2/enable > netstat -l > ps -elf|grep iscsi_np|grep -v grep > > echo -e "\nDisable tpgt_1 - should shutdown (3260) listener" > echo 0 > /sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.hex-7.x8664:sn.9350a8ae6bd6/tpgt_1/enable > netstat -l > ps -elf|grep iscsi_np|grep -v grep > > echo -e "\nDelete tpgt_2 np (while enabled) - should shutdown (3261) listener" > rmdir /sys/kernel/config/target/iscsi/iqn.2003-01.org.linux-iscsi.hex-7.x8664:sn.9350a8ae6bd6/tpgt_2/np/10.160.64.64:3261 > netstat -l > ps -elf|grep iscsi_np|grep -v grep > ---- > > With this patch-set, the test output is: > ==== > > Enable tpgt_1 and add a (3260) portal - should spawn iscsi_np kthread listener > Active Internet connections (only servers) > Proto Recv-Q Send-Q Local Address Foreign Address State > tcp 0 0 10.160.64.64:3260 *:* LISTEN > Active UNIX domain sockets (only servers) > Proto RefCnt Flags Type State I-Node Path > 1 S root 1051 2 0 80 0 - 0 inet_c 12:42 ? 00:00:00 [iscsi_np] > > Disable tpgt_2 and add a (3261) portal - shouldn't spawn a new listener > [ 16.589885] iSCSI Target Portal Group: 2 is already inactive, ignoring request. > ./lio_tpg_state_test.sh: line 10: echo: write error: Invalid argument > Active Internet connections (only servers) > Proto Recv-Q Send-Q Local Address Foreign Address State > tcp 0 0 10.160.64.64:3260 *:* LISTEN > Active UNIX domain sockets (only servers) > Proto RefCnt Flags Type State I-Node Path > 1 S root 1051 2 0 80 0 - 0 inet_c 12:42 ? 00:00:00 [iscsi_np] > > Enable tpgt_2 - should spawn new listener for existing (3261) portal > Active Internet connections (only servers) > Proto Recv-Q Send-Q Local Address Foreign Address State > tcp 0 0 10.160.64.64:3260 *:* LISTEN > tcp 0 0 10.160.64.64:3261 *:* LISTEN > Active UNIX domain sockets (only servers) > Proto RefCnt Flags Type State I-Node Path > 1 S root 1051 2 0 80 0 - 0 inet_c 12:42 ? 00:00:00 [iscsi_np] > 1 S root 1061 2 0 80 0 - 0 inet_c 12:42 ? 00:00:00 [iscsi_np] > > Disable tpgt_1 - should shutdown (3260) listener > Active Internet connections (only servers) > Proto Recv-Q Send-Q Local Address Foreign Address State > tcp 0 0 10.160.64.64:3261 *:* LISTEN > Active UNIX domain sockets (only servers) > Proto RefCnt Flags Type State I-Node Path > 1 S root 1061 2 0 80 0 - 0 inet_c 12:42 ? 00:00:00 [iscsi_np] > > Delete tpgt_2 np (while enabled) - should shutdown (3261) listener > Active Internet connections (only servers) > Proto Recv-Q Send-Q Local Address Foreign Address State > Active UNIX domain sockets (only servers) > Proto RefCnt Flags Type State I-Node Path > ==== > > Without this patch-set, the test output is: > ==== > > Enable tpgt_1 and add a (3260) portal - should spawn iscsi_np kthread listener > Active Internet connections (only servers) > Proto Recv-Q Send-Q Local Address Foreign Address State > tcp 0 0 10.160.64.64:3260 *:* LISTEN > Active UNIX domain sockets (only servers) > Proto RefCnt Flags Type State I-Node Path > 1 S root 1051 2 0 80 0 - 0 inet_c 13:17 ? 00:00:00 [iscsi_np] > > Disable tpgt_2 and add a (3261) portal - shouldn't spawn a new listener > [ 26.617861] iSCSI Target Portal Group: 2 is already inactive, ignoring request. > ./lio_tpg_state_test.sh: line 10: echo: write error: Invalid argument > Active Internet connections (only servers) > Proto Recv-Q Send-Q Local Address Foreign Address State > tcp 0 0 10.160.64.64:3260 *:* LISTEN > tcp 0 0 10.160.64.64:3261 *:* LISTEN > Active UNIX domain sockets (only servers) > Proto RefCnt Flags Type State I-Node Path > 1 S root 1051 2 0 80 0 - 0 inet_c 13:17 ? 00:00:00 [iscsi_np] > 1 S root 1057 2 0 80 0 - 0 inet_c 13:17 ? 00:00:00 [iscsi_np] > > Enable tpgt_2 - should spawn new listener for existing (3261) portal > Active Internet connections (only servers) > Proto Recv-Q Send-Q Local Address Foreign Address State > tcp 0 0 10.160.64.64:3260 *:* LISTEN > tcp 0 0 10.160.64.64:3261 *:* LISTEN > Active UNIX domain sockets (only servers) > Proto RefCnt Flags Type State I-Node Path > 1 S root 1051 2 0 80 0 - 0 inet_c 13:17 ? 00:00:00 [iscsi_np] > 1 S root 1057 2 0 80 0 - 0 inet_c 13:17 ? 00:00:00 [iscsi_np] > > Disable tpgt_1 - should shutdown (3260) listener > Active Internet connections (only servers) > Proto Recv-Q Send-Q Local Address Foreign Address State > tcp 0 0 10.160.64.64:3260 *:* LISTEN > tcp 0 0 10.160.64.64:3261 *:* LISTEN > Active UNIX domain sockets (only servers) > Proto RefCnt Flags Type State I-Node Path > 1 S root 1051 2 0 80 0 - 0 inet_c 13:17 ? 00:00:00 [iscsi_np] > 1 S root 1057 2 0 80 0 - 0 inet_c 13:17 ? 00:00:00 [iscsi_np] > > Delete tpgt_2 np (while enabled) - should shutdown (3261) listener > Active Internet connections (only servers) > Proto Recv-Q Send-Q Local Address Foreign Address State > tcp 0 0 10.160.64.64:3260 *:* LISTEN > Active UNIX domain sockets (only servers) > Proto RefCnt Flags Type State I-Node Path > 1 S root 1051 2 0 80 0 - 0 inet_c 13:17 ? 00:00:00 [iscsi_np] > ==== > > Feedback appreciated. > > drivers/target/iscsi/iscsi_target.c | 114 ++++++++++++++-------- > drivers/target/iscsi/iscsi_target.h | 5 +- > drivers/target/iscsi/iscsi_target_login.c | 22 ----- > drivers/target/iscsi/iscsi_target_login.h | 2 - > drivers/target/iscsi/iscsi_target_tpg.c | 84 +++++++++++++--- > 5 files changed, 144 insertions(+), 83 deletions(-) > > Cheers, David > -- > To unsubscribe from this list: send the line "unsubscribe target-devel" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- Lee Duncan SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html