From 6c9ea47b23592de5fc783d3760f7d7e5fe4c47b9 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 31 Oct 2013 03:53:14 +0000 Subject: [PATCH] Disable automatic sessions unregistration Nowadays scst_local doesn't need anymore auto closing sessions on target unregistration. Moreover, it can lead for it to the following Oops: BUG at /home/bart/software/scst.git/scst/src/scst_targ.c:6293 ------------[ cut here ]------------ kernel BUG at /home/bart/software/scst.git/scst/src/scst_targ.c:6293! RIP: 0010:[] [] scst_post_rx_mgmt_cmd+0x2b0/0x340 [scst] Call Trace: [] scst_rx_mgmt_fn+0xe9/0x3a0 [scst] [] scst_rx_mgmt_fn_lun.constprop.34+0x4a/0x60 [scst] [] scst_unregister_session+0x94/0x250 [scst] [] scst_local_release_adapter+0xa8/0x160 [scst_local] [] device_release+0x3d/0xb0 [] kobject_cleanup+0x82/0x1b0 [] kobject_put+0x2b/0x60 [] put_device+0x17/0x20 [] scsi_host_dev_release+0xb3/0xe0 [scsi_mod] [] device_release+0x3d/0xb0 [] kobject_cleanup+0x82/0x1b0 [] kobject_put+0x2b/0x60 [] put_device+0x17/0x20 [] scsi_target_dev_release+0x22/0x30 [scsi_mod] [] device_release+0x3d/0xb0 [] kobject_cleanup+0x82/0x1b0 [] kobject_put+0x2b/0x60 [] put_device+0x17/0x20 [] scsi_device_dev_release_usercontext+0x1a5/0x1c0 [scsi_mod] [] execute_in_process_context+0x65/0x70 [] scsi_device_dev_release+0x1c/0x20 [scsi_mod] [] device_release+0x3d/0xb0 [] kobject_cleanup+0x82/0x1b0 [] kobject_put+0x2b/0x60 [] put_device+0x17/0x20 [] scsi_device_put+0x44/0x60 [scsi_mod] [] scsi_disk_put+0x39/0x50 [sd_mod] [] sd_release+0x4b/0xd0 [sd_mod] [] __blkdev_put+0x16c/0x1c0 [] ? _raw_spin_lock_irq+0x17/0x40 [] blkdev_put+0x57/0x130 [] blkdev_close+0x25/0x30 [] __fput+0xdb/0x230 [] ____fput+0xe/0x10 [] task_work_run+0xa7/0xe0 [] do_notify_resume+0x79/0xa0 [] int_signal+0x12/0x17 So, experimantally disable this functionality. Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5083 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_main.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 66dd2ed94..663012c75 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -613,7 +613,6 @@ static inline int test_sess_list(struct scst_tgt *tgt) */ void scst_unregister_target(struct scst_tgt *tgt) { - struct scst_session *sess; struct scst_tgt_template *vtt = tgt->tgtt; #ifndef CONFIG_SCST_PROC struct scst_acg *acg, *acg_tmp; @@ -636,21 +635,26 @@ void scst_unregister_target(struct scst_tgt *tgt) tgt->tgtt->release(tgt); TRACE_DBG("%s", "Target driver's release() returned"); +#if 0 /* Looks not needed. For scst_local it's bad, see this commit log message */ mutex_lock(&scst_mutex); again: - list_for_each_entry(sess, &tgt->sess_list, sess_list_entry) { - if (sess->shut_phase == SCST_SESS_SPH_READY) { - /* - * Sometimes it's hard for target driver to track all - * its sessions (see scst_local, eg), so let's help it. - */ - mutex_unlock(&scst_mutex); - scst_unregister_session(sess, 0, NULL); - mutex_lock(&scst_mutex); - goto again; + { + struct scst_session *sess; + list_for_each_entry(sess, &tgt->sess_list, sess_list_entry) { + if (sess->shut_phase == SCST_SESS_SPH_READY) { + /* + * Sometimes it's hard for target driver to + * track all its sessions, so let's help it. + */ + mutex_unlock(&scst_mutex); + scst_unregister_session(sess, 0, NULL); + mutex_lock(&scst_mutex); + goto again; + } } } mutex_unlock(&scst_mutex); +#endif TRACE_DBG("%s", "Waiting for sessions shutdown"); wait_event(tgt->unreg_waitQ, test_sess_list(tgt));