scsi: qla2xxx: Use flexible array for qpair hints
Subsystems (2)
PATCH 1/1 scsi: qla2xxx: Use flexible array for qpair hints
Store the qpair hints as trailing storage in struct qla_tgt instead of allocating and freeing them separately.
This keeps the hints tied to the target allocation and simplifies the error and release paths.
Assisted-by Codex:GPT-5.5
Signed-off-by Rosen Penev <[email protected]>
--- drivers/scsi/qla2xxx/qla_target.c | 12 +----------- drivers/scsi/qla2xxx/qla_target.h | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-)
drivers/scsi/qla2xxx/qla_target.c +1 -11
@@ -1590,7 +1590,6 @@ static void qlt_release(struct qla_tgt *tgt) h->qpair =NULL ; } } -kfree (tgt->qphints);mutex_lock (&qla_tgt_mutex);list_del (&vha->vha_tgt.qla_tgt->tgt_list_entry);mutex_unlock (&qla_tgt_mutex);
@@ -7458,26 +7457,17 @@ int qlt_add_target(struct qla_hw_data *ha, struct scsi_qla_host *base_vha)BUG_ON (base_vha->vha_tgt.qla_tgt !=NULL ); - tgt = kzalloc_obj(struct qla_tgt); + tgt =kzalloc_flex (*tgt, qphints, ha->max_qpairs +1 );if (!tgt) {ql_dbg (ql_dbg_tgt, base_vha,0xe066 ,"Unable to allocate struct qla_tgt\n" );return -ENOMEM ; } - tgt->qphints = kzalloc_objs(struct qla_qpair_hint, ha->max_qpairs + 1); -if (!tgt->qphints) { -kfree (tgt); -ql_log (ql_log_warn, base_vha,0x0197 , -"Unable to allocate qpair hints.\n" ); -return -ENOMEM ; - } - qla2xxx_driver_template.supported_mode |=MODE_TARGET ; rc =btree_init64 (&tgt->lun_qpair_map);if (rc) { -kfree (tgt->qphints);kfree (tgt);ql_log (ql_log_info, base_vha,0x0198 ,"Unable to initialize lun_qpair_map btree\n" );
drivers/scsi/qla2xxx/qla_target.h +1 -1
@@ -794,7 +794,6 @@ struct qla_tgt {struct scsi_qla_host *vha;struct qla_hw_data *ha;struct btree_head64 lun_qpair_map; -struct qla_qpair_hint *qphints;/* * To sync between IRQ handlers and qlt_target_release(). Needed, * because req_pkt() can drop/reaquire HW lock inside. Protected by
@@ -834,6 +833,7 @@ struct qla_tgt {atomic_t tgt_global_resets_count;struct list_head tgt_list_entry; +struct qla_qpair_hint qphints[]; };struct qla_tgt_sess_op {
Signature · 1 line
2.54.0