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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Hannes Reinecke <hare@xxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux