Linux Hotplug development
 help / color / mirror / Atom feed
* drive removes and then re-adds itself causing udev rule to re-run
@ 2011-10-03 12:07 brad
  2011-10-03 12:30 ` Kay Sievers
  0 siblings, 1 reply; 2+ messages in thread
From: brad @ 2011-10-03 12:07 UTC (permalink / raw)
  To: linux-hotplug

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





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-03 12:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-03 12:07 drive removes and then re-adds itself causing udev rule to re-run brad
2011-10-03 12:30 ` Kay Sievers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox