mpt0 and removing disks

Tomas Hlavacek tomas.hlavacek at elfove.cz
Fri Sep 24 22:18:32 UTC 2010


Hi!

I had the same problem and I tried to research a bit into that. I tried
to read the Linux mptsas driver, but I have only found out that lots of
messages from HW are ignored in FreeBSD. It would be job lasting month
(at least for me) to understand what does it mean and how to port the
hotplugging-related code to FreeBSD.

So I have made a simple hack or workaround to make FreeBSD kernel notice
that device is lost when I physically disconnect the disk to prevent
freeze and/or kernel panic (that's what happened to me when I
disconnected one or more disks being used at the moment by ZFS).

I have to warn that I am not a FreeBSD developer at all, actually I am
pretty new here in *BSD. But anyway, this hack (for FreeBSD-stable)
worked for me:

--- sys/dev/mpt/mpt_cam.c.orig	2010-07-22 17:38:36.000000000 +0200
+++ sys/dev/mpt/mpt_cam.c	2010-09-24 23:19:30.000000000 +0200
@@ -2415,6 +2415,12 @@
 		xpt_async(AC_BUS_RESET, mpt->path, NULL);
 		break;
 
+// Hacked MPI_EVENT_SAS_PHY_LINK_STATUS handler to react on SAS device removal.
+	case MPI_EVENT_SAS_PHY_LINK_STATUS:
+		mpt_prt(mpt, "Bus reset due to SAS PHY link status change.\n");
+		xpt_async(AC_BUS_RESET, mpt->path, NULL);
+		break;
+
 	case MPI_EVENT_RESCAN:
 #if __FreeBSD_version >= 600000
 	{

It seems that it prevents ending up in the loop waiting for command
completion on SATA disks since the device is kicked out before. With SAS
disks it behaves a bit differently: Few timeouts and completing
timeouted/... messages are printed but after a while it resets driver
and realizes that the disk is lost.

I think it would be much better to parse data0 and/or data1 variables in
order to react only on device removal but I have not succeeded to
understand to meaning of each bit there, even though I tried to consult
(much more advanced) Linux mptsas driver.

BTW.: Sorry for starting a new thread for this. I just subscribed to the
mailinglist and so in archives I can not see Message-ID and other
headers of the original message to properly reply on it.

Tomas

-- 
Tomáš Hlaváček <tomas.hlavacek at elfove.cz>



More information about the freebsd-scsi mailing list