From: Rosen Penev <rosenp@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: Nilesh Javali <njavali@marvell.com>,
GR-QLogic-Storage-Upstream@marvell.com (maintainer:QLOGIC
QLA2XXX FC-SCSI DRIVER),
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] scsi: qla2xxx: Use flexible array for qpair hints
Date: Mon, 11 May 2026 18:10:46 -0700 [thread overview]
Message-ID: <20260512011046.41368-1-rosenp@gmail.com> (raw)
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 <rosenp@gmail.com>
---
drivers/scsi/qla2xxx/qla_target.c | 12 +-----------
drivers/scsi/qla2xxx/qla_target.h | 2 +-
2 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index e47da45e93a0..8acbd45f96dc 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -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");
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
index 61072fb41b29..575c10269a67 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -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 {
--
2.54.0
reply other threads:[~2026-05-12 1:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260512011046.41368-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=GR-QLogic-Storage-Upstream@marvell.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=njavali@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox