mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-22 21:21:28 +00:00
scst: Complain about unbalanced reference counts in the command processing path
There is no evidence that this is possible. This patch is a debugging help. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8497 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -2317,6 +2317,9 @@ struct scst_cmd {
|
||||
/* Set by WRITE VERIFY commands to trigger a verify after write */
|
||||
unsigned int do_verify:1;
|
||||
|
||||
/* For debugging purposes. */
|
||||
unsigned int owns_refcnt:1;
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
/* cmd's async flags */
|
||||
|
||||
@@ -4504,6 +4504,7 @@ static int scst_pre_xmit_response1(struct scst_cmd *cmd)
|
||||
* latency, so we should decrement them after cmd completed.
|
||||
*/
|
||||
smp_mb__before_atomic_dec();
|
||||
cmd->owns_refcnt = false;
|
||||
scst_tgt_dev_dec_cmd_count(cmd->tgt_dev);
|
||||
percpu_ref_put(&cmd->dev->refcnt);
|
||||
#ifdef CONFIG_SCST_PER_DEVICE_CMD_COUNT_LIMIT
|
||||
@@ -4693,6 +4694,8 @@ static int scst_finish_cmd(struct scst_cmd *cmd)
|
||||
|
||||
TRACE_ENTRY();
|
||||
|
||||
WARN_ON_ONCE(cmd->owns_refcnt);
|
||||
|
||||
if (unlikely(cmd->delivery_status != SCST_CMD_DELIVERY_SUCCESS)) {
|
||||
if ((cmd->tgt_dev != NULL) &&
|
||||
(cmd->status == SAM_STAT_CHECK_CONDITION) &&
|
||||
@@ -5156,6 +5159,7 @@ static int __scst_init_cmd(struct scst_cmd *cmd)
|
||||
failure = true;
|
||||
}
|
||||
|
||||
cmd->owns_refcnt = true;
|
||||
percpu_ref_get(&dev->refcnt);
|
||||
#ifdef CONFIG_SCST_PER_DEVICE_CMD_COUNT_LIMIT
|
||||
atomic_inc(&dev->dev_cmd_count);
|
||||
|
||||
Reference in New Issue
Block a user