Skip to content

Commit 901b894

Browse files
Benjamin-Blockmartinkpetersen
authored andcommitted
scsi: zfcp: Trace when request remove fails after qdio send fails
When we fail to send a FSF request in 'zfcp_fsf_req_send()' when calling 'zfcp_qdio_send()' we try to remove the request object from our internal hash table again to prevent keeping a stale memory reference. This removal might still - very much theoretically - fail. To store some evidence of when this happens add a new trace record for this case; tag: 'fsrsrmf'. We reuse the 'ZFCP_DBF_HBA_RES' trace ID for this, but mark all fields other then the request ID with ~0, to make fairly obvious that these are invalid values. This faking has to be done because we don't have a valid request object at this point, and can not safely access any of the memory of the old object - we just failed to find it in our hash table, so it might be gone already. Here is an example of a decoded trace record: Timestamp : 2023-02-17-13:09:12:748140 Area : HBA Subarea : 1 Level : - Exception : 000003ff7ff500c2 CPU ID : 0011 Caller : 0x0 Record ID : 1 Tag : fsrsrmf Request ID : 0x0000000080126ab6 Request status : 0xffffffff FSF cmnd : 0xffffffff FSF sequence no: 0xffffffff FSF issued : 2042-09-18-01:53:47:370495 FSF stat : 0xffffffff FSF stat qual : ffffffff ffffffff ffffffff ffffffff Prot stat : 0xffffffff Prot stat qual : ffffffff ffffffff ffffffff ffffffff Port handle : 0xffffffff LUN handle : 0xffffffff This provides at least some basic evidence that this event happened, and what object was affected. Link: https://lore.kernel.org/r/99b8246b2d71b63fa4f9c56333e2037502f7f5af.1677000450.git.bblock@linux.ibm.com Signed-off-by: Benjamin Block <[email protected]> Reviewed-by: Steffen Maier <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 3ab0181 commit 901b894

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

drivers/s390/scsi/zfcp_dbf.c

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Debug traces for zfcp.
66
*
7-
* Copyright IBM Corp. 2002, 2020
7+
* Copyright IBM Corp. 2002, 2023
88
*/
99

1010
#define KMSG_COMPONENT "zfcp"
@@ -145,6 +145,48 @@ void zfcp_dbf_hba_fsf_fces(char *tag, const struct zfcp_fsf_req *req, u64 wwpn,
145145
spin_unlock_irqrestore(&dbf->hba_lock, flags);
146146
}
147147

148+
/**
149+
* zfcp_dbf_hba_fsf_reqid - trace only the tag and a request ID
150+
* @tag: tag documenting the source
151+
* @level: trace level
152+
* @adapter: adapter instance the request ID belongs to
153+
* @req_id: the request ID to trace
154+
*/
155+
void zfcp_dbf_hba_fsf_reqid(const char *const tag, const int level,
156+
struct zfcp_adapter *const adapter,
157+
const u64 req_id)
158+
{
159+
struct zfcp_dbf *const dbf = adapter->dbf;
160+
struct zfcp_dbf_hba *const rec = &dbf->hba_buf;
161+
struct zfcp_dbf_hba_res *const res = &rec->u.res;
162+
unsigned long flags;
163+
164+
if (unlikely(!debug_level_enabled(dbf->hba, level)))
165+
return;
166+
167+
spin_lock_irqsave(&dbf->hba_lock, flags);
168+
memset(rec, 0, sizeof(*rec));
169+
170+
memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
171+
172+
rec->id = ZFCP_DBF_HBA_RES;
173+
rec->fsf_req_id = req_id;
174+
rec->fsf_req_status = ~0u;
175+
rec->fsf_cmd = ~0u;
176+
rec->fsf_seq_no = ~0u;
177+
178+
res->req_issued = ~0ull;
179+
res->prot_status = ~0u;
180+
memset(res->prot_status_qual, 0xff, sizeof(res->prot_status_qual));
181+
res->fsf_status = ~0u;
182+
memset(res->fsf_status_qual, 0xff, sizeof(res->fsf_status_qual));
183+
res->port_handle = ~0u;
184+
res->lun_handle = ~0u;
185+
186+
debug_event(dbf->hba, level, rec, sizeof(*rec));
187+
spin_unlock_irqrestore(&dbf->hba_lock, flags);
188+
}
189+
148190
/**
149191
* zfcp_dbf_hba_fsf_uss - trace event for an unsolicited status buffer
150192
* @tag: tag indicating which kind of unsolicited status has been received

drivers/s390/scsi/zfcp_ext.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* External function declarations.
66
*
7-
* Copyright IBM Corp. 2002, 2020
7+
* Copyright IBM Corp. 2002, 2023
88
*/
99

1010
#ifndef ZFCP_EXT_H
@@ -46,6 +46,9 @@ extern void zfcp_dbf_hba_fsf_res(char *, int, struct zfcp_fsf_req *);
4646
extern void zfcp_dbf_hba_fsf_fces(char *tag, const struct zfcp_fsf_req *req,
4747
u64 wwpn, u32 fc_security_old,
4848
u32 fc_security_new);
49+
extern void zfcp_dbf_hba_fsf_reqid(const char *const tag, const int level,
50+
struct zfcp_adapter *const adapter,
51+
const u64 req_id);
4952
extern void zfcp_dbf_hba_bit_err(char *, struct zfcp_fsf_req *);
5053
extern void zfcp_dbf_hba_def_err(struct zfcp_adapter *, u64, u16, void **);
5154
extern void zfcp_dbf_san_req(char *, struct zfcp_fsf_req *, u32);

drivers/s390/scsi/zfcp_fsf.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Implementation of FSF commands.
66
*
7-
* Copyright IBM Corp. 2002, 2020
7+
* Copyright IBM Corp. 2002, 2023
88
*/
99

1010
#define KMSG_COMPONENT "zfcp"
@@ -892,8 +892,11 @@ static int zfcp_fsf_req_send(struct zfcp_fsf_req *req)
892892
req->issued = get_tod_clock();
893893
if (zfcp_qdio_send(qdio, &req->qdio_req)) {
894894
del_timer_sync(&req->timer);
895+
895896
/* lookup request again, list might have changed */
896-
zfcp_reqlist_find_rm(adapter->req_list, req_id);
897+
if (zfcp_reqlist_find_rm(adapter->req_list, req_id) == NULL)
898+
zfcp_dbf_hba_fsf_reqid("fsrsrmf", 1, adapter, req_id);
899+
897900
zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1");
898901
return -EIO;
899902
}

0 commit comments

Comments
 (0)