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

Commit d7175373 authored by Mike Christie's avatar Mike Christie Committed by Nicholas Bellinger
Browse files

target: fix ALUA transition timeout handling



The implicit transition time tells initiators the min time
to wait before timing out a transition. We currently schedule
the transition to occur in tg_pt_gp_implicit_trans_secs
seconds so there is no room for delays. If
core_alua_do_transition_tg_pt_work->core_alua_update_tpg_primary_metadata
needs to write out info to a remote file, then the initiator can
easily time out the operation.

Signed-off-by: default avatarMike Christie <mchristi@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 207ee841
Loading
Loading
Loading
Loading
+8 −15
Original line number Diff line number Diff line
@@ -1013,7 +1013,7 @@ static void core_alua_queue_state_change_ua(struct t10_alua_tg_pt_gp *tg_pt_gp)
static void core_alua_do_transition_tg_pt_work(struct work_struct *work)
{
	struct t10_alua_tg_pt_gp *tg_pt_gp = container_of(work,
		struct t10_alua_tg_pt_gp, tg_pt_gp_transition_work.work);
		struct t10_alua_tg_pt_gp, tg_pt_gp_transition_work);
	struct se_device *dev = tg_pt_gp->tg_pt_gp_dev;
	bool explicit = (tg_pt_gp->tg_pt_gp_alua_access_status ==
			 ALUA_STATUS_ALTERED_BY_EXPLICIT_STPG);
@@ -1076,13 +1076,12 @@ static int core_alua_do_transition_tg_pt(
	/*
	 * Flush any pending transitions
	 */
	if (!explicit && tg_pt_gp->tg_pt_gp_implicit_trans_secs &&
	    atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state) ==
	if (!explicit && atomic_read(&tg_pt_gp->tg_pt_gp_alua_access_state) ==
	    ALUA_ACCESS_STATE_TRANSITION) {
		/* Just in case */
		tg_pt_gp->tg_pt_gp_alua_pending_state = new_state;
		tg_pt_gp->tg_pt_gp_transition_complete = &wait;
		flush_delayed_work(&tg_pt_gp->tg_pt_gp_transition_work);
		flush_work(&tg_pt_gp->tg_pt_gp_transition_work);
		wait_for_completion(&wait);
		tg_pt_gp->tg_pt_gp_transition_complete = NULL;
		return 0;
@@ -1117,15 +1116,9 @@ static int core_alua_do_transition_tg_pt(
	atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt);
	spin_unlock(&dev->t10_alua.tg_pt_gps_lock);

	if (!explicit && tg_pt_gp->tg_pt_gp_implicit_trans_secs) {
		unsigned long transition_tmo;

		transition_tmo = tg_pt_gp->tg_pt_gp_implicit_trans_secs * HZ;
		schedule_delayed_work(&tg_pt_gp->tg_pt_gp_transition_work,
				      transition_tmo);
	} else {
	schedule_work(&tg_pt_gp->tg_pt_gp_transition_work);
	if (explicit) {
		tg_pt_gp->tg_pt_gp_transition_complete = &wait;
		schedule_delayed_work(&tg_pt_gp->tg_pt_gp_transition_work, 0);
		wait_for_completion(&wait);
		tg_pt_gp->tg_pt_gp_transition_complete = NULL;
	}
@@ -1696,7 +1689,7 @@ struct t10_alua_tg_pt_gp *core_alua_allocate_tg_pt_gp(struct se_device *dev,
	mutex_init(&tg_pt_gp->tg_pt_gp_md_mutex);
	spin_lock_init(&tg_pt_gp->tg_pt_gp_lock);
	atomic_set(&tg_pt_gp->tg_pt_gp_ref_cnt, 0);
	INIT_DELAYED_WORK(&tg_pt_gp->tg_pt_gp_transition_work,
	INIT_WORK(&tg_pt_gp->tg_pt_gp_transition_work,
		  core_alua_do_transition_tg_pt_work);
	tg_pt_gp->tg_pt_gp_dev = dev;
	atomic_set(&tg_pt_gp->tg_pt_gp_alua_access_state,
@@ -1805,7 +1798,7 @@ void core_alua_free_tg_pt_gp(
	dev->t10_alua.alua_tg_pt_gps_counter--;
	spin_unlock(&dev->t10_alua.tg_pt_gps_lock);

	flush_delayed_work(&tg_pt_gp->tg_pt_gp_transition_work);
	flush_work(&tg_pt_gp->tg_pt_gp_transition_work);

	/*
	 * Allow a struct t10_alua_tg_pt_gp_member * referenced by
+1 −1
Original line number Diff line number Diff line
@@ -299,7 +299,7 @@ struct t10_alua_tg_pt_gp {
	struct list_head tg_pt_gp_lun_list;
	struct se_lun *tg_pt_gp_alua_lun;
	struct se_node_acl *tg_pt_gp_alua_nacl;
	struct delayed_work tg_pt_gp_transition_work;
	struct work_struct tg_pt_gp_transition_work;
	struct completion *tg_pt_gp_transition_complete;
};