1 From: Gerald Schaefer <geraldsc@de.ibm.com>
2 Subject: [PATCH] zfcp: Only collect FSF/HBA debug data for matching trace levels
3 References: bnc#532063,LTC#55526
5 From: Christof Schmitt <christof.schmitt@de.ibm.com>
7 The default trace level is to only trace failed FSF commands. Thus it
8 is not necessary to collect trace data for most FSF commands, since
9 it will be thrown away later. Restructure the FSF/HBA trace
10 infrastructure to first check the trace level in a inline function and
11 only do the expensive data collection for matching trace levels.
13 Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
15 Acked-by: John Jolly <jjolly@suse.de>
18 drivers/s390/scsi/zfcp_dbf.c | 44 ++++++-----------------------------
19 drivers/s390/scsi/zfcp_dbf.h | 53 +++++++++++++++++++++++++++++++++++++++++++
20 drivers/s390/scsi/zfcp_ext.h | 9 ++++---
21 3 files changed, 67 insertions(+), 39 deletions(-)
23 --- a/drivers/s390/scsi/zfcp_dbf.c 2009-07-01 17:57:03.000000000 +0200
24 +++ b/drivers/s390/scsi/zfcp_dbf.c 2009-07-01 17:57:41.000000000 +0200
25 @@ -119,14 +119,10 @@ static int zfcp_dbf_view_header(debug_in
30 - * zfcp_hba_dbf_event_fsf_response - trace event for request completion
31 - * @fsf_req: request that has been completed
33 -void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *fsf_req)
34 +void _zfcp_hba_dbf_event_fsf_response(const char *tag2, int level,
35 + struct zfcp_fsf_req *fsf_req,
36 + struct zfcp_dbf *dbf)
38 - struct zfcp_adapter *adapter = fsf_req->adapter;
39 - struct zfcp_dbf *dbf = adapter->dbf;
40 struct fsf_qtcb *qtcb = fsf_req->qtcb;
41 union fsf_prot_status_qual *prot_status_qual =
42 &qtcb->prefix.prot_status_qual;
43 @@ -137,31 +133,12 @@ void zfcp_hba_dbf_event_fsf_response(str
44 struct zfcp_send_els *send_els;
45 struct zfcp_hba_dbf_record *rec = &dbf->hba_dbf_buf;
46 struct zfcp_hba_dbf_record_response *response = &rec->u.response;
50 spin_lock_irqsave(&dbf->hba_dbf_lock, flags);
51 memset(rec, 0, sizeof(*rec));
52 strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE);
54 - if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
55 - (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
56 - strncpy(rec->tag2, "perr", ZFCP_DBF_TAG_SIZE);
58 - } else if (qtcb->header.fsf_status != FSF_GOOD) {
59 - strncpy(rec->tag2, "ferr", ZFCP_DBF_TAG_SIZE);
61 - } else if ((fsf_req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
62 - (fsf_req->fsf_command == FSF_QTCB_OPEN_LUN)) {
63 - strncpy(rec->tag2, "open", ZFCP_DBF_TAG_SIZE);
65 - } else if (qtcb->header.log_length) {
66 - strncpy(rec->tag2, "qtcb", ZFCP_DBF_TAG_SIZE);
69 - strncpy(rec->tag2, "norm", ZFCP_DBF_TAG_SIZE);
72 + strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE);
74 response->fsf_command = fsf_req->fsf_command;
75 response->fsf_reqid = (unsigned long)fsf_req;
76 @@ -240,14 +217,9 @@ void zfcp_hba_dbf_event_fsf_response(str
77 spin_unlock_irqrestore(&dbf->hba_dbf_lock, flags);
81 - * zfcp_hba_dbf_event_fsf_unsol - trace event for an unsolicited status buffer
82 - * @tag: tag indicating which kind of unsolicited status has been received
83 - * @adapter: adapter that has issued the unsolicited status buffer
84 - * @status_buffer: buffer containing payload of unsolicited status
86 -void zfcp_hba_dbf_event_fsf_unsol(const char *tag, struct zfcp_adapter *adapter,
87 - struct fsf_status_read_buffer *status_buffer)
88 +void _zfcp_hba_dbf_event_fsf_unsol(const char *tag, int level,
89 + struct zfcp_adapter *adapter,
90 + struct fsf_status_read_buffer *status_buffer)
92 struct zfcp_dbf *dbf = adapter->dbf;
93 struct zfcp_hba_dbf_record *rec = &dbf->hba_dbf_buf;
94 @@ -295,7 +267,7 @@ void zfcp_hba_dbf_event_fsf_unsol(const
95 &status_buffer->payload, rec->u.status.payload_size);
98 - debug_event(dbf->hba_dbf, 2, rec, sizeof(*rec));
99 + debug_event(dbf->hba_dbf, level, rec, sizeof(*rec));
100 spin_unlock_irqrestore(&dbf->hba_dbf_lock, flags);
103 --- a/drivers/s390/scsi/zfcp_dbf.h 2009-07-01 17:57:03.000000000 +0200
104 +++ b/drivers/s390/scsi/zfcp_dbf.h 2009-07-01 17:57:41.000000000 +0200
105 @@ -239,6 +239,59 @@ struct zfcp_dbf {
109 +void zfcp_hba_dbf_event_fsf_resp(const char *tag2, int level,
110 + struct zfcp_fsf_req *req, struct zfcp_dbf *dbf)
112 + if (level <= dbf->hba_dbf->level)
113 + _zfcp_hba_dbf_event_fsf_response(tag2, level, req, dbf);
117 + * zfcp_hba_dbf_event_fsf_response - trace event for request completion
118 + * @fsf_req: request that has been completed
120 +static inline void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *req)
122 + struct zfcp_dbf *dbf = req->adapter->dbf;
123 + struct fsf_qtcb *qtcb = req->qtcb;
125 + if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
126 + (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
127 + zfcp_hba_dbf_event_fsf_resp("perr", 1, req, dbf);
129 + } else if (qtcb->header.fsf_status != FSF_GOOD) {
130 + zfcp_hba_dbf_event_fsf_resp("ferr", 1, req, dbf);
132 + } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
133 + (req->fsf_command == FSF_QTCB_OPEN_LUN)) {
134 + zfcp_hba_dbf_event_fsf_resp("open", 4, req, dbf);
136 + } else if (qtcb->header.log_length) {
137 + zfcp_hba_dbf_event_fsf_resp("qtcb", 5, req, dbf);
140 + zfcp_hba_dbf_event_fsf_resp("norm", 6, req, dbf);
145 + * zfcp_hba_dbf_event_fsf_unsol - trace event for an unsolicited status buffer
146 + * @tag: tag indicating which kind of unsolicited status has been received
147 + * @adapter: adapter that has issued the unsolicited status buffer
148 + * @status_buffer: buffer containing payload of unsolicited status
151 +void zfcp_hba_dbf_event_fsf_unsol(const char *tag, struct zfcp_adapter *adapter,
152 + struct fsf_status_read_buffer *buf)
154 + struct zfcp_dbf *dbf = adapter->dbf;
157 + if (level <= dbf->hba_dbf->level)
158 + _zfcp_hba_dbf_event_fsf_unsol(tag, level, adapter, buf);
162 void zfcp_scsi_dbf_event(const char *tag, const char *tag2, int level,
163 struct zfcp_adapter *adapter, struct scsi_cmnd *scmd,
164 struct zfcp_fsf_req *req, unsigned long old_id)
165 --- a/drivers/s390/scsi/zfcp_ext.h 2009-07-01 17:57:03.000000000 +0200
166 +++ b/drivers/s390/scsi/zfcp_ext.h 2009-07-01 17:58:28.000000000 +0200
167 @@ -44,9 +44,12 @@ extern void zfcp_rec_dbf_event_trigger(u
168 struct zfcp_adapter *,
169 struct zfcp_port *, struct zfcp_unit *);
170 extern void zfcp_rec_dbf_event_action(u8, struct zfcp_erp_action *);
171 -extern void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *);
172 -extern void zfcp_hba_dbf_event_fsf_unsol(const char *, struct zfcp_adapter *,
173 - struct fsf_status_read_buffer *);
174 +extern void _zfcp_hba_dbf_event_fsf_response(const char *, int level,
175 + struct zfcp_fsf_req *,
176 + struct zfcp_dbf *dbf);
177 +extern void _zfcp_hba_dbf_event_fsf_unsol(const char *, int level,
178 + struct zfcp_adapter *,
179 + struct fsf_status_read_buffer *);
180 extern void zfcp_hba_dbf_event_qdio(struct zfcp_adapter *, unsigned int, int,
182 extern void zfcp_hba_dbf_event_berr(struct zfcp_adapter *,