Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b62a8d9b authored by Christof Schmitt's avatar Christof Schmitt Committed by James Bottomley
Browse files

[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: default avatarSwen Schillig <swen@vnet.ibm.com>
Signed-off-by: default avatarChristof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent fdbd1c5e
Loading
Loading
Loading
Loading
+15 −13
Original line number Diff line number Diff line
@@ -482,7 +482,7 @@ static int zfcp_dbf_rec_view_format(debug_info_t *id, struct debug_view *view,
		zfcp_dbf_out(&p, "fcp_lun", "0x%016Lx", r->u.trigger.fcp_lun);
		zfcp_dbf_out(&p, "adapter_status", "0x%08x", r->u.trigger.as);
		zfcp_dbf_out(&p, "port_status", "0x%08x", r->u.trigger.ps);
		zfcp_dbf_out(&p, "unit_status", "0x%08x", r->u.trigger.us);
		zfcp_dbf_out(&p, "lun_status", "0x%08x", r->u.trigger.ls);
		break;
	case ZFCP_REC_DBF_ID_ACTION:
		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)
}

/**
 * zfcp_dbf_rec_unit - trace event for unit state change
 * zfcp_dbf_rec_lun - trace event for LUN state change
 * @id: identifier for trigger of state change
 * @ref: additional reference (e.g. request)
 * @unit: unit
 * @sdev: SCSI device
 */
void zfcp_dbf_rec_unit(char *id, void *ref, struct zfcp_unit *unit)
void zfcp_dbf_rec_lun(char *id, void *ref, struct scsi_device *sdev)
{
	struct zfcp_port *port = unit->port;
	struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(sdev);
	struct zfcp_port *port = zfcp_sdev->port;
	struct zfcp_dbf *dbf = port->adapter->dbf;

	zfcp_dbf_rec_target(id, ref, dbf, &unit->status,
				  &unit->erp_counter, port->wwpn, port->d_id,
				  unit->fcp_lun);
	zfcp_dbf_rec_target(id, ref, dbf, &zfcp_sdev->status,
			    &zfcp_sdev->erp_counter, port->wwpn, port->d_id,
			    zfcp_scsi_dev_lun(sdev));
}

/**
@@ -624,11 +625,11 @@ void zfcp_dbf_rec_unit(char *id, void *ref, struct zfcp_unit *unit)
 * @action: address of error recovery action struct
 * @adapter: adapter
 * @port: port
 * @unit: unit
 * @sdev: SCSI device
 */
void zfcp_dbf_rec_trigger(char *id2, void *ref, u8 want, u8 need, void *action,
			  struct zfcp_adapter *adapter, struct zfcp_port *port,
			  struct zfcp_unit *unit)
			  struct scsi_device *sdev)
{
	struct zfcp_dbf *dbf = adapter->dbf;
	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,
		r->u.trigger.ps = atomic_read(&port->status);
		r->u.trigger.wwpn = port->wwpn;
	}
	if (unit)
		r->u.trigger.us = atomic_read(&unit->status);
	r->u.trigger.fcp_lun = unit ? unit->fcp_lun : ZFCP_DBF_INVALID_LUN;
	if (sdev)
		r->u.trigger.ls = atomic_read(&sdev_to_zfcp(sdev)->status);
	r->u.trigger.fcp_lun = sdev ? zfcp_scsi_dev_lun(sdev) :
				      ZFCP_DBF_INVALID_LUN;
	debug_event(dbf->rec, action ? 1 : 4, r, sizeof(*r));
	spin_unlock_irqrestore(&dbf->rec_lock, flags);
}
+6 −6
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ struct zfcp_dbf_rec_record_trigger {
	u8 need;
	u32 as;
	u32 ps;
	u32 us;
	u32 ls;
	u64 ref;
	u64 action;
	u64 wwpn;
@@ -350,16 +350,16 @@ void zfcp_dbf_scsi_abort(const char *tag, struct zfcp_dbf *dbf,
/**
 * zfcp_dbf_scsi_devreset - trace event for Logical Unit or Target Reset
 * @tag: tag indicating success or failure of reset operation
 * @scmnd: SCSI command which caused this error recovery
 * @flag: indicates type of reset (Target Reset, Logical Unit Reset)
 * @unit: unit that needs reset
 * @scsi_cmnd: SCSI command which caused this error recovery
 */
static inline
void zfcp_dbf_scsi_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
			    struct scsi_cmnd *scsi_cmnd)
void zfcp_dbf_scsi_devreset(const char *tag, struct scsi_cmnd *scmnd, u8 flag)
{
	struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scmnd->device);

	zfcp_dbf_scsi(flag == FCP_TMF_TGT_RESET ? "trst" : "lrst", tag, 1,
			    unit->port->adapter->dbf, scsi_cmnd, NULL, 0);
		      zfcp_sdev->port->adapter->dbf, scmnd, NULL, 0);
}

#endif /* ZFCP_DBF_H */
+19 −15
Original line number Diff line number Diff line
@@ -85,8 +85,8 @@ struct zfcp_reqlist;
#define ZFCP_STATUS_PORT_LINK_TEST		0x00000002

/* logical unit status */
#define ZFCP_STATUS_UNIT_SHARED			0x00000004
#define ZFCP_STATUS_UNIT_READONLY		0x00000008
#define ZFCP_STATUS_LUN_SHARED			0x00000004
#define ZFCP_STATUS_LUN_READONLY		0x00000008

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

/**
 * struct zfcp_unit - LUN configured via zfcp sysfs
 * @dev: struct device for sysfs representation and reference counting
 * @list: entry in LUN/unit list per zfcp_port
 * @port: reference to zfcp_port where this LUN is configured
 * @fcp_lun: 64 bit LUN value
 * @scsi_work: for running scsi_scan_target
 *
 * This is the representation of a LUN that has been configured for
 * usage. The main data here is the 64 bit LUN value, data for
 * running I/O and recovery is in struct zfcp_scsi_dev.
 */
struct zfcp_unit {
	struct device		dev;
	struct list_head       list;	       /* list of logical units */
	struct zfcp_port       *port;	       /* remote port of unit */
	atomic_t	       status;	       /* status of this logical unit */
	u64		       fcp_lun;	       /* own FCP_LUN */
	u32		       handle;	       /* handle assigned by FSF */
        struct scsi_device     *device;        /* scsi device struct pointer */
	struct zfcp_erp_action erp_action;     /* pending error recovery */
        atomic_t               erp_counter;
	struct zfcp_latencies	latencies;
	struct list_head	list;
	struct zfcp_port	*port;
	u64			fcp_lun;
	struct work_struct	scsi_work;
};

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

Loading