diff --git a/iscsi-scst/kernel/config.c b/iscsi-scst/kernel/config.c index b4c7e842e..3c2d9f425 100644 --- a/iscsi-scst/kernel/config.c +++ b/iscsi-scst/kernel/config.c @@ -1095,7 +1095,7 @@ out: return res; } -static long ioctl(struct file *file, unsigned int cmd, unsigned long arg) +static long iscsi_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { long err; @@ -1172,7 +1172,7 @@ out: return err; } -static int open(struct inode *inode, struct file *file) +static int iscsi_open(struct inode *inode, struct file *file) { bool already; @@ -1190,7 +1190,7 @@ static int open(struct inode *inode, struct file *file) return 0; } -static int release(struct inode *inode, struct file *filp) +static int iscsi_release(struct inode *inode, struct file *filp) { #ifndef CONFIG_SCST_PROC struct iscsi_attr *attr, *t; @@ -1222,10 +1222,10 @@ static int release(struct inode *inode, struct file *filp) const struct file_operations ctr_fops = { .owner = THIS_MODULE, - .unlocked_ioctl = ioctl, - .compat_ioctl = ioctl, - .open = open, - .release = release, + .unlocked_ioctl = iscsi_ioctl, + .compat_ioctl = iscsi_ioctl, + .open = iscsi_open, + .release = iscsi_release, }; #ifdef CONFIG_SCST_DEBUG diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index e713a1e43..572d6c440 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -397,7 +397,7 @@ struct iscsi_conn *conn_lookup(struct iscsi_session *session, u16 cid) */ list_for_each_entry_reverse(conn, &session->conn_list, conn_list_entry) { - if (conn->cid == cid) + if (conn->cid == cid && !conn->closing) return conn; } return NULL; diff --git a/iscsi-scst/kernel/iscsi.c b/iscsi-scst/kernel/iscsi.c index 1a5ac0991..54205077f 100644 --- a/iscsi-scst/kernel/iscsi.c +++ b/iscsi-scst/kernel/iscsi.c @@ -2154,6 +2154,9 @@ static int scsi_cmnd_start(struct iscsi_cmnd *req) req->scst_state = ISCSI_CMD_STATE_RX_CMD; conn->rx_task = current; scst_cmd_init_stage1_done(scst_cmd, SCST_CONTEXT_DIRECT, 0); +#ifdef CONFIG_SCST_EXTRACHECKS + conn->rx_task = NULL; +#endif if (req->scst_state != ISCSI_CMD_STATE_RX_CMD) res = req->conn->transport->iscsit_receive_cmnd_data(req); @@ -4237,7 +4240,7 @@ create: if (p == NULL) { PRINT_ERROR("Unable to allocate iSCSI thread pool (size %zd)", sizeof(*p)); - res = -ENOMEM; + res = 0; if (!list_empty(&iscsi_thread_pools_list)) { PRINT_WARNING("%s", "Using global iSCSI thread pool " "instead"); diff --git a/iscsi-scst/usr/event.c b/iscsi-scst/usr/event.c index 8d0734767..1d28ef9e9 100644 --- a/iscsi-scst/usr/event.c +++ b/iscsi-scst/usr/event.c @@ -1066,6 +1066,15 @@ retry: goto retry; log_error("read netlink fd (%d) failed: %s", fd, strerror(errno)); exit(1); + } else if (rc == 0) { + /* + * EOF on nl_fd -- + * We arrive here after the kernel module closes the other end + * of nl_fd during shutdown of the kernel modules. The daemon + * thread is expected to exit when this happens. + */ + log_info("kernel module shutdown -- daemon exits"); + exit(1); } log_debug(1, "target %u, session %#" PRIx64 ", conn %u, code %u, cookie %d", diff --git a/iscsi-scst/usr/iscsi_scstd.c b/iscsi-scst/usr/iscsi_scstd.c index 7fa813d04..d66943087 100644 --- a/iscsi-scst/usr/iscsi_scstd.c +++ b/iscsi-scst/usr/iscsi_scstd.c @@ -846,8 +846,13 @@ int main(int argc, char **argv) /* * Otherwise we could die in some later write() during the event_loop() * instead of getting EPIPE! + * + * The effects of signal(2) in a multithreaded process are unspecified, + * so use sigaction(2) instead. */ - signal(SIGPIPE, SIG_IGN); + struct sigaction act = (struct sigaction) { .sa_handler = SIG_IGN }; + int rc = sigaction(SIGPIPE, &act, NULL); + assert(rc == 0); while ((ch = getopt_long(argc, argv, "c:fd:s:u:g:a:p:vh", long_options, &longindex)) >= 0) { switch (ch) { diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index 19cddff2e..2e2c4caf4 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -1700,6 +1700,11 @@ next: dev->dev_rd_only = virt_dev->rd_only; +#ifdef CONFIG_SCST_PROC + if (virt_dev->nullio && !virt_dev->file_size) + virt_dev->file_size = VDISK_NULLIO_SIZE; +#endif + res = vdisk_reexamine(virt_dev); if (res < 0) goto out; diff --git a/usr/fileio/common.c b/usr/fileio/common.c index d40caafbf..636b0a707 100644 --- a/usr/fileio/common.c +++ b/usr/fileio/common.c @@ -747,7 +747,7 @@ static int process_cmd(struct vdisk_cmd *vcmd) case SCST_USER_TASK_MGMT_DONE: res = do_tm(vcmd, 1); -#if DEBUG_TM_FN_IGNORE +#ifdef DEBUG_TM_FN_IGNORE if (dev->debug_tm_ignore) { sleep(15); }