linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Mansfield <patmans@us.ibm.com>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] hotplug scsi.agent script avoid race on scsi type attribute
Date: Fri, 13 Feb 2004 01:13:10 +0000	[thread overview]
Message-ID: <20040212171310.A4258@beaverton.ibm.com> (raw)

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\x10
+    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; <scsi/scsi.h> 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_id\x1356&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

                 reply	other threads:[~2004-02-13  1:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040212171310.A4258@beaverton.ibm.com \
    --to=patmans@us.ibm.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).