Linux Hotplug development
 help / color / mirror / Atom feed
From: brad@16systems.com
To: linux-hotplug@vger.kernel.org
Subject: drive removes and then re-adds itself causing udev rule to re-run
Date: Mon, 03 Oct 2011 12:07:38 +0000	[thread overview]
Message-ID: <41252.128.173.192.90.1317643658.squirrel@webmail.tuffmail.net> (raw)

I have a udev rule to detect when drives are added to a system via an
esata drive dock. Here is the rule:

ACTION="add", KERNEL="sd?", RUN+="/bin/bash /home/rbt/Desktop/script.sh
$kernel"

I use the rule to get the kernel name of the device (sdc, sdd, sde, etc.)
and write it to a file. I normally use this rule on a one slot esata drive
dock and in that case, it works fine.

However, when I use a multi-slot esata drive dock (4 drive slots) drives
sometimes remove themselves and then immediately re-add themselves causing
the rule to fire multiple times. The drives that do this have not been
physically removed from the drive dock and have not powered down. When
this occurs, it causes a bug in my program as that's not expected to
occur.

# udevadm --version = 157

Could anyone on the list offer advice on how to prevent the re-firing of
the rule? I'm going to try setting a env var to prevent firing of the
rule:

ACTION="add", KERNEL="sd?", ENV{status}!="done", ENV{status}="done",
RUN+="/bin/bash /home/rbt/Desktop/script.sh $kernel"

But I suspect that it won't work as udev thinks the device was removed
(even though it wasn't and then re-added) so the variable won't be set.
Here's a log I captured showing the removal and re-addition:

KERNEL[1317412756.066853] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0
(bsg)
KERNEL[1317412756.066883] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg4
(scsi_generic)
KERNEL[1317412756.066900] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0
(scsi_device)
KERNEL[1317412756.066917] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0
(scsi_disk)
KERNEL[1317412756.066995] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc/sdc2
(block)
KERNEL[1317412756.067020] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc/sdc1
(block)
UDEV  [1317412756.067829] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0
(bsg)
UDEV  [1317412756.067854] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg4
(scsi_generic)
UDEV  [1317412756.067871] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0
(scsi_disk)
KERNEL[1317412756.070392] remove   /devices/virtual/bdi/8:32 (bdi)
KERNEL[1317412756.070420] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc
(block)
UDEV  [1317412756.070499] remove   /devices/virtual/bdi/8:32 (bdi)
UDEV  [1317412756.070658] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0
(scsi_device)
UDEV  [1317412756.071349] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc/sdc2
(block)
UDEV  [1317412756.071864] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc/sdc1
(block)
KERNEL[1317412756.074152] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0
(scsi)
KERNEL[1317412756.074172] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0 (scsi)
KERNEL[1317412756.074187] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0 (scsi)
KERNEL[1317412756.074201] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0
(scsi)
KERNEL[1317412756.074215] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0
(scsi_disk)
KERNEL[1317412756.074229] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0
(scsi_device)
KERNEL[1317412756.074246] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg4
(scsi_generic)
KERNEL[1317412756.074273] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0
(bsg)
UDEV  [1317412756.079955] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc
(block)
UDEV  [1317412756.080552] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0
(scsi)
UDEV  [1317412756.081001] remove  
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0 (scsi)
UDEV  [1317412756.081182] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0 (scsi)
UDEV  [1317412756.082019] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0
(scsi)
UDEV  [1317412756.082037] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0
(scsi_device)
UDEV  [1317412756.082260] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0
(scsi_disk)
UDEV  [1317412756.084781] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg4
(scsi_generic)
UDEV  [1317412756.084886] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0
(bsg)
KERNEL[1317412756.086104] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc
(block)
KERNEL[1317412756.086751] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc/sdc1
(block)
KERNEL[1317412756.086818] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc/sdc2
(block)
KERNEL[1317412756.086908] add      /devices/virtual/bdi/8:32 (bdi)
UDEV  [1317412756.087126] add      /devices/virtual/bdi/8:32 (bdi)
UDEV  [1317412756.132662] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc
(block)
UDEV  [1317412756.520435] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc/sdc1
(block)
UDEV  [1317412756.523139] add     
/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:0:0/0:0:0:0/block/sdc/sdc2
(block)

Thanks for any advice!

Brad





             reply	other threads:[~2011-10-03 12:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03 12:07 brad [this message]
2011-10-03 12:30 ` drive removes and then re-adds itself causing udev rule to re-run Kay Sievers

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=41252.128.173.192.90.1317643658.squirrel@webmail.tuffmail.net \
    --to=brad@16systems.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