Skip to content

Commit 17b18ea

Browse files
glagoligmartinkpetersen
authored andcommitted
scsi: qla2xxx: deadlock by configfs_depend_item
The intent of invoking configfs_depend_item in commit 7474f52 ("tcm_qla2xxx: Perform configfs depend/undepend for base_tpg") was to prevent a physical Fibre Channel port removal when virtual (NPIV) ports announced through that physical port are active. The change does not work as expected: it makes enabled physical port dependent on target configfs subsystem (the port's parent), something the configfs guarantees anyway. Besides, scheduling work in a worker thread and waiting for the work's completion is not really a valid workaround for the requirement not to call configfs_depend_item from a configfs callback: the call occasionally deadlocks. Thus, removing configfs_depend_item calls does not break anything and fixes the deadlock problem. Signed-off-by: Anatoliy Glagolev <glagolig@gmail.com> Acked-by: Himanshu Madhani <hmadhani@marvell.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 3841746 commit 17b18ea

File tree

2 files changed

+8
-43
lines changed

2 files changed

+8
-43
lines changed

drivers/scsi/qla2xxx/tcm_qla2xxx.c

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -954,38 +954,14 @@ static ssize_t tcm_qla2xxx_tpg_enable_show(struct config_item *item,
954954
atomic_read(&tpg->lport_tpg_enabled));
955955
}
956956

957-
static void tcm_qla2xxx_depend_tpg(struct work_struct *work)
958-
{
959-
struct tcm_qla2xxx_tpg *base_tpg = container_of(work,
960-
struct tcm_qla2xxx_tpg, tpg_base_work);
961-
struct se_portal_group *se_tpg = &base_tpg->se_tpg;
962-
struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha;
963-
964-
if (!target_depend_item(&se_tpg->tpg_group.cg_item)) {
965-
atomic_set(&base_tpg->lport_tpg_enabled, 1);
966-
qlt_enable_vha(base_vha);
967-
}
968-
complete(&base_tpg->tpg_base_comp);
969-
}
970-
971-
static void tcm_qla2xxx_undepend_tpg(struct work_struct *work)
972-
{
973-
struct tcm_qla2xxx_tpg *base_tpg = container_of(work,
974-
struct tcm_qla2xxx_tpg, tpg_base_work);
975-
struct se_portal_group *se_tpg = &base_tpg->se_tpg;
976-
struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha;
977-
978-
if (!qlt_stop_phase1(base_vha->vha_tgt.qla_tgt)) {
979-
atomic_set(&base_tpg->lport_tpg_enabled, 0);
980-
target_undepend_item(&se_tpg->tpg_group.cg_item);
981-
}
982-
complete(&base_tpg->tpg_base_comp);
983-
}
984-
985957
static ssize_t tcm_qla2xxx_tpg_enable_store(struct config_item *item,
986958
const char *page, size_t count)
987959
{
988960
struct se_portal_group *se_tpg = to_tpg(item);
961+
struct se_wwn *se_wwn = se_tpg->se_tpg_wwn;
962+
struct tcm_qla2xxx_lport *lport = container_of(se_wwn,
963+
struct tcm_qla2xxx_lport, lport_wwn);
964+
struct scsi_qla_host *vha = lport->qla_vha;
989965
struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
990966
struct tcm_qla2xxx_tpg, se_tpg);
991967
unsigned long op;
@@ -1004,24 +980,16 @@ static ssize_t tcm_qla2xxx_tpg_enable_store(struct config_item *item,
1004980
if (atomic_read(&tpg->lport_tpg_enabled))
1005981
return -EEXIST;
1006982

1007-
INIT_WORK(&tpg->tpg_base_work, tcm_qla2xxx_depend_tpg);
983+
atomic_set(&tpg->lport_tpg_enabled, 1);
984+
qlt_enable_vha(vha);
1008985
} else {
1009986
if (!atomic_read(&tpg->lport_tpg_enabled))
1010987
return count;
1011988

1012-
INIT_WORK(&tpg->tpg_base_work, tcm_qla2xxx_undepend_tpg);
989+
atomic_set(&tpg->lport_tpg_enabled, 0);
990+
qlt_stop_phase1(vha->vha_tgt.qla_tgt);
1013991
}
1014-
init_completion(&tpg->tpg_base_comp);
1015-
schedule_work(&tpg->tpg_base_work);
1016-
wait_for_completion(&tpg->tpg_base_comp);
1017992

1018-
if (op) {
1019-
if (!atomic_read(&tpg->lport_tpg_enabled))
1020-
return -ENODEV;
1021-
} else {
1022-
if (atomic_read(&tpg->lport_tpg_enabled))
1023-
return -EPERM;
1024-
}
1025993
return count;
1026994
}
1027995

drivers/scsi/qla2xxx/tcm_qla2xxx.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ struct tcm_qla2xxx_tpg {
4848
struct tcm_qla2xxx_tpg_attrib tpg_attrib;
4949
/* Returned by tcm_qla2xxx_make_tpg() */
5050
struct se_portal_group se_tpg;
51-
/* Items for dealing with configfs_depend_item */
52-
struct completion tpg_base_comp;
53-
struct work_struct tpg_base_work;
5451
};
5552

5653
struct tcm_qla2xxx_fc_loopid {

0 commit comments

Comments
 (0)