From: Patrick Mansfield Date: Fri, 13 Feb 2004 01:13:10 +0000 Subject: [PATCH] hotplug scsi.agent script avoid race on scsi type attribute Message-Id: <20040212171310.A4258@beaverton.ibm.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-hotplug@vger.kernel.org Hi - I'm not sure who is maintaining this, let me know if I'm sending to the wrong address. This patch against hotplug-2004_01_05 avoids a race while trying to determine the type of scsi device found. Without the patch, the automatic loading of upper level drivers sometimes fails, with errors like: Feb 12 16:21:09 elm3b79 scsi.agent[3003]: how to add device type= at /devices/pci0000:01/0000:01:0c.0/host5/5:0:2:0 ?? diff -uprN -X /home/patman/dontdiff hotplug-2004_01_05-orig/etc/hotplug/scsi.agent hotplug-2004_01_05/etc/hotplug/scsi.agent --- hotplug-2004_01_05-orig/etc/hotplug/scsi.agent Wed Dec 11 14:05:06 2002 +++ hotplug-2004_01_05/etc/hotplug/scsi.agent Thu Feb 12 16:23:22 2004 @@ -18,7 +18,26 @@ add) exit 1 fi - TYPE=$(cat /sys/$DEVPATH/type) + TYPE_ATTR=/sys$DEVPATH/type + + # Possibly sleep here to try and avoid races with scsi attributes and block + # devices + count + while [ ! -f $TYPE_ATTR -a $count -gt 0 ] + do + # We seem to always hit this now, so don't output any message. + debug_mesg "waiting for $TYPE_ATTR" + sleep 1 + let count=count+1 + done + + if [ ! -f $TYPE_ATTR ] + then + mesg "Attribute $TYPE_ATTR does not exist" + exit 1 + fi + + TYPE=$(cat $TYPE_ATTR) case "$TYPE" in # 2.5.51 style attributes; TYPE_* constants 0) TYPE=disk ; MODULE=sd_mod ;; ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id56&alloc_id438&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel