RE: failover does not work with rdac device handler

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

 



Hi,

Can you try the attached patch.

chandra
PS: I see a problem (not related to this patch) that the dh_state file
is not getting recreated, still working on it.

-------------

Keep a reference count of attaches, so that same number of detaches are allowed.

Signed-off-by: Chandra Seetharaman <sekharan@xxxxxxxxxx>
---
Index: linux-2.6.27-rc8-git5/drivers/scsi/device_handler/scsi_dh.c
===================================================================
--- linux-2.6.27-rc8-git5.orig/drivers/scsi/device_handler/scsi_dh.c
+++ linux-2.6.27-rc8-git5/drivers/scsi/device_handler/scsi_dh.c
@@ -153,12 +153,26 @@ static int scsi_dh_handler_attach(struct
 	if (sdev->scsi_dh_data) {
 		if (sdev->scsi_dh_data->scsi_dh != scsi_dh)
 			err = -EBUSY;
-	} else if (scsi_dh->attach)
+		else
+			kref_get(&sdev->scsi_dh_data.kref);
+	} else if (scsi_dh->attach) {
 		err = scsi_dh->attach(sdev);
+		if (!err)
+			kref_init(&sdev->scsi_dh_data.kref);
+	}
 
 	return err;
 }
 
+static void scsi_dh_release(struct *kref kref)
+{
+	struct scsi_dh_data *scsi_dh_data;
+	scsi_dh_data = container_of(kref, struct scsi_dh_data, kref);
+
+	if (scsi_dh_data->scsi_dh && scsi_dh_data->scsi_dh->detach)
+		scsi_dh_data->scsi_dh->detach(sdev);
+}
+
 /*
  * scsi_dh_handler_detach - Detach a device handler from a device
  * @sdev - SCSI device the device handler should be detached from
@@ -176,11 +190,7 @@ static void scsi_dh_handler_detach(struc
 	if (scsi_dh && scsi_dh != sdev->scsi_dh_data->scsi_dh)
 		return;
 
-	if (!scsi_dh)
-		scsi_dh = sdev->scsi_dh_data->scsi_dh;
-
-	if (scsi_dh && scsi_dh->detach)
-		scsi_dh->detach(sdev);
+	kref_put(&sdev->scsi_dh_data.kref, scsi_dh_release);
 }
 
 /*
Index: linux-2.6.27-rc8-git5/include/scsi/scsi_device.h
===================================================================
--- linux-2.6.27-rc8-git5.orig/include/scsi/scsi_device.h
+++ linux-2.6.27-rc8-git5/include/scsi/scsi_device.h
@@ -191,6 +191,7 @@ struct scsi_device_handler {
 
 struct scsi_dh_data {
 	struct scsi_device_handler *scsi_dh;
+	struct kref kref;
 	char buf[0];
 };
 


--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux