diff mbox

[5/5] scsi_dh_rdac: Add 'state' callback

Message ID 1436353788-104911-6-git-send-email-hare@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Hannes Reinecke July 8, 2015, 11:09 a.m. UTC
Add a 'state' callback to display the current LUN access state
to sysfs.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/device_handler/scsi_dh_rdac.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox

Patch

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)