Skip to content

Commit b62a8d9

Browse files
Christof SchmittJames Bottomley
Christof Schmitt
authored and
James Bottomley
committed
[SCSI] zfcp: Use SCSI device data zfcp_scsi_dev instead of zfcp_unit
This is the large change to switch from using the data in zfcp_unit to zfcp_scsi_dev. Keeping everything working requires doing the switch in one piece. To ensure that no code keeps using the data in zfcp_unit, this patch also removes the data from zfcp_unit that is now being replaced with zfcp_scsi_dev. For zfcp, the scsi_device together with zfcp_scsi_dev exist from the call of slave_alloc to the call of slave_destroy. The data in zfcp_scsi_dev is initialized in zfcp_scsi_slave_alloc and the LUN is opened; the final shutdown for the LUN is run from slave_destroy. Where the scsi_device or zfcp_scsi_dev is needed, the pointer to the scsi_device is passed as function argument and inside the function converted to the pointer to zfcp_scsi_dev; this avoids back and forth conversion betweeen scsi_device and zfcp_scsi_dev. While changing the function arguments from zfcp_unit to scsi_device, the functions names are renamed form "unit" to "lun". This is to have a seperation between zfcp_scsi_dev/LUN and the zfcp_unit; only code referring to the remaining configuration information in zfcp_unit struct uses "unit". Reviewed-by: Swen Schillig <[email protected]> Signed-off-by: Christof Schmitt <[email protected]> Signed-off-by: James Bottomley <[email protected]>
1 parent fdbd1c5 commit b62a8d9

File tree

9 files changed

+480
-465
lines changed

9 files changed

+480
-465
lines changed

Diff for: drivers/s390/scsi/zfcp_dbf.c

+15-13
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ static int zfcp_dbf_rec_view_format(debug_info_t *id, struct debug_view *view,
482482
zfcp_dbf_out(&p, "fcp_lun", "0x%016Lx", r->u.trigger.fcp_lun);
483483
zfcp_dbf_out(&p, "adapter_status", "0x%08x", r->u.trigger.as);
484484
zfcp_dbf_out(&p, "port_status", "0x%08x", r->u.trigger.ps);
485-
zfcp_dbf_out(&p, "unit_status", "0x%08x", r->u.trigger.us);
485+
zfcp_dbf_out(&p, "lun_status", "0x%08x", r->u.trigger.ls);
486486
break;
487487
case ZFCP_REC_DBF_ID_ACTION:
488488
zfcp_dbf_out(&p, "erp_action", "0x%016Lx", r->u.action.action);
@@ -600,19 +600,20 @@ void zfcp_dbf_rec_port(char *id, void *ref, struct zfcp_port *port)
600600
}
601601

602602
/**
603-
* zfcp_dbf_rec_unit - trace event for unit state change
603+
* zfcp_dbf_rec_lun - trace event for LUN state change
604604
* @id: identifier for trigger of state change
605605
* @ref: additional reference (e.g. request)
606-
* @unit: unit
606+
* @sdev: SCSI device
607607
*/
608-
void zfcp_dbf_rec_unit(char *id, void *ref, struct zfcp_unit *unit)
608+
void zfcp_dbf_rec_lun(char *id, void *ref, struct scsi_device *sdev)
609609
{
610-
struct zfcp_port *port = unit->port;
610+
struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
611+
struct zfcp_port *port = zfcp_sdev->port;
611612
struct zfcp_dbf *dbf = port->adapter->dbf;
612613

613-
zfcp_dbf_rec_target(id, ref, dbf, &unit->status,
614-
&unit->erp_counter, port->wwpn, port->d_id,
615-
unit->fcp_lun);
614+
zfcp_dbf_rec_target(id, ref, dbf, &zfcp_sdev->status,
615+
&zfcp_sdev->erp_counter, port->wwpn, port->d_id,
616+
zfcp_scsi_dev_lun(sdev));
616617
}
617618

618619
/**
@@ -624,11 +625,11 @@ void zfcp_dbf_rec_unit(char *id, void *ref, struct zfcp_unit *unit)
624625
* @action: address of error recovery action struct
625626
* @adapter: adapter
626627
* @port: port
627-
* @unit: unit
628+
* @sdev: SCSI device
628629
*/
629630
void zfcp_dbf_rec_trigger(char *id2, void *ref, u8 want, u8 need, void *action,
630631
struct zfcp_adapter *adapter, struct zfcp_port *port,
631-
struct zfcp_unit *unit)
632+
struct scsi_device *sdev)
632633
{
633634
struct zfcp_dbf *dbf = adapter->dbf;
634635
struct zfcp_dbf_rec_record *r = &dbf->rec_buf;
@@ -647,9 +648,10 @@ void zfcp_dbf_rec_trigger(char *id2, void *ref, u8 want, u8 need, void *action,
647648
r->u.trigger.ps = atomic_read(&port->status);
648649
r->u.trigger.wwpn = port->wwpn;
649650
}
650-
if (unit)
651-
r->u.trigger.us = atomic_read(&unit->status);
652-
r->u.trigger.fcp_lun = unit ? unit->fcp_lun : ZFCP_DBF_INVALID_LUN;
651+
if (sdev)
652+
r->u.trigger.ls = atomic_read(&sdev_to_zfcp(sdev)->status);
653+
r->u.trigger.fcp_lun = sdev ? zfcp_scsi_dev_lun(sdev) :
654+
ZFCP_DBF_INVALID_LUN;
653655
debug_event(dbf->rec, action ? 1 : 4, r, sizeof(*r));
654656
spin_unlock_irqrestore(&dbf->rec_lock, flags);
655657
}

Diff for: drivers/s390/scsi/zfcp_dbf.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct zfcp_dbf_rec_record_trigger {
6060
u8 need;
6161
u32 as;
6262
u32 ps;
63-
u32 us;
63+
u32 ls;
6464
u64 ref;
6565
u64 action;
6666
u64 wwpn;
@@ -350,16 +350,16 @@ void zfcp_dbf_scsi_abort(const char *tag, struct zfcp_dbf *dbf,
350350
/**
351351
* zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
352352
* @tag: tag indicating success or failure of reset operation
353+
* @scmnd: SCSI command which caused this error recovery
353354
* @flag: indicates type of reset (Target Reset, Logical Unit Reset)
354-
* @unit: unit that needs reset
355-
* @scsi_cmnd: SCSI command which caused this error recovery
356355
*/
357356
static inline
358-
void zfcp_dbf_scsi_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
359-
struct scsi_cmnd *scsi_cmnd)
357+
void zfcp_dbf_scsi_devreset(const char *tag, struct scsi_cmnd *scmnd, u8 flag)
360358
{
359+
struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scmnd->device);
360+
361361
zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1,
362-
unit->port->adapter->dbf, scsi_cmnd, NULL, 0);
362+
zfcp_sdev->port->adapter->dbf, scmnd, NULL, 0);
363363
}
364364

365365
#endif /* ZFCP_DBF_H */

Diff for: drivers/s390/scsi/zfcp_def.h

+19-15
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ struct zfcp_reqlist;
8585
#define ZFCP_STATUS_PORT_LINK_TEST 0x00000002
8686

8787
/* logical unit status */
88-
#define ZFCP_STATUS_UNIT_SHARED 0x00000004
89-
#define ZFCP_STATUS_UNIT_READONLY 0x00000008
88+
#define ZFCP_STATUS_LUN_SHARED 0x00000004
89+
#define ZFCP_STATUS_LUN_READONLY 0x00000008
9090

9191
/* FSF request status (this does not have a common part) */
9292
#define ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT 0x00000002
@@ -118,7 +118,7 @@ struct zfcp_erp_action {
118118
int action; /* requested action code */
119119
struct zfcp_adapter *adapter; /* device which should be recovered */
120120
struct zfcp_port *port;
121-
struct zfcp_unit *unit;
121+
struct scsi_device *sdev;
122122
u32 status; /* recovery status */
123123
u32 step; /* active step of this erp action */
124124
unsigned long fsf_req_id;
@@ -219,17 +219,23 @@ struct zfcp_port {
219219
unsigned int starget_id;
220220
};
221221

222+
/**
223+
* struct zfcp_unit - LUN configured via zfcp sysfs
224+
* @dev: struct device for sysfs representation and reference counting
225+
* @list: entry in LUN/unit list per zfcp_port
226+
* @port: reference to zfcp_port where this LUN is configured
227+
* @fcp_lun: 64 bit LUN value
228+
* @scsi_work: for running scsi_scan_target
229+
*
230+
* This is the representation of a LUN that has been configured for
231+
* usage. The main data here is the 64 bit LUN value, data for
232+
* running I/O and recovery is in struct zfcp_scsi_dev.
233+
*/
222234
struct zfcp_unit {
223-
struct device dev;
224-
struct list_head list; /* list of logical units */
225-
struct zfcp_port *port; /* remote port of unit */
226-
atomic_t status; /* status of this logical unit */
227-
u64 fcp_lun; /* own FCP_LUN */
228-
u32 handle; /* handle assigned by FSF */
229-
struct scsi_device *device; /* scsi device struct pointer */
230-
struct zfcp_erp_action erp_action; /* pending error recovery */
231-
atomic_t erp_counter;
232-
struct zfcp_latencies latencies;
235+
struct device dev;
236+
struct list_head list;
237+
struct zfcp_port *port;
238+
u64 fcp_lun;
233239
struct work_struct scsi_work;
234240
};
235241

@@ -288,7 +294,6 @@ static inline u64 zfcp_scsi_dev_lun(struct scsi_device *sdev)
288294
* @erp_action: reference to erp action if request issued on behalf of ERP
289295
* @pool: reference to memory pool if used for this request
290296
* @issued: time when request was send (STCK)
291-
* @unit: reference to unit if this request is a SCSI request
292297
* @handler: handler which should be called to process response
293298
*/
294299
struct zfcp_fsf_req {
@@ -306,7 +311,6 @@ struct zfcp_fsf_req {
306311
struct zfcp_erp_action *erp_action;
307312
mempool_t *pool;
308313
unsigned long long issued;
309-
struct zfcp_unit *unit;
310314
void (*handler)(struct zfcp_fsf_req *);
311315
};
312316

0 commit comments

Comments
 (0)