| 
      
      
      From: <vl...@us...> - 2012-10-02 18:47:38
       | 
| Revision: 4542
          http://scst.svn.sourceforge.net/scst/?rev=4542&view=rev
Author:   vlnb
Date:     2012-10-02 18:47:29 +0000 (Tue, 02 Oct 2012)
Log Message:
-----------
Logging improvements
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2012-10-02 08:30:15 UTC (rev 4541)
+++ trunk/scst/src/scst_targ.c	2012-10-02 18:47:29 UTC (rev 4542)
@@ -4918,16 +4918,23 @@
 		}
 
 		if (mstb->done_counted || mstb->finish_counted) {
-			PRINT_INFO("cmd %p (tag %llu, "
+			unsigned long t;
+			if (mcmd->fn != SCST_PR_ABORT_ALL)
+				t = TRACE_MGMT;
+			else
+				t = TRACE_MGMT_DEBUG;
+			TRACE(t, "cmd %p (tag %llu, "
 				"sn %u) being executed/xmitted (state %d, "
 				"op %x, proc time %ld sec., timeout %d sec.), "
 				"deferring ABORT (cmd_done_wait_count %d, "
-				"cmd_finish_wait_count %d, internal %d)", cmd,
+				"cmd_finish_wait_count %d, internal %d, mcmd "
+				"fn %d (mcmd %p))", cmd,
 				(long long unsigned int)cmd->tag,
 				cmd->sn, cmd->state, cmd->cdb[0],
 				(long)(jiffies - cmd->start_time) / HZ,
 				cmd->timeout / HZ, mcmd->cmd_done_wait_count,
-				mcmd->cmd_finish_wait_count, cmd->internal);
+				mcmd->cmd_finish_wait_count, cmd->internal,
+				mcmd->fn, mcmd);
 			/*
 			 * cmd can't die here or sess_list_lock already taken
 			 * and cmd is in the sess list
@@ -5873,10 +5880,10 @@
 		scst_mgmt_cmd_set_status(mcmd, SCST_MGMT_STATUS_TASK_NOT_EXIST);
 
 	if (mcmd->fn < SCST_UNREG_SESS_TM)
-		TRACE(TRACE_MGMT, "TM fn %d (%p) finished, "
+		TRACE(TRACE_MGMT, "TM fn %d (mcmd %p) finished, "
 			"status %d", mcmd->fn, mcmd, mcmd->status);
 	else
-		TRACE_MGMT_DBG("TM fn %d (%p) finished, "
+		TRACE_MGMT_DBG("TM fn %d (mcmd %p) finished, "
 			"status %d", mcmd->fn, mcmd, mcmd->status);
 
 	if (mcmd->fn == SCST_PR_ABORT_ALL) {
@@ -6203,11 +6210,11 @@
 	mcmd->cmd_sn = params->cmd_sn;
 
 	if (params->fn < SCST_UNREG_SESS_TM)
-		TRACE(TRACE_MGMT, "TM fn %d (%p, initiator %s, target %s)",
+		TRACE(TRACE_MGMT, "TM fn %d (mcmd %p, initiator %s, target %s)",
 			params->fn, mcmd, sess->initiator_name,
 			sess->tgt->tgt_name);
 	else
-		TRACE_MGMT_DBG("TM fn %d (%p)", params->fn, mcmd);
+		TRACE_MGMT_DBG("TM fn %d (mcmd %p)", params->fn, mcmd);
 
 	TRACE_MGMT_DBG("sess=%p, tag_set %d, tag %lld, lun_set %d, "
 		"lun=%lld, cmd_sn_set %d, cmd_sn %d, priv %p", sess,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2012-10-04 22:18:07
       | 
| Revision: 4548
          http://scst.svn.sourceforge.net/scst/?rev=4548&view=rev
Author:   vlnb
Date:     2012-10-04 22:18:01 +0000 (Thu, 04 Oct 2012)
Log Message:
-----------
Cleanup
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2012-10-04 22:08:02 UTC (rev 4547)
+++ trunk/scst/src/scst_targ.c	2012-10-04 22:18:01 UTC (rev 4548)
@@ -2687,6 +2687,19 @@
 	goto out;
 }
 
+typedef int (*scst_local_exec_fn)(struct scst_cmd *cmd);
+
+static scst_local_exec_fn scst_local_fns[256] = {
+	[RESERVE] = scst_reserve_local,
+	[RESERVE_10] = scst_reserve_local,
+	[RELEASE] = scst_release_local,
+	[RELEASE_10] = scst_release_local,
+	[PERSISTENT_RESERVE_IN] = scst_persistent_reserve_in_local,
+	[PERSISTENT_RESERVE_OUT] = scst_persistent_reserve_out_local,
+	[REPORT_LUNS] = scst_report_luns_local,
+	[REQUEST_SENSE] = scst_request_sense_local,
+};
+
 static int scst_do_local_exec(struct scst_cmd *cmd)
 {
 	int res;
@@ -2711,31 +2724,7 @@
 		goto out;
 	}
 
-	switch (cmd->cdb[0]) {
-	case RESERVE:
-	case RESERVE_10:
-		res = scst_reserve_local(cmd);
-		break;
-	case RELEASE:
-	case RELEASE_10:
-		res = scst_release_local(cmd);
-		break;
-	case PERSISTENT_RESERVE_IN:
-		res = scst_persistent_reserve_in_local(cmd);
-		break;
-	case PERSISTENT_RESERVE_OUT:
-		res = scst_persistent_reserve_out_local(cmd);
-		break;
-	case REPORT_LUNS:
-		res = scst_report_luns_local(cmd);
-		break;
-	case REQUEST_SENSE:
-		res = scst_request_sense_local(cmd);
-		break;
-	default:
-		res = SCST_EXEC_NOT_COMPLETED;
-		break;
-	}
+	res = scst_local_fns[cmd->cdb[0]](cmd);
 
 out:
 	TRACE_EXIT_RES(res);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2012-12-12 00:09:22
       | 
| Revision: 4641
          http://scst.svn.sourceforge.net/scst/?rev=4641&view=rev
Author:   vlnb
Date:     2012-12-12 00:09:11 +0000 (Wed, 12 Dec 2012)
Log Message:
-----------
scst, persistent reservations: Fix a locking error
Avoid that a command like sg_raw -r256 /dev/sda 5e 04 00 00 00 00 00 20 00 00
triggers the following error messages on a kernel with PROVE_LOCKING enabled:
=====================================
[ BUG: bad unlock balance detected! ]
3.7.0-rc5-debug+ #1 Tainted: G           O
-------------------------------------
disk010_1/9985 is trying to release lock (&dev->dev_pr_mutex) at:
[<ffffffff814b742e>] mutex_unlock+0xe/0x10
but there are no more locks to release!
other info that might help us debug this:
no locks held by disk010_1/9985.
stack backtrace:
Pid: 9985, comm: disk010_1 Tainted: G           O 3.7.0-rc5-debug+ #1
Call Trace:
 [<ffffffff8109598e>] print_unlock_inbalance_bug+0xfe/0x110
 [<ffffffff81098bc6>] lock_release+0x1f6/0x260
 [<ffffffff814b734a>] __mutex_unlock_slowpath+0x9a/0x170
 [<ffffffff814b742e>] mutex_unlock+0xe/0x10
 [<ffffffffa02d7d0f>] scst_pr_write_unlock+0x4f/0xd0 [scst]
 [<ffffffffa02db83c>] scst_persistent_reserve_in_local+0x2cc/0x470 [scst]
 [<ffffffffa02d99bf>] scst_do_local_exec+0x15f/0x1c0 [scst]
 [<ffffffffa02e35d0>] scst_exec_check_blocking+0xd0/0x2c0 [scst]
 [<ffffffffa02e3955>] scst_exec_check_sn+0x195/0x2f0 [scst]
 [<ffffffffa02e5249>] scst_process_active_cmd+0x549/0x780 [scst]
 [<ffffffffa02e5509>] scst_do_job_active+0x89/0x1a0 [scst]
 [<ffffffffa02e5883>] scst_cmd_thread+0x183/0x310 [scst]
 [<ffffffff81063ccd>] kthread+0xed/0x100
 [<ffffffff814c2aac>] ret_from_fork+0x7c/0xb0
Signed-off-by: Bart Van Assche <bva...@ac...>
Revision Links:
--------------
    http://scst.svn.sourceforge.net/scst/?rev=256&view=rev
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2012-12-11 02:57:16 UTC (rev 4640)
+++ trunk/scst/src/scst_targ.c	2012-12-12 00:09:11 UTC (rev 4641)
@@ -2190,7 +2190,6 @@
 		break;
 	default:
 		PRINT_ERROR("Unsupported action %x", action);
-		scst_pr_write_unlock(dev);
 		goto out_unsup_act;
 	}
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2012-12-20 02:20:30
       | 
| Revision: 4656
          http://scst.svn.sourceforge.net/scst/?rev=4656&view=rev
Author:   vlnb
Date:     2012-12-20 02:20:24 +0000 (Thu, 20 Dec 2012)
Log Message:
-----------
scst_get_unique_sess_name(): Handle out-of-memory properly
Return NULL instead of triggering a NULL pointer dereference if out
of memory. Detected by Coverity.
Signed-off-by: Bart Van Assche <bva...@ac...>
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2012-12-20 02:17:23 UTC (rev 4655)
+++ trunk/scst/src/scst_targ.c	2012-12-20 02:20:24 UTC (rev 4656)
@@ -6474,6 +6474,7 @@
 					PRINT_ERROR("Unable to allocate a "
 						"replacement name (size %d)",
 						len);
+					break;
 				}
 			}
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2013-01-09 01:42:16
       | 
| Revision: 4727
          http://scst.svn.sourceforge.net/scst/?rev=4727&view=rev
Author:   vlnb
Date:     2013-01-09 01:42:10 +0000 (Wed, 09 Jan 2013)
Log Message:
-----------
scst, SCSI pass-through: Do not complain unnecessarily about max_hw_sectors
cmd->bufflen is in bytes so it has to be divided by the sector size before
being compared with queue_max_hw_sectors(). Other changes included in this
patch:
* Print the "rc" error code as a signed integer instead of as an unsigned
  hex number.
* Change "(int)rc" into "rc". The cast isn't necessary because rc has type
  int.
* Insert a "0x" prefix in front of the SCSI CDB opcode.
Signed-off-by: Bart Van Assche <bva...@ac...>
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2013-01-09 01:38:05 UTC (rev 4726)
+++ trunk/scst/src/scst_targ.c	2013-01-09 01:42:10 UTC (rev 4727)
@@ -2612,11 +2612,12 @@
 	rc = scst_scsi_exec_async(cmd, cmd, scst_pass_through_cmd_done);
 #endif
 	if (unlikely(rc != 0)) {
-		PRINT_ERROR("scst pass-through exec failed: %x", rc);
-		if (((int)rc == -EINVAL) &&
-		    (cmd->bufflen > queue_max_hw_sectors(scsi_dev->request_queue)))
+		PRINT_ERROR("scst pass-through exec failed: %d", rc);
+		/* "Sectors" are hardcoded as 512 bytes in the kernel */
+		if (rc == -EINVAL &&
+		    (cmd->bufflen >> 9) > queue_max_hw_sectors(scsi_dev->request_queue))
 			PRINT_ERROR("Too low max_hw_sectors %d sectors on %s "
-				"to serve command %x with bufflen %db."
+				"to serve command %#x with bufflen %d bytes."
 				"See README for more details.",
 				queue_max_hw_sectors(scsi_dev->request_queue),
 				dev->virt_name, cmd->cdb[0], cmd->bufflen);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2013-10-02 04:53:15
       | 
| Revision: 5014
          http://sourceforge.net/p/scst/svn/5014
Author:   vlnb
Date:     2013-10-02 04:53:12 +0000 (Wed, 02 Oct 2013)
Log Message:
-----------
Change write residual underflow handling
Now it writes only supplied amount of data.
Reported by Klaus Hochlehnert <Mai...@kh...>
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2013-10-01 06:21:38 UTC (rev 5013)
+++ trunk/scst/src/scst_targ.c	2013-10-02 04:53:12 UTC (rev 5014)
@@ -1588,19 +1588,23 @@
 
 	if (unlikely(cmd->resid_possible)) {
 		if (cmd->data_direction & SCST_DATA_WRITE) {
-			bool do_zero = false;
+			bool remainder = false;
 			if (cmd->data_direction & SCST_DATA_READ) {
 				if (cmd->write_len != cmd->out_bufflen)
-					do_zero = true;
+					remainder = true;
 			} else {
 				if (cmd->write_len != cmd->bufflen)
-					do_zero = true;
+					remainder = true;
 			}
-			if (do_zero) {
+			if (remainder) {
 				if (!(cmd->op_flags & SCST_TRANSFER_LEN_TYPE_FIXED) ||
 				    (cmd->write_len & ((1 << cmd->dev->block_shift) - 1)) == 0) {
+#if 0 /* dangerous, because can override valid data by zeros */
 					scst_check_restore_sg_buff(cmd);
 					scst_zero_write_rest(cmd);
+#else
+					/* do nothing */
+#endif
 				} else {
 					/*
 					 * Looks like it's safer in this case to
@@ -3109,6 +3113,8 @@
 					cmd->sense = NULL;
 
 					scst_check_restore_sg_buff(cmd);
+					if (cmd->data_direction & SCST_DATA_WRITE)
+						scst_set_write_len(cmd);
 
 					sBUG_ON(cmd->dbl_ua_orig_resp_data_len < 0);
 					cmd->data_direction =
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2014-04-04 00:57:35
       | 
| Revision: 5404
          http://sourceforge.net/p/scst/svn/5404
Author:   vlnb
Date:     2014-04-04 00:57:30 +0000 (Fri, 04 Apr 2014)
Log Message:
-----------
Fix typo in scst_report_supported_tm_fns() reported by Steve Magnani <ste...@di...>
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2014-04-03 15:58:16 UTC (rev 5403)
+++ trunk/scst/src/scst_targ.c	2014-04-04 00:57:30 UTC (rev 5404)
@@ -2087,7 +2087,7 @@
 #if 1
 		buf[4] = 1; /* TMFTMOV */
 		buf[6] = 0x80; /* ATTS */
-		put_unaligned_be32(30, &buf[8]); /* long timeout - 30 sec. */
+		put_unaligned_be32(300, &buf[8]); /* long timeout - 30 sec. */
 		put_unaligned_be32(150, &buf[12]); /* short timeout - 15 sec. */
 #endif
 		resp_len = 16;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2014-04-29 00:13:27
       | 
| Revision: 5490
          http://sourceforge.net/p/scst/svn/5490
Author:   vlnb
Date:     2014-04-29 00:13:24 +0000 (Tue, 29 Apr 2014)
Log Message:
-----------
It's wrong to clean reservation on failed RESERVE commands
With multiple outstanding commands it can open a race window leading to
loose of a valid reservation
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2014-04-28 22:30:03 UTC (rev 5489)
+++ trunk/scst/src/scst_targ.c	2014-04-29 00:13:24 UTC (rev 5490)
@@ -3595,23 +3595,6 @@
 		TRACE(TRACE_SCSI, "cmd %p not succeeded with status %x",
 			cmd, cmd->status);
 
-		if ((cmd->cdb[0] == RESERVE) || (cmd->cdb[0] == RESERVE_10)) {
-			struct scst_device *dev = cmd->dev;
-
-			if (scst_is_reservation_holder(dev, cmd->sess)) {
-				TRACE(TRACE_SCSI, "RESERVE failed lun=%lld, "
-					"status=%x",
-					(long long unsigned int)cmd->lun,
-					cmd->status);
-				PRINT_BUFF_FLAG(TRACE_SCSI, "Sense", cmd->sense,
-					cmd->sense_valid_len);
-
-				spin_lock_bh(&dev->dev_lock);
-				scst_clear_dev_reservation(dev);
-				spin_unlock_bh(&dev->dev_lock);
-			}
-		}
-
 		/* Check for MODE PARAMETERS CHANGED UA */
 		if ((cmd->dev->scsi_dev != NULL) &&
 		    (cmd->status == SAM_STAT_CHECK_CONDITION) &&
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2014-04-29 02:09:32
       | 
| Revision: 5493
          http://sourceforge.net/p/scst/svn/5493
Author:   vlnb
Date:     2014-04-29 02:09:29 +0000 (Tue, 29 Apr 2014)
Log Message:
-----------
Minor logging improvement
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2014-04-29 01:45:43 UTC (rev 5492)
+++ trunk/scst/src/scst_targ.c	2014-04-29 02:09:29 UTC (rev 5493)
@@ -2533,8 +2533,8 @@
 
 	action = cmd->cdb[1] & 0x1f;
 
-	TRACE(TRACE_SCSI, "PR action %x for '%s' (LUN %llx) from '%s'", action,
-	    dev->virt_name, tgt_dev->lun, session->initiator_name);
+	TRACE(TRACE_SCSI, "PR IN action %x for '%s' (LUN %llx) from '%s'",
+		action, dev->virt_name, tgt_dev->lun, session->initiator_name);
 
 	switch (action) {
 	case PR_READ_KEYS:
@@ -2605,8 +2605,8 @@
 
 	action = cmd->cdb[1] & 0x1f;
 
-	TRACE(TRACE_SCSI, "PR action %x for '%s' (LUN %llx) from '%s'", action,
-	    dev->virt_name, tgt_dev->lun, session->initiator_name);
+	TRACE(TRACE_SCSI, "PR OUT action %x for '%s' (LUN %llx) from '%s'",
+		action, dev->virt_name, tgt_dev->lun, session->initiator_name);
 
 	if (scst_dev_reserved(dev)) {
 		TRACE_PR("PR command rejected, because device %s holds regular "
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2014-06-20 04:00:50
       | 
| Revision: 5613
          http://sourceforge.net/p/scst/svn/5613
Author:   vlnb
Date:     2014-06-20 04:00:41 +0000 (Fri, 20 Jun 2014)
Log Message:
-----------
scst: Convert a loop to keep smatch happy
Avoid that smatch reports the following warning:
scst_init_session() info: loop could be replaced with if statement.
Signed-off-by: Bart Van Assche <bva...@ac...>
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2014-06-19 12:48:25 UTC (rev 5612)
+++ trunk/scst/src/scst_targ.c	2014-06-20 04:00:41 UTC (rev 5613)
@@ -7025,7 +7025,7 @@
 static int scst_init_session(struct scst_session *sess)
 {
 	int res = 0;
-	struct scst_cmd *cmd;
+	struct scst_cmd *cmd, *cmd_tmp;
 	struct scst_mgmt_cmd *mcmd, *tm;
 	int mwake = 0;
 
@@ -7096,16 +7096,14 @@
 	else
 		sess->init_phase = SCST_SESS_IPH_FAILED;
 
-restart:
-	list_for_each_entry(cmd, &sess->init_deferred_cmd_list,
-				cmd_list_entry) {
+	list_for_each_entry_safe(cmd, cmd_tmp, &sess->init_deferred_cmd_list,
+				 cmd_list_entry) {
 		TRACE_DBG("Deleting cmd %p from init deferred cmd list", cmd);
 		list_del(&cmd->cmd_list_entry);
 		atomic_dec(&sess->sess_cmd_count);
 		spin_unlock_irq(&sess->sess_list_lock);
 		scst_cmd_init_done(cmd, SCST_CONTEXT_THREAD);
 		spin_lock_irq(&sess->sess_list_lock);
-		goto restart;
 	}
 
 	spin_lock(&scst_mcmd_lock);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2014-07-19 04:08:33
       | 
| Revision: 5684
          http://sourceforge.net/p/scst/svn/5684
Author:   vlnb
Date:     2014-07-19 04:08:30 +0000 (Sat, 19 Jul 2014)
Log Message:
-----------
scst: Clean up scst_process_active_cmd()
Since inside scst_process_active_cmd() cmd->state can only change after
cmd has been added back to the command list it is safe to perform the
cmd->state check without holding the command list lock. Hence move the
perform the cmd->state check without holding the command list lock.
Signed-off-by: Bart Van Assche <bva...@ac...>
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2014-07-19 03:54:33 UTC (rev 5683)
+++ trunk/scst/src/scst_targ.c	2014-07-19 04:08:30 UTC (rev 5684)
@@ -4845,7 +4845,6 @@
 	if (res == SCST_CMD_STATE_RES_CONT_NEXT) {
 		/* None */
 	} else if (res == SCST_CMD_STATE_RES_NEED_THREAD) {
-		spin_lock_irq(&cmd->cmd_threads->cmd_list_lock);
 #ifdef CONFIG_SCST_EXTRACHECKS
 		switch (cmd->state) {
 		case SCST_CMD_STATE_PARSE:
@@ -4858,22 +4857,18 @@
 		case SCST_CMD_STATE_REAL_EXEC:
 		case SCST_CMD_STATE_DEV_DONE:
 		case SCST_CMD_STATE_XMIT_RESP:
-#endif
-			TRACE_DBG("Adding cmd %p to head of active cmd list",
-				  cmd);
-			list_add(&cmd->cmd_list_entry,
-				&cmd->cmd_threads->active_cmd_list);
-#ifdef CONFIG_SCST_EXTRACHECKS
 			break;
 		default:
 			PRINT_CRIT_ERROR("cmd %p is in invalid state %d)", cmd,
 				cmd->state);
-#if !defined(__CHECKER__)
-			spin_unlock_irq(&cmd->cmd_threads->cmd_list_lock);
-#endif
 			sBUG();
 		}
 #endif
+		TRACE_DBG("Adding cmd %p to head of active cmd list", cmd);
+
+		spin_lock_irq(&cmd->cmd_threads->cmd_list_lock);
+		list_add(&cmd->cmd_list_entry,
+			 &cmd->cmd_threads->active_cmd_list);
 		wake_up(&cmd->cmd_threads->cmd_list_waitQ);
 		spin_unlock_irq(&cmd->cmd_threads->cmd_list_lock);
 	} else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2014-07-28 23:11:17
       | 
| Revision: 5705
          http://sourceforge.net/p/scst/svn/5705
Author:   vlnb
Date:     2014-07-28 23:11:14 +0000 (Mon, 28 Jul 2014)
Log Message:
-----------
Print initiator and target in the abort messages
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2014-07-26 00:04:51 UTC (rev 5704)
+++ trunk/scst/src/scst_targ.c	2014-07-28 23:11:14 UTC (rev 5705)
@@ -5424,13 +5424,14 @@
 				"op %s, proc time %ld sec., timeout %d sec.), "
 				"deferring ABORT (cmd_done_wait_count %d, "
 				"cmd_finish_wait_count %d, internal %d, mcmd "
-				"fn %d (mcmd %p))", cmd,
-				(long long unsigned int)cmd->tag,
+				"fn %d (mcmd %p), initiator %s, target %s)",
+				cmd, (long long unsigned int)cmd->tag,
 				cmd->sn, cmd->state, scst_get_opcode_name(cmd),
 				(long)(jiffies - cmd->start_time) / HZ,
 				cmd->timeout / HZ, mcmd->cmd_done_wait_count,
 				mcmd->cmd_finish_wait_count, cmd->internal,
-				mcmd->fn, mcmd);
+				mcmd->fn, mcmd, mcmd->sess->initiator_name,
+				mcmd->sess->tgt->tgt_name);
 			/*
 			 * cmd can't die here or sess_list_lock already taken
 			 * and cmd is in the sess list
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2014-07-30 02:52:32
       | 
| Revision: 5707
          http://sourceforge.net/p/scst/svn/5707
Author:   vlnb
Date:     2014-07-30 02:52:26 +0000 (Wed, 30 Jul 2014)
Log Message:
-----------
Follow up for r5704: NO SENSE is also valid sense
Revision Links:
--------------
    http://sourceforge.net/p/scst/svn/5704
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2014-07-30 02:27:10 UTC (rev 5706)
+++ trunk/scst/src/scst_targ.c	2014-07-30 02:52:26 UTC (rev 5707)
@@ -3475,7 +3475,7 @@
 	TRACE_ENTRY();
 
 	if (unlikely(cmd->status == SAM_STAT_CHECK_CONDITION) &&
-	    (!scst_sense_valid(cmd->sense) || scst_no_sense(cmd->sense))) {
+	    !scst_sense_valid(cmd->sense)) {
 		if (!test_bit(SCST_CMD_ABORTED, &cmd->cmd_flags)) {
 			TRACE(TRACE_SCSI|TRACE_MINOR_AND_MGMT_DBG,
 				"CHECK_CONDITION, but no sense: cmd->status=%x, "
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2014-11-15 01:44:13
       | 
| Revision: 5855
          http://sourceforge.net/p/scst/svn/5855
Author:   vlnb
Date:     2014-11-15 01:44:06 +0000 (Sat, 15 Nov 2014)
Log Message:
-----------
Ease severity of reporting unsupported REPORT LUNS SELECT REPORT value
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2014-11-01 08:30:20 UTC (rev 5854)
+++ trunk/scst/src/scst_targ.c	2014-11-15 01:44:06 UTC (rev 5855)
@@ -1850,8 +1850,8 @@
 	cmd->driver_status = 0;
 
 	if ((cmd->cdb[2] != 0) && (cmd->cdb[2] != 2)) {
-		PRINT_ERROR("Unsupported SELECT REPORT value %x in REPORT "
-			"LUNS command", cmd->cdb[2]);
+		TRACE(TRACE_MINOR, "Unsupported SELECT REPORT value %x in "
+			"REPORT LUNS command", cmd->cdb[2]);
 		scst_set_invalid_field_in_cdb(cmd, 2, 0);
 		goto out_compl;
 	}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <bva...@us...> - 2015-01-13 08:51:16
       | 
| Revision: 5964
          http://sourceforge.net/p/scst/svn/5964
Author:   bvassche
Date:     2015-01-13 08:51:08 +0000 (Tue, 13 Jan 2015)
Log Message:
-----------
scst_parse_unmap_descriptors(): Avoid using GFP_KERNEL in atomic context
Reported-by: Shahar Salzman <sha...@ka...>
Signed-off-by: Bart Van Assche <bva...@ac...>
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-01-13 08:42:28 UTC (rev 5963)
+++ trunk/scst/src/scst_targ.c	2015-01-13 08:51:08 UTC (rev 5964)
@@ -1734,9 +1734,17 @@
 
 out_descr:
 	if (unlikely(cmd->op_flags & SCST_DESCRIPTORS_BASED)) {
-		int r = scst_parse_descriptors(cmd);
-		if (unlikely(r != 0))
+		if (scst_cmd_atomic(cmd)) {
+			/*
+			 * Switch to thread context such that
+			 * scst_parse_descriptors() can use GFP_KERNEL instead
+			 * of GFP_ATOMIC.
+			 */
+			res = SCST_CMD_STATE_RES_NEED_THREAD;
 			goto out;
+		}
+		if (unlikely(scst_parse_descriptors(cmd) != 0))
+			goto out;
 	}
 
 out:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <bva...@us...> - 2015-01-15 08:58:49
       | 
| Revision: 5968
          http://sourceforge.net/p/scst/svn/5968
Author:   bvassche
Date:     2015-01-15 08:58:39 +0000 (Thu, 15 Jan 2015)
Log Message:
-----------
scst_targ: Avoid triggering a kernel panic if dev_user_parse() returns SCST_CMD_STATE_STOP
Reported-by: Ilan Steinberg <ila...@ka...>
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-01-14 08:06:12 UTC (rev 5967)
+++ trunk/scst/src/scst_targ.c	2015-01-15 08:58:39 UTC (rev 5968)
@@ -635,7 +635,7 @@
 			TRACE_MGMT_DBG("Dev handler %s parse() needs thread "
 				"context, rescheduling", devt->name);
 			res = SCST_CMD_STATE_RES_NEED_THREAD;
-			goto out;
+			goto check_compl;
 		}
 
 		TRACE_DBG("Calling dev handler %s parse(%p)",
@@ -939,11 +939,11 @@
 		TRACE_DBG_FLAG(TRACE_DEBUG|TRACE_MINOR, "Atomic context and "
 			"non-WRITE data direction, rescheduling (cmd %p)", cmd);
 		res = SCST_CMD_STATE_RES_NEED_THREAD;
-		goto out;
+		goto check_compl;
 	}
 #endif
 
-out:
+check_compl:
 #ifdef CONFIG_SCST_EXTRACHECKS
 	if (unlikely(cmd->completed)) {
 		/* Command completed with error */
@@ -1000,6 +1000,7 @@
 		}
 	}
 
+out:
 	TRACE_EXIT_HRES(res);
 	return res;
 
@@ -1010,7 +1011,7 @@
 out_done:
 	scst_set_cmd_abnormal_done_state(cmd);
 	res = SCST_CMD_STATE_RES_CONT_SAME;
-	goto out;
+	goto check_compl;
 }
 
 static void scst_set_write_len(struct scst_cmd *cmd)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2015-01-16 03:16:30
       | 
| Revision: 5970
          http://sourceforge.net/p/scst/svn/5970
Author:   vlnb
Date:     2015-01-16 03:16:26 +0000 (Fri, 16 Jan 2015)
Log Message:
-----------
Follow up for r5968
Revision Links:
--------------
    http://sourceforge.net/p/scst/svn/5968
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-01-16 01:21:10 UTC (rev 5969)
+++ trunk/scst/src/scst_targ.c	2015-01-16 03:16:26 UTC (rev 5970)
@@ -635,7 +635,7 @@
 			TRACE_MGMT_DBG("Dev handler %s parse() needs thread "
 				"context, rescheduling", devt->name);
 			res = SCST_CMD_STATE_RES_NEED_THREAD;
-			goto check_compl;
+			goto out;
 		}
 
 		TRACE_DBG("Calling dev handler %s parse(%p)",
@@ -655,6 +655,9 @@
 			goto out;
 
 		case SCST_CMD_STATE_STOP:
+			/*
+			 * !! cmd can be dead now!
+			 */
 			TRACE_DBG("Dev handler %s parse() requested stop "
 				"processing", devt->name);
 			res = SCST_CMD_STATE_RES_CONT_NEXT;
@@ -939,11 +942,11 @@
 		TRACE_DBG_FLAG(TRACE_DEBUG|TRACE_MINOR, "Atomic context and "
 			"non-WRITE data direction, rescheduling (cmd %p)", cmd);
 		res = SCST_CMD_STATE_RES_NEED_THREAD;
-		goto check_compl;
+		/* go through */
 	}
 #endif
 
-check_compl:
+out_check_compl:
 #ifdef CONFIG_SCST_EXTRACHECKS
 	if (unlikely(cmd->completed)) {
 		/* Command completed with error */
@@ -1011,7 +1014,7 @@
 out_done:
 	scst_set_cmd_abnormal_done_state(cmd);
 	res = SCST_CMD_STATE_RES_CONT_SAME;
-	goto check_compl;
+	goto out_check_compl;
 }
 
 static void scst_set_write_len(struct scst_cmd *cmd)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2015-01-20 04:20:24
       | 
| Revision: 5978
          http://sourceforge.net/p/scst/svn/5978
Author:   vlnb
Date:     2015-01-20 04:20:13 +0000 (Tue, 20 Jan 2015)
Log Message:
-----------
Revert r5963 as not needed
Revision Links:
--------------
    http://sourceforge.net/p/scst/svn/5963
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-01-20 04:18:07 UTC (rev 5977)
+++ trunk/scst/src/scst_targ.c	2015-01-20 04:20:13 UTC (rev 5978)
@@ -1598,44 +1598,12 @@
 }
 EXPORT_SYMBOL(scst_rx_data);
 
-/*
- * Whether a command must be executed in thread context. Persistent reservation
- * commands need thread context because of dev_pr_mutex. Traditional reserve
- * and release commands need thread context because e.g. queueing a unit
- * attention needs either BH or thread context.
- */
-static inline bool scst_needs_thread_context(struct scst_cmd *cmd)
-{
-	switch (cmd->cdb[0]) {
-	case PERSISTENT_RESERVE_IN:
-	case PERSISTENT_RESERVE_OUT:
-	case RESERVE:
-	case RESERVE_10:
-	case RELEASE:
-	case RELEASE_10:
-		return true;
-	}
-
-	return false;
-}
-
 static int scst_tgt_pre_exec(struct scst_cmd *cmd)
 {
 	int res = SCST_CMD_STATE_RES_CONT_SAME, rc;
 
 	TRACE_ENTRY();
 
-	/* Switch to thread context before executing a reservation command. */
-	if (unlikely(scst_cmd_atomic(cmd) &&
-		     ((cmd->dev && cmd->dev->pr_is_set) ||
-		      scst_needs_thread_context(cmd)))) {
-		TRACE_DBG("Atomic context and %s, rescheduling (cmd %p)",
-			  cmd->dev && cmd->dev->pr_is_set ?
-			  "dev->pr_is_set" : "reservation command", cmd);
-		res = SCST_CMD_STATE_RES_NEED_THREAD;
-		goto out;
-	}
-
 #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING)
 	if (unlikely(trace_flag & TRACE_DATA_RECEIVED) &&
 	    (cmd->data_direction & SCST_DATA_WRITE)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <bva...@us...> - 2015-02-06 15:55:18
       | 
| Revision: 6025
          http://sourceforge.net/p/scst/svn/6025
Author:   bvassche
Date:     2015-02-06 15:55:16 +0000 (Fri, 06 Feb 2015)
Log Message:
-----------
scst_targ: Fix spelling in a source code comment
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-02-06 15:53:35 UTC (rev 6024)
+++ trunk/scst/src/scst_targ.c	2015-02-06 15:55:16 UTC (rev 6025)
@@ -2853,7 +2853,7 @@
  *
  * !! At this point cmd can be processed in parallel by some other thread!
  * !! As consecuence, no pointer in cmd, except cur_order_data and
- * !! sn_slot, can be touched here! The same is for aasignments to cmd's
+ * !! sn_slot, can be touched here! The same is for assignments to cmd's
  * !! fields. As protection cmd declared as const.
  *
  * Overall, cmd is passed here only for extra correctness checking.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2015-03-25 00:21:24
       | 
| Revision: 6147
          http://sourceforge.net/p/scst/svn/6147
Author:   vlnb
Date:     2015-03-25 00:21:16 +0000 (Wed, 25 Mar 2015)
Log Message:
-----------
Small logging improvement
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-03-19 00:01:03 UTC (rev 6146)
+++ trunk/scst/src/scst_targ.c	2015-03-25 00:21:16 UTC (rev 6147)
@@ -3409,6 +3409,7 @@
 
 	if (unlikely(cmd->status == SAM_STAT_CHECK_CONDITION) &&
 	    scst_sense_valid(cmd->sense)) {
+		TRACE(TRACE_SCSI, "cmd %p with valid sense received", cmd);
 		PRINT_BUFF_FLAG(TRACE_SCSI, "Sense", cmd->sense,
 			cmd->sense_valid_len);
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2015-03-26 00:04:31
       | 
| Revision: 6154
          http://sourceforge.net/p/scst/svn/6154
Author:   vlnb
Date:     2015-03-26 00:04:24 +0000 (Thu, 26 Mar 2015)
Log Message:
-----------
scst: Kernel 3.19 build fix
Signed-off-by: Bart Van Assche <bar...@sa...>
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-03-26 00:02:19 UTC (rev 6153)
+++ trunk/scst/src/scst_targ.c	2015-03-26 00:04:24 UTC (rev 6154)
@@ -29,6 +29,7 @@
 #include <linux/kthread.h>
 #include <linux/delay.h>
 #include <linux/ktime.h>
+#include <scsi/sg.h>
 
 #ifdef INSIDE_KERNEL_TREE
 #include <scst/scst.h>
@@ -5960,7 +5961,14 @@
 		/* dev->scsi_dev must be non-NULL here */
 		TRACE(TRACE_MGMT, "Resetting host %d bus ",
 			dev->scsi_dev->host->host_no);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
+		{
+			int arg = SG_SCSI_RESET_TARGET;
+
+			rc = scsi_ioctl_reset(dev->scsi_dev,
+					      (__force __user int *)&arg);
+		}
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
 		rc = scsi_reset_provider(dev->scsi_dev, SCSI_TRY_RESET_TARGET);
 #else
 		rc = scsi_reset_provider(dev->scsi_dev, SCSI_TRY_RESET_BUS);
@@ -6023,7 +6031,16 @@
 	if (dev->scsi_dev != NULL) {
 		TRACE(TRACE_MGMT, "Resetting host %d bus ",
 		      dev->scsi_dev->host->host_no);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
+		{
+			int arg = SG_SCSI_RESET_DEVICE;
+
+			rc = scsi_ioctl_reset(dev->scsi_dev,
+					      (__force __user int *)&arg);
+		}
+#else
 		rc = scsi_reset_provider(dev->scsi_dev, SCSI_TRY_RESET_DEVICE);
+#endif
 		TRACE(TRACE_MGMT, "scsi_reset_provider(%s) returned %d",
 		      dev->virt_name, rc);
 #if 0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <vl...@us...> - 2015-05-09 03:17:18
       | 
| Revision: 6206
          http://sourceforge.net/p/scst/svn/6206
Author:   vlnb
Date:     2015-05-09 03:17:16 +0000 (Sat, 09 May 2015)
Log Message:
-----------
Disable preemption during tasklet schedule for per-CPU variable usage
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-05-09 03:16:19 UTC (rev 6205)
+++ trunk/scst/src/scst_targ.c	2015-05-09 03:17:16 UTC (rev 6206)
@@ -73,9 +73,13 @@
 
 static inline void scst_schedule_tasklet(struct scst_cmd *cmd)
 {
-	struct scst_percpu_info *i = &scst_percpu_infos[smp_processor_id()];
+	struct scst_percpu_info *i;
 	unsigned long flags;
 
+	preempt_disable();
+
+	i = &scst_percpu_infos[smp_processor_id()];
+
 	if (atomic_read(&i->cpu_cmd_count) <= scst_max_tasklet_cmd) {
 		spin_lock_irqsave(&i->tasklet_lock, flags);
 		TRACE_DBG("Adding cmd %p to tasklet %d cmd list", cmd,
@@ -93,6 +97,8 @@
 		wake_up(&cmd->cmd_threads->cmd_list_waitQ);
 		spin_unlock_irqrestore(&cmd->cmd_threads->cmd_list_lock, flags);
 	}
+
+	preempt_enable();
 	return;
 }
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <bva...@us...> - 2015-06-09 14:52:09
       | 
| Revision: 6230
          http://sourceforge.net/p/scst/svn/6230
Author:   bvassche
Date:     2015-06-09 14:52:07 +0000 (Tue, 09 Jun 2015)
Log Message:
-----------
scst_targ: Fix a debug statement
See also patch "Merge t10-pi branch back" (r6192).
Revision Links:
--------------
    http://sourceforge.net/p/scst/svn/6192
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-06-09 13:55:53 UTC (rev 6229)
+++ trunk/scst/src/scst_targ.c	2015-06-09 14:52:07 UTC (rev 6230)
@@ -698,6 +698,7 @@
 		if (scst_cmd_is_expected_set(cmd)) {
 			TRACE(TRACE_MINOR, "Using initiator supplied values: "
 				"direction %d, transfer_len %d/%d/%d",
+				cmd->expected_data_direction,
 				scst_cmd_get_expected_transfer_len_data(cmd),
 				scst_cmd_get_expected_transfer_len_dif(cmd),
 				cmd->expected_out_transfer_len);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <bva...@us...> - 2015-06-17 00:01:26
       | 
| Revision: 6357
          http://sourceforge.net/p/scst/svn/6357
Author:   bvassche
Date:     2015-06-17 00:01:24 +0000 (Wed, 17 Jun 2015)
Log Message:
-----------
scst_targ: Add more debug code in scst_unblock_aborted_cmds()
Use lockdep to verify that the caller holds scst_mutex if the
scst_mutex_held argument has not been set.
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-06-17 00:00:40 UTC (rev 6356)
+++ trunk/scst/src/scst_targ.c	2015-06-17 00:01:24 UTC (rev 6357)
@@ -5617,6 +5617,8 @@
 
 	if (!scst_mutex_held)
 		mutex_lock(&scst_mutex);
+	else
+		lockdep_assert_held(&scst_mutex);
 
 	list_for_each_entry(dev, &scst_dev_list, dev_list_entry) {
 		struct scst_cmd *cmd, *tcmd;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
      
      
      From: <bva...@us...> - 2015-07-14 21:52:42
       | 
| Revision: 6422
          http://sourceforge.net/p/scst/svn/6422
Author:   bvassche
Date:     2015-07-14 21:52:40 +0000 (Tue, 14 Jul 2015)
Log Message:
-----------
scst_targ: Kernel 4.2 build fix
Modified Paths:
--------------
    trunk/scst/src/scst_targ.c
Modified: trunk/scst/src/scst_targ.c
===================================================================
--- trunk/scst/src/scst_targ.c	2015-07-14 21:50:51 UTC (rev 6421)
+++ trunk/scst/src/scst_targ.c	2015-07-14 21:52:40 UTC (rev 6422)
@@ -29,6 +29,7 @@
 #include <linux/kthread.h>
 #include <linux/delay.h>
 #include <linux/ktime.h>
+#include <linux/vmalloc.h>
 #include <scsi/sg.h>
 
 #ifdef INSIDE_KERNEL_TREE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |