Add a 'state' callback to display the current LUN access state
to sysfs.

Signed-off-by: Hannes Reinecke <[email protected]>
---
 drivers/scsi/device_handler/scsi_dh_rdac.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c 
b/drivers/scsi/device_handler/scsi_dh_rdac.c
index 3613581..151b736 100644
--- a/drivers/scsi/device_handler/scsi_dh_rdac.c
+++ b/drivers/scsi/device_handler/scsi_dh_rdac.c
@@ -834,6 +834,22 @@ static void rdac_bus_detach( struct scsi_device *sdev )
        kfree(h);
 }
 
+static int rdac_state(struct scsi_device *sdev)
+{
+       struct rdac_dh_data *h = sdev->handler_data;
+       int access_state = SCSI_ACCESS_STATE_OPTIMAL;
+
+       if (h->lun_state == RDAC_LUN_UNOWNED)
+               access_state = SCSI_ACCESS_STATE_ACTIVE;
+       if (h->state == RDAC_STATE_PASSIVE)
+               access_state = SCSI_ACCESS_STATE_PASSIVE;
+
+       if (h->preferred == RDAC_PREFERRED)
+               access_state |= SCSI_ACCESS_STATE_PREFERRED;
+
+       return access_state;
+}
+
 static struct scsi_device_handler rdac_dh = {
        .name = RDAC_NAME,
        .module = THIS_MODULE,
@@ -842,6 +858,7 @@ static struct scsi_device_handler rdac_dh = {
        .attach = rdac_bus_attach,
        .detach = rdac_bus_detach,
        .activate = rdac_activate,
+       .state = rdac_state,
 };
 
 static int __init rdac_init(void)
-- 
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to