@@ -1182,6 +1182,52 @@ static void alua_check(struct scsi_device *sdev, bool force)
}
/*
+ * alua_state - report path status
+ * @sdev: device on the path to be checked
+ *
+ * Check the device status
+ */
+static int alua_state(struct scsi_device *sdev)
+{
+ struct alua_dh_data *h = sdev->handler_data;
+ struct alua_port_group *pg = NULL;
+ int access_state = SCSI_ACCESS_STATE_UNKNOWN;
+
+ rcu_read_lock();
+ if (h)
+ pg = rcu_dereference(h->pg);
+ if (pg) {
+ switch (pg->state) {
+ case TPGS_STATE_OPTIMIZED:
+ access_state = SCSI_ACCESS_STATE_OPTIMAL;
+ break;
+ case TPGS_STATE_NONOPTIMIZED:
+ access_state = SCSI_ACCESS_STATE_ACTIVE;
+ break;
+ case TPGS_STATE_STANDBY:
+ access_state = SCSI_ACCESS_STATE_PASSIVE;
+ break;
+ case TPGS_STATE_UNAVAILABLE:
+ access_state = SCSI_ACCESS_STATE_UNAVAILABLE;
+ break;
+ case TPGS_STATE_LBA_DEPENDENT:
+ access_state = SCSI_ACCESS_STATE_LBA;
+ break;
+ case TPGS_STATE_OFFLINE:
+ access_state = SCSI_ACCESS_STATE_OFFLINE;
+ break;
+ case TPGS_STATE_TRANSITIONING:
+ access_state = SCSI_ACCESS_STATE_TRANSITIONING;
+ break;
+ }
+ if (pg->pref)
+ access_state |= SCSI_ACCESS_STATE_PREFERRED;
+ }
+ rcu_read_unlock();
+ return access_state;
+}
+
+/*
* alua_prep_fn - request callback
*
* Fail I/O to all paths not in state
@@ -1288,6 +1334,7 @@ static struct scsi_device_handler alua_dh = {
.activate = alua_activate,
.rescan = alua_rescan,
.set_params = alua_set_params,
+ .state = alua_state,
};
static int __init alua_init(void)
Add a 'state' callback function to display the current path status in sysfs. Signed-off-by: Hannes Reinecke <hare@suse.de> --- drivers/scsi/device_handler/scsi_dh_alua.c | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)