From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
Lee Duncan <lduncan@suse.com>, Chris Leech <cleech@redhat.com>,
Mike Christie <michael.christie@oracle.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Subject: [PATCH 22/36] scsi: libiscsi: Prepare for enabling lock context analysis
Date: Thu, 12 Mar 2026 14:15:33 -0700 [thread overview]
Message-ID: <20260312211636.3245119-23-bvanassche@acm.org> (raw)
In-Reply-To: <20260312211636.3245119-1-bvanassche@acm.org>
Document locking requirements with __must_hold().
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/libiscsi.c | 19 ++++++++++++++++++-
include/scsi/libiscsi.h | 5 +++--
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 25857d6ed6e8..b89c048b4034 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1088,6 +1088,7 @@ static int iscsi_nop_out_rsp(struct iscsi_task *task,
static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
char *data, int datalen)
+ __must_hold(&conn->session->back_lock)
{
struct iscsi_reject *reject = (struct iscsi_reject *)hdr;
struct iscsi_hdr rejected_pdu;
@@ -1500,6 +1501,7 @@ static int iscsi_check_cmdsn_window_closed(struct iscsi_conn *conn)
static int iscsi_xmit_task(struct iscsi_conn *conn, struct iscsi_task *task,
bool was_requeue)
+ __must_hold(&conn->session->frwd_lock)
{
int rc;
@@ -1915,7 +1917,8 @@ static void iscsi_tmf_timedout(struct timer_list *t)
static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
struct iscsi_tm *hdr, int age,
int timeout)
- __must_hold(&session->frwd_lock)
+ __must_hold(&conn->session->frwd_lock)
+ __must_hold(&conn->session->eh_mutex)
{
struct iscsi_session *session = conn->session;
@@ -1962,6 +1965,7 @@ static int iscsi_exec_task_mgmt_fn(struct iscsi_conn *conn,
* Fail commands. session frwd lock held and xmit thread flushed.
*/
static void fail_scsi_tasks(struct iscsi_conn *conn, u64 lun, int error)
+ __must_hold(&conn->session->frwd_lock)
{
struct iscsi_session *session = conn->session;
struct iscsi_task *task;
@@ -2408,6 +2412,9 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt);
conn = session->leadconn;
+ /* Tell the compiler that conn->session == session. */
+ __assume_ctx_lock(&conn->session->eh_mutex);
+ __assume_ctx_lock(&conn->session->frwd_lock);
iscsi_get_conn(conn->cls_conn);
conn->eh_abort_cnt++;
age = session->age;
@@ -2531,6 +2538,9 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN)
goto unlock;
conn = session->leadconn;
+ /* Tell the compiler that conn->session == session. */
+ __assume_ctx_lock(&conn->session->frwd_lock);
+ __assume_ctx_lock(&conn->session->eh_mutex);
/* only have one tmf outstanding at a time */
if (session->tmf_state != TMF_INITIAL)
@@ -2564,6 +2574,8 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
iscsi_suspend_tx(conn);
spin_lock_bh(&session->frwd_lock);
+ /* Tell the compiler that conn->session == session. */
+ __assume_ctx_lock(&conn->session->frwd_lock);
memset(hdr, 0, sizeof(*hdr));
fail_scsi_tasks(conn, sc->device->lun, DID_ERROR);
session->tmf_state = TMF_INITIAL;
@@ -2693,6 +2705,9 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc)
if (!session->leadconn || session->state != ISCSI_STATE_LOGGED_IN)
goto unlock;
conn = session->leadconn;
+ /* Tell the compiler that conn->session == session. */
+ __assume_ctx_lock(&conn->session->eh_mutex);
+ __assume_ctx_lock(&conn->session->frwd_lock);
/* only have one tmf outstanding at a time */
if (session->tmf_state != TMF_INITIAL)
@@ -2726,6 +2741,8 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc)
iscsi_suspend_tx(conn);
spin_lock_bh(&session->frwd_lock);
+ /* Tell the compiler that conn->session == session. */
+ __assume_ctx_lock(&conn->session->frwd_lock);
memset(hdr, 0, sizeof(*hdr));
fail_scsi_tasks(conn, -1, DID_ERROR);
session->tmf_state = TMF_INITIAL;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index 3d765c77bcd9..d39b5b268e6f 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -474,8 +474,9 @@ extern int iscsi_conn_send_pdu(struct iscsi_cls_conn *, struct iscsi_hdr *,
char *, uint32_t);
extern int iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
char *, int);
-extern int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
- char *, int);
+extern int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *,
+ char *, int)
+ __must_hold(&conn->session->back_lock);
extern int iscsi_verify_itt(struct iscsi_conn *, itt_t);
extern struct iscsi_task *iscsi_itt_to_ctask(struct iscsi_conn *, itt_t);
extern struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *, itt_t);
next prev parent reply other threads:[~2026-03-12 21:17 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 21:15 [PATCH 00/36] Enable lock context analysis for most SCSI drivers Bart Van Assche
2026-03-12 21:15 ` [PATCH 01/36] scsi: core: Prepare for enabling lock context analysis Bart Van Assche
2026-03-12 21:15 ` [PATCH 02/36] scsi: scsi_debug: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 03/36] scsi: sg: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 04/36] scsi: st: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 05/36] scsi: BusLogic: Introduce a local variable Bart Van Assche
2026-03-26 20:50 ` Khalid Aziz
2026-03-12 21:15 ` [PATCH 06/36] scsi: BusLogic: Prepare for enabling lock context analysis Bart Van Assche
2026-03-26 20:59 ` Khalid Aziz
2026-03-12 21:15 ` [PATCH 07/36] scsi: NCR5380: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 08/36] scsi: aacraid: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 09/36] scsi: aha152x: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 10/36] scsi: aic7xxx: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 11/36] scsi: be2iscsi: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 12/36] scsi: bnx2fc: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 13/36] scsi: bnx2i: Introduce a local variable Bart Van Assche
2026-03-12 21:15 ` [PATCH 14/36] scsi: bnx2i: Prepare for enabling lock context analysis Bart Van Assche
2026-03-12 21:15 ` [PATCH 15/36] scsi: csiostor: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 16/36] scsi: fnic: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 17/36] scsi: hpsa: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 18/36] scsi: ibmvscsi_tgt: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 19/36] scsi: ipr: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 20/36] scsi: ips: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 21/36] scsi: libfc: " Bart Van Assche
2026-03-12 21:15 ` Bart Van Assche [this message]
2026-03-12 21:15 ` [PATCH 23/36] scsi: libsas: " Bart Van Assche
2026-03-13 1:35 ` Jason Yan
2026-03-12 21:15 ` [PATCH 24/36] scsi: lpfc: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 25/36] scsi: megaraid_sas: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 26/36] scsi: mvsas: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 27/36] scsi: pm8001: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 28/36] scsi: qedi: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 29/36] scsi: qla1280: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 30/36] scsi: qla2xxx: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 31/36] scsi: qla4xxx: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 32/36] scsi: ufs: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 33/36] scsi: iSCSI transport: " Bart Van Assche
2026-03-12 21:15 ` [PATCH 34/36] scsi: smartpqi: " Bart Van Assche
2026-03-16 15:36 ` Don.Brace
2026-03-12 21:15 ` [PATCH 35/36] scsi: Enable " Bart Van Assche
2026-03-12 21:15 ` [PATCH 36/36] scsi: core: Protect host state changes with the host lock Bart Van Assche
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=20260312211636.3245119-23-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=cleech@redhat.com \
--cc=lduncan@suse.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=michael.christie@oracle.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