Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <bblock@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Benjamin Block and committed by
Martin K. Petersen
901b894a 3ab01810

+52 -4
+43 -1
drivers/s390/scsi/zfcp_dbf.c
··· 4 4 * 5 5 * Debug traces for zfcp. 6 6 * 7 - * Copyright IBM Corp. 2002, 2020 7 + * Copyright IBM Corp. 2002, 2023 8 8 */ 9 9 10 10 #define KMSG_COMPONENT "zfcp" ··· 140 140 rec->u.fces.wwpn = wwpn; 141 141 rec->u.fces.fc_security_old = fc_security_old; 142 142 rec->u.fces.fc_security_new = fc_security_new; 143 + 144 + debug_event(dbf->hba, level, rec, sizeof(*rec)); 145 + spin_unlock_irqrestore(&dbf->hba_lock, flags); 146 + } 147 + 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; 143 185 144 186 debug_event(dbf->hba, level, rec, sizeof(*rec)); 145 187 spin_unlock_irqrestore(&dbf->hba_lock, flags);
+4 -1
drivers/s390/scsi/zfcp_ext.h
··· 4 4 * 5 5 * External function declarations. 6 6 * 7 - * Copyright IBM Corp. 2002, 2020 7 + * Copyright IBM Corp. 2002, 2023 8 8 */ 9 9 10 10 #ifndef ZFCP_EXT_H ··· 46 46 extern void zfcp_dbf_hba_fsf_fces(char *tag, const struct zfcp_fsf_req *req, 47 47 u64 wwpn, u32 fc_security_old, 48 48 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); 49 52 extern void zfcp_dbf_hba_bit_err(char *, struct zfcp_fsf_req *); 50 53 extern void zfcp_dbf_hba_def_err(struct zfcp_adapter *, u64, u16, void **); 51 54 extern void zfcp_dbf_san_req(char *, struct zfcp_fsf_req *, u32);
+5 -2
drivers/s390/scsi/zfcp_fsf.c
··· 4 4 * 5 5 * Implementation of FSF commands. 6 6 * 7 - * Copyright IBM Corp. 2002, 2020 7 + * Copyright IBM Corp. 2002, 2023 8 8 */ 9 9 10 10 #define KMSG_COMPONENT "zfcp" ··· 892 892 req->issued = get_tod_clock(); 893 893 if (zfcp_qdio_send(qdio, &req->qdio_req)) { 894 894 del_timer_sync(&req->timer); 895 + 895 896 /* 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 + 897 900 zfcp_erp_adapter_reopen(adapter, 0, "fsrs__1"); 898 901 return -EIO; 899 902 }