Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b6427b6 authored by Bart Van Assche's avatar Bart Van Assche Committed by Nicholas Bellinger
Browse files

target: Move session check from target_put_sess_cmd() into target_release_cmd_kref()



This patch does not change any functionality.

Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: David Disseldorp <ddiss@suse.de>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent b1a2ecda
Loading
Loading
Loading
Loading
+19 −20
Original line number Original line Diff line number Diff line
@@ -2592,6 +2592,7 @@ static void target_release_cmd_kref(struct kref *kref)
	unsigned long flags;
	unsigned long flags;
	bool fabric_stop;
	bool fabric_stop;


	if (se_sess) {
		spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
		spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);


		spin_lock(&se_cmd->t_state_lock);
		spin_lock(&se_cmd->t_state_lock);
@@ -2608,23 +2609,21 @@ static void target_release_cmd_kref(struct kref *kref)
		}
		}
		list_del_init(&se_cmd->se_cmd_list);
		list_del_init(&se_cmd->se_cmd_list);
		spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
		spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
	}


	target_free_cmd_mem(se_cmd);
	target_free_cmd_mem(se_cmd);
	se_cmd->se_tfo->release_cmd(se_cmd);
	se_cmd->se_tfo->release_cmd(se_cmd);
}
}


/* target_put_sess_cmd - Check for active I/O shutdown via kref_put
/**
 * @se_cmd:	command descriptor to drop
 * target_put_sess_cmd - decrease the command reference count
 * @se_cmd:	command to drop a reference from
 *
 * Returns 1 if and only if this target_put_sess_cmd() call caused the
 * refcount to drop to zero. Returns zero otherwise.
 */
 */
int target_put_sess_cmd(struct se_cmd *se_cmd)
int target_put_sess_cmd(struct se_cmd *se_cmd)
{
{
	struct se_session *se_sess = se_cmd->se_sess;

	if (!se_sess) {
		target_free_cmd_mem(se_cmd);
		se_cmd->se_tfo->release_cmd(se_cmd);
		return 1;
	}
	return kref_put(&se_cmd->cmd_kref, target_release_cmd_kref);
	return kref_put(&se_cmd->cmd_kref, target_release_cmd_kref);
}
}
EXPORT_SYMBOL(target_put_sess_cmd);
EXPORT_SYMBOL(target_put_sess_cmd);