finally solve the bad sysfs-timing for all of us
During the integration of HAL into the linux hotplug system, we dicover every week a new signaling path that fails cause of the delayed population of the sysfs files, which are connected by symlinks and appear in something like a random order in userspace.
It's pretty complicated to understand the connection between all these files for all the different subsystems with all the exceptions, so most of the users simply sleep a few seconds, but that is not acceptable for our integration work.
Here I try to get all the special knowledge about that behavior together and place that in a simple binary. That program _must_ run first of all other hotplug processsing and every later script, udev or HAL all can get rid of the wild guesses about the right time sysfs is ready.
It will not only wait for the "dev"-file events we handle with udev, also for every /device-device with the corresponding bus link.
It is provided as a patch against the current udev tree and a "install" will place the new program in the hotplug.d directory:
[kay@pim ~]$ tree /etc/hotplug.d/
/etc/hotplug.d/
`-- default
|-- 00-wait_for_sysfs.hotplug -> /sbin/wait_for_sysfs
|-- 10-udev.hotplug -> /sbin/udevsend
|-- 20-hal.hotplug -> /usr/libexec/hal.hotplug
|-- default.hotplug
`-- log.hotplugFor now, it logs the result of the waiting to syslog, to catch any device, that needs special treatment. All newly discovered delay problems, device black/whitelist updates should go into that program and we may remove that kind of specialisation from all the other hotplug programs.
Any patches, reports, testing is more than welcome.
Sample debug:
Sep 21 18:44:07 localhost kernel: usb 3-2: new full speed USB device using address 12 Sep 21 18:44:07 localhost kernel: hub 3-2:1.0: USB hub found Sep 21 18:44:07 localhost kernel: hub 3-2:1.0: 2 ports detected Sep 21 18:44:07 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2' Sep 21 18:44:07 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0' Sep 21 18:44:08 localhost kernel: usb 3-2.1: new full speed USB device using address 13 Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/class/usb/lp0' Sep 21 18:44:08 localhost kernel: drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 13 if 0 alt 1 proto 2 vid 0x067B pid 0x2305 Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.1/3-2.1:1.0' Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.1' Sep 21 18:44:08 localhost udev: configured rule in '/etc/udev/rules.d/50-udev.rules' at line 29 applied, 'lp0' becomes 'usb/%k' Sep 21 18:44:08 localhost udev: creating device node '/udev/usb/lp0' Sep 21 18:44:09 localhost kernel: usb 3-2.2: new full speed USB device using address 14 Sep 21 18:44:09 localhost kernel: pl2303 3-2.2:1.0: PL-2303 converter detected Sep 21 18:44:09 localhost kernel: usb 3-2.2: PL-2303 converter now attached to ttyUSB0 Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2/3-2.2:1.0' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2/3-2.2:1.0/ttyUSB0' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/class/tty/ttyUSB0' Sep 21 18:44:09 localhost udev: creating device node '/udev/ttyUSB0'
Thanks,
Kay
Makefile +12 -3
@@ -33,6 +33,7 @@ TESTER = udevtest STARTER = udevstart RULER = udevruler +WAIT = wait_for_sysfs VERSION = 032 INSTALL_DIR = /usr/local/bin RELEASE_NAME = $(ROOT)-$(VERSION)
@@ -172,7 +173,7 @@ CFLAGS += -I$(PWD)/libsysfs -all: $(ROOT) $(SENDER) $(DAEMON) $(INFO) $(TESTER) +all: $(ROOT) $(SENDER) $(DAEMON) $(INFO) $(TESTER) $(WAIT) @extras="$(EXTRAS)" ; for target in $$extras ; do \ echo $$target ; \ $(MAKE) prefix=$(prefix) \
@@ -285,10 +286,14 @@ $(LD) $(LDFLAGS) -o $@ $(CRT0) udevruler.o udev_lib.o udev_config.o udevdb.o $(SYSFS) $(TDB) $(LIB_OBJS) $(ARCH_LIB_OBJS) -lnewt $(STRIPCMD) $@ +$(WAIT): $(WAIT).o $(OBJS) $(HEADERS) $(LIBC) + $(LD) $(LDFLAGS) -o $@ $(CRT0) $(WAIT).o $(SYSFS) $(LIB_OBJS) $(ARCH_LIB_OBJS) + $(STRIPCMD) $@ + clean: -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ | xargs rm -f - -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(GEN_MANPAGES) $(INFO) $(DAEMON) $(SENDER) $(TESTER) $(RULER) + -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(GEN_MANPAGES) $(INFO) $(DAEMON) $(SENDER) $(TESTER) $(RULER) $(WAIT) $(MAKE) -C klibc clean @extras="$(EXTRAS)" ; for target in $$extras ; do \ echo $$target ; \
@@ -388,8 +393,10 @@ $(INSTALL_PROGRAM) -D $(SENDER) $(DESTDIR)$(sbindir)/$(SENDER) $(INSTALL_PROGRAM) -D $(INFO) $(DESTDIR)$(usrbindir)/$(INFO) $(INSTALL_PROGRAM) -D $(TESTER) $(DESTDIR)$(usrbindir)/$(TESTER) - ln -sf $(sbindir)/udev $(DESTDIR)$(sbindir)/$(STARTER) + $(INSTALL_PROGRAM) -D $(WAIT) $(DESTDIR)$(sbindir)/$(WAIT) + - ln -f -s $(sbindir)/udev $(DESTDIR)$(sbindir)/$(STARTER) - ln -f -s $(sbindir)/$(SENDER) $(DESTDIR)$(hotplugdir)/10-udev.hotplug + - ln -f -s $(sbindir)/$(WAIT) $(DESTDIR)$(hotplugdir)/00-wait_for_sysfs.hotplug ifndef DESTDIR - killall udevd - rm -f $(udevdir)/.udev.tdb
@@ -402,6 +409,7 @@ uninstall: uninstall-man uninstall-dev.d - rm $(hotplugdir)/10-udev.hotplug + - rm $(hotplugdir)/00-wait_for_sysfs.hotplug - rm $(configdir)/rules.d/50-udev.rules - rm $(configdir)/permissions.d/50-udev.permissions - rm $(configdir)/udev.conf
@@ -415,6 +423,7 @@ - rm $(sbindir)/$(STARTER) - rm $(usrbindir)/$(INFO) - rm $(usrbindir)/$(TESTER) + - rm $(usrbindir)/$(WAIT) - rmdir $(hotplugdir) - rm $(udevdir)/.udev.tdb - rmdir $(udevdir)
wait_for_sysfs.c new file +316 -0
316 lines not on this page · raw message
Quoted 51 lines · Kay Sievers
During the integration of HAL into the linux hotplug system, we dicover every week a new signaling path that fails cause of the delayed population of the sysfs files, which are connected by symlinks and appear in something like a random order in userspace.
It's pretty complicated to understand the connection between all these files for all the different subsystems with all the exceptions, so most of the users simply sleep a few seconds, but that is not acceptable for our integration work.
Here I try to get all the special knowledge about that behavior together and place that in a simple binary. That program _must_ run first of all other hotplug processsing and every later script, udev or HAL all can get rid of the wild guesses about the right time sysfs is ready.
It will not only wait for the "dev"-file events we handle with udev, also for every /device-device with the corresponding bus link.
It is provided as a patch against the current udev tree and a "install" will place the new program in the hotplug.d directory:
[kay@pim ~]$ tree
/etc/hotplug.d/
/etc/hotplug.d/
`-- default|-- 00-wait_for_sysfs.hotplug -> /sbin/wait_for_sysfs |-- 10-udev.hotplug -> /sbin/udevsend |-- 20-hal.hotplug -> /usr/libexec/hal.hotplug |-- default.hotplug `-- log.hotplugFor now, it logs the result of the waiting to syslog, to catch any device, that needs special treatment. All newly discovered delay problems, device black/whitelist updates should go into that program and we may remove that kind of specialisation from all the other hotplug programs.
Any patches, reports, testing is more than welcome.
Sample debug:
Sep 21 18:44:07 localhost kernel: usb 3-2: new full speed USB device using address 12 Sep 21 18:44:07 localhost kernel: hub 3-2:1.0: USB hub found Sep 21 18:44:07 localhost kernel: hub 3-2:1.0: 2 ports detected Sep 21 18:44:07 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2' Sep 21 18:44:07 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0' Sep 21 18:44:08 localhost kernel: usb 3-2.1: new full speed USB device using address 13 Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/class/usb/lp0' Sep 21 18:44:08 localhost kernel: drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 13 if 0 alt 1 proto 2 vid 0x067B pid 0x2305 Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.1/3-2.1:1.0' Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.1' Sep 21 18:44:08 localhost udev: configured rule in '/etc/udev/rules.d/50-udev.rules' at line 29 applied, 'lp0' becomes 'usb/%k' Sep 21 18:44:08 localhost udev: creating device node '/udev/usb/lp0'
Quoted 8 lines
Sep 21 18:44:09 localhost kernel: usb 3-2.2: new full speed USB device using address 14 Sep 21 18:44:09 localhost kernel: pl2303 3-2.2:1.0: PL-2303 converter detected Sep 21 18:44:09 localhost kernel: usb 3-2.2: PL-2303 converter now attached to ttyUSB0 Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2/3-2.2:1.0' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2/3-2.2:1.0/ttyUSB0' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/class/tty/ttyUSB0' Sep 21 18:44:09 localhost udev: creating device node '/udev/ttyUSB0'
New version with more devices excluded from /device-link saerch and a better maching for device names.
Thanks,
Kay
Makefile +12 -3
@@ -33,6 +33,7 @@ TESTER = udevtest STARTER = udevstart RULER = udevruler +WAIT = wait_for_sysfs VERSION = 032 INSTALL_DIR = /usr/local/bin RELEASE_NAME = $(ROOT)-$(VERSION)
@@ -172,7 +173,7 @@ CFLAGS += -I$(PWD)/libsysfs -all: $(ROOT) $(SENDER) $(DAEMON) $(INFO) $(TESTER) +all: $(ROOT) $(SENDER) $(DAEMON) $(INFO) $(TESTER) $(WAIT) @extras="$(EXTRAS)" ; for target in $$extras ; do \ echo $$target ; \ $(MAKE) prefix=$(prefix) \
@@ -285,10 +286,14 @@ $(LD) $(LDFLAGS) -o $@ $(CRT0) udevruler.o udev_lib.o udev_config.o udevdb.o $(SYSFS) $(TDB) $(LIB_OBJS) $(ARCH_LIB_OBJS) -lnewt $(STRIPCMD) $@ +$(WAIT): $(WAIT).o $(OBJS) $(HEADERS) $(LIBC) + $(LD) $(LDFLAGS) -o $@ $(CRT0) $(WAIT).o $(SYSFS) $(LIB_OBJS) $(ARCH_LIB_OBJS) + $(STRIPCMD) $@ + clean: -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ | xargs rm -f - -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(GEN_MANPAGES) $(INFO) $(DAEMON) $(SENDER) $(TESTER) $(RULER) + -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(GEN_MANPAGES) $(INFO) $(DAEMON) $(SENDER) $(TESTER) $(RULER) $(WAIT) $(MAKE) -C klibc clean @extras="$(EXTRAS)" ; for target in $$extras ; do \ echo $$target ; \
@@ -388,8 +393,10 @@ $(INSTALL_PROGRAM) -D $(SENDER) $(DESTDIR)$(sbindir)/$(SENDER) $(INSTALL_PROGRAM) -D $(INFO) $(DESTDIR)$(usrbindir)/$(INFO) $(INSTALL_PROGRAM) -D $(TESTER) $(DESTDIR)$(usrbindir)/$(TESTER) - ln -sf $(sbindir)/udev $(DESTDIR)$(sbindir)/$(STARTER) + $(INSTALL_PROGRAM) -D $(WAIT) $(DESTDIR)$(sbindir)/$(WAIT) + - ln -f -s $(sbindir)/udev $(DESTDIR)$(sbindir)/$(STARTER) - ln -f -s $(sbindir)/$(SENDER) $(DESTDIR)$(hotplugdir)/10-udev.hotplug + - ln -f -s $(sbindir)/$(WAIT) $(DESTDIR)$(hotplugdir)/00-wait_for_sysfs.hotplug ifndef DESTDIR - killall udevd - rm -f $(udevdir)/.udev.tdb
@@ -402,6 +409,7 @@ uninstall: uninstall-man uninstall-dev.d - rm $(hotplugdir)/10-udev.hotplug + - rm $(hotplugdir)/00-wait_for_sysfs.hotplug - rm $(configdir)/rules.d/50-udev.rules - rm $(configdir)/permissions.d/50-udev.permissions - rm $(configdir)/udev.conf
@@ -415,6 +423,7 @@ - rm $(sbindir)/$(STARTER) - rm $(usrbindir)/$(INFO) - rm $(usrbindir)/$(TESTER) + - rm $(usrbindir)/$(WAIT) - rmdir $(hotplugdir) - rm $(udevdir)/.udev.tdb - rmdir $(udevdir)
wait_for_sysfs.c new file +334 -0
334 lines not on this page · raw message
Quoted 61 lines · Kay Sievers
Quoted 51 lines · Kay Sievers
During the integration of HAL into the linux hotplug system, we dicover every week a new signaling path that fails cause of the delayed population of the sysfs files, which are connected by symlinks and appear in something like a random order in userspace.
It's pretty complicated to understand the connection between all these files for all the different subsystems with all the exceptions, so most of the users simply sleep a few seconds, but that is not acceptable for our integration work.
Here I try to get all the special knowledge about that behavior together and place that in a simple binary. That program _must_ run first of all other hotplug processsing and every later script, udev or HAL all can get rid of the wild guesses about the right time sysfs is ready.
It will not only wait for the "dev"-file events we handle with udev, also for every /device-device with the corresponding bus link.
It is provided as a patch against the current udev tree and a "install" will place the new program in the hotplug.d directory:
[kay@pim ~]$ tree
/etc/hotplug.d/
/etc/hotplug.d/
`-- default|-- 00-wait_for_sysfs.hotplug -> /sbin/wait_for_sysfs |-- 10-udev.hotplug -> /sbin/udevsend |-- 20-hal.hotplug -> /usr/libexec/hal.hotplug |-- default.hotplug `-- log.hotplugFor now, it logs the result of the waiting to syslog, to catch any device, that needs special treatment. All newly discovered delay problems, device black/whitelist updates should go into that program and we may remove that kind of specialisation from all the other hotplug programs.
Any patches, reports, testing is more than welcome.
Sample debug:
Sep 21 18:44:07 localhost kernel: usb 3-2: new full speed USB device using address 12 Sep 21 18:44:07 localhost kernel: hub 3-2:1.0: USB hub found Sep 21 18:44:07 localhost kernel: hub 3-2:1.0: 2 ports detected Sep 21 18:44:07 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2' Sep 21 18:44:07 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0' Sep 21 18:44:08 localhost kernel: usb 3-2.1: new full speed USB device using address 13 Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/class/usb/lp0' Sep 21 18:44:08 localhost kernel: drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 13 if 0 alt 1 proto 2 vid 0x067B pid 0x2305 Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.1/3-2.1:1.0' Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.1' Sep 21 18:44:08 localhost udev: configured rule in '/etc/udev/rules.d/50-udev.rules' at line 29 applied, 'lp0' becomes 'usb/%k' Sep 21 18:44:08 localhost udev: creating device node '/udev/usb/lp0'Quoted 8 lines
Sep 21 18:44:09 localhost kernel: usb 3-2.2: new full speed USB device using address 14 Sep 21 18:44:09 localhost kernel: pl2303 3-2.2:1.0: PL-2303 converter detected Sep 21 18:44:09 localhost kernel: usb 3-2.2: PL-2303 converter now attached to ttyUSB0 Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2/3-2.2:1.0' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2/3-2.2:1.0/ttyUSB0' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/class/tty/ttyUSB0' Sep 21 18:44:09 localhost udev: creating device node '/udev/ttyUSB0'
Quoted 2 lines
New version with more devices excluded from /device-link saerch and a better maching for device names.
Fixed version with even more exceptions for devices without busses.
Thanks,
Kay
Makefile +12 -3
@@ -33,6 +33,7 @@ TESTER = udevtest STARTER = udevstart RULER = udevruler +WAIT = wait_for_sysfs VERSION = 032 INSTALL_DIR = /usr/local/bin RELEASE_NAME = $(ROOT)-$(VERSION)
@@ -172,7 +173,7 @@ CFLAGS += -I$(PWD)/libsysfs -all: $(ROOT) $(SENDER) $(DAEMON) $(INFO) $(TESTER) +all: $(ROOT) $(SENDER) $(DAEMON) $(INFO) $(TESTER) $(WAIT) @extras="$(EXTRAS)" ; for target in $$extras ; do \ echo $$target ; \ $(MAKE) prefix=$(prefix) \
@@ -285,10 +286,14 @@ $(LD) $(LDFLAGS) -o $@ $(CRT0) udevruler.o udev_lib.o udev_config.o udevdb.o $(SYSFS) $(TDB) $(LIB_OBJS) $(ARCH_LIB_OBJS) -lnewt $(STRIPCMD) $@ +$(WAIT): $(WAIT).o $(OBJS) $(HEADERS) $(LIBC) + $(LD) $(LDFLAGS) -o $@ $(CRT0) $(WAIT).o $(SYSFS) $(LIB_OBJS) $(ARCH_LIB_OBJS) + $(STRIPCMD) $@ + clean: -find . \( -not -type d \) -and \( -name '*~' -o -name '*.[oas]' \) -type f -print \ | xargs rm -f - -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(GEN_MANPAGES) $(INFO) $(DAEMON) $(SENDER) $(TESTER) $(RULER) + -rm -f core $(ROOT) $(GEN_HEADERS) $(GEN_CONFIGS) $(GEN_MANPAGES) $(INFO) $(DAEMON) $(SENDER) $(TESTER) $(RULER) $(WAIT) $(MAKE) -C klibc clean @extras="$(EXTRAS)" ; for target in $$extras ; do \ echo $$target ; \
@@ -388,8 +393,10 @@ $(INSTALL_PROGRAM) -D $(SENDER) $(DESTDIR)$(sbindir)/$(SENDER) $(INSTALL_PROGRAM) -D $(INFO) $(DESTDIR)$(usrbindir)/$(INFO) $(INSTALL_PROGRAM) -D $(TESTER) $(DESTDIR)$(usrbindir)/$(TESTER) - ln -sf $(sbindir)/udev $(DESTDIR)$(sbindir)/$(STARTER) + $(INSTALL_PROGRAM) -D $(WAIT) $(DESTDIR)$(sbindir)/$(WAIT) + - ln -f -s $(sbindir)/udev $(DESTDIR)$(sbindir)/$(STARTER) - ln -f -s $(sbindir)/$(SENDER) $(DESTDIR)$(hotplugdir)/10-udev.hotplug + - ln -f -s $(sbindir)/$(WAIT) $(DESTDIR)$(hotplugdir)/05-wait_for_sysfs.hotplug ifndef DESTDIR - killall udevd - rm -f $(udevdir)/.udev.tdb
@@ -402,6 +409,7 @@ uninstall: uninstall-man uninstall-dev.d - rm $(hotplugdir)/10-udev.hotplug + - rm $(hotplugdir)/05-wait_for_sysfs.hotplug - rm $(configdir)/rules.d/50-udev.rules - rm $(configdir)/permissions.d/50-udev.permissions - rm $(configdir)/udev.conf
@@ -415,6 +423,7 @@ - rm $(sbindir)/$(STARTER) - rm $(usrbindir)/$(INFO) - rm $(usrbindir)/$(TESTER) + - rm $(usrbindir)/$(WAIT) - rmdir $(hotplugdir) - rm $(udevdir)/.udev.tdb - rmdir $(udevdir)
wait_for_sysfs.c new file +365 -0
365 lines not on this page · raw message
Greg KH
AppliedQuoted 61 lines · Kay Sievers
Quoted 51 lines · Kay Sievers
During the integration of HAL into the linux hotplug system, we dicover every week a new signaling path that fails cause of the delayed population of the sysfs files, which are connected by symlinks and appear in something like a random order in userspace.
It's pretty complicated to understand the connection between all these files for all the different subsystems with all the exceptions, so most of the users simply sleep a few seconds, but that is not acceptable for our integration work.
Here I try to get all the special knowledge about that behavior together and place that in a simple binary. That program _must_ run first of all other hotplug processsing and every later script, udev or HAL all can get rid of the wild guesses about the right time sysfs is ready.
It will not only wait for the "dev"-file events we handle with udev, also for every /device-device with the corresponding bus link.
It is provided as a patch against the current udev tree and a "install" will place the new program in the hotplug.d directory:
[kay@pim ~]$ tree
/etc/hotplug.d/
/etc/hotplug.d/
`-- default|-- 00-wait_for_sysfs.hotplug -> /sbin/wait_for_sysfs |-- 10-udev.hotplug -> /sbin/udevsend |-- 20-hal.hotplug -> /usr/libexec/hal.hotplug |-- default.hotplug `-- log.hotplugFor now, it logs the result of the waiting to syslog, to catch any device, that needs special treatment. All newly discovered delay problems, device black/whitelist updates should go into that program and we may remove that kind of specialisation from all the other hotplug programs.
Any patches, reports, testing is more than welcome.
Sample debug:
Sep 21 18:44:07 localhost kernel: usb 3-2: new full speed USB device using address 12 Sep 21 18:44:07 localhost kernel: hub 3-2:1.0: USB hub found Sep 21 18:44:07 localhost kernel: hub 3-2:1.0: 2 ports detected Sep 21 18:44:07 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2' Sep 21 18:44:07 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0' Sep 21 18:44:08 localhost kernel: usb 3-2.1: new full speed USB device using address 13 Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/class/usb/lp0' Sep 21 18:44:08 localhost kernel: drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 13 if 0 alt 1 proto 2 vid 0x067B pid 0x2305 Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.1/3-2.1:1.0' Sep 21 18:44:08 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.1' Sep 21 18:44:08 localhost udev: configured rule in '/etc/udev/rules.d/50-udev.rules' at line 29 applied, 'lp0' becomes 'usb/%k' Sep 21 18:44:08 localhost udev: creating device node '/udev/usb/lp0'Quoted 8 lines
Sep 21 18:44:09 localhost kernel: usb 3-2.2: new full speed USB device using address 14 Sep 21 18:44:09 localhost kernel: pl2303 3-2.2:1.0: PL-2303 converter detected Sep 21 18:44:09 localhost kernel: usb 3-2.2: PL-2303 converter now attached to ttyUSB0 Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2/3-2.2:1.0' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2.2/3-2.2:1.0/ttyUSB0' Sep 21 18:44:09 localhost 00-wait_for_sysfs.hotplug: result: waiting for sysfs successful '/class/tty/ttyUSB0' Sep 21 18:44:09 localhost udev: creating device node '/udev/ttyUSB0'
Quoted 2 lines
New version with more devices excluded from /device-link saerch and a better maching for device names.
Applied, thanks.
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 6 lines · Greg KH
Quoted 3 lines · Kay Sievers
Quoted 3 lines
For now, it logs the result of the waiting to syslog, to catch any device, that needs special treatment.
Applied, thanks.
Sorry, I left my debug code in. We don't need to log a successful operation. On failure we log and ask to report the device, so we hopefully collect all unusual device representations over the time and can put in in the built-in exception lists.
Thanks,
Kay
===== wait_for_sysfs.c 1.1 vs edited =====
wait_for_sysfs.c +6 -2
@@ -206,6 +206,8 @@ int main(int argc, char *argv[], char *eint loop;int rc =0 ; +init_logging ("wait_for_sysfs" ); +if (argc !=2 ) {dbg ("error: subsystem" );return 1 ;
@@ -326,9 +328,11 @@ int main(int argc, char *argv[], char *e exit:if (rc ==0 ) -info ("result: waiting for sysfs successful '%s'" , devpath); +dbg ("result: waiting for sysfs successful '%s'" , devpath);else -info ("result: waiting for sysfs failed '%s'" , devpath); +info ("error: wait_for_sysfs needs an update to handle the device '%s' " +"properly, please report to <[email protected]>" , + devpath);return rc; }