Skip to contentSkip to conversation

Hanging udev process on nfs-mounted /dev

DISCUSSION Frank Steiner 3 participants 26 messages Sep 28, 2004 – Oct 8, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

I also sent this to the NFS list, because I'm not sure if this is an NFS or an udev problem. I hope it's ok to ask here!

The issue:
=====
From time to time some udev process goes mad and comsumes allmost all
the CPU power, making the whole system terribly slow.

The software:
======SuSE 9.1, kernel 2.6.8.1, udev 032, klibc 0.179, sysfsutils 1.1.0, hotplug 0.44 (SuSE hotplug package, the rest (udev, klibc, sysfsutils, kernel) has been replaced by newer versions).

My guess:
====Maybe sth. related to nfs? The udev process hangs at/after calling F_SETLKW, see traces below.

We have diskless clients which mount their own /dev over NFS from a server (not shared with other clients, each has its own /dev). Since the clients don't have local hard disks, I guess this cannot be done without NFS because we maintain some permanent links like /dev/cdrecorder -> /dev/hdd, so we need some permanent filesystem. I though about using a ramdisk for /dev on the clients and make udev setup such links, but I'm not sure if a ramdisk for /dev is better than a NFS mount. Would that be worth a try?

/dev is mounted in /etc/init.d/boot, before any other start script runs. Thus, it is mounted with "nolock" because at this time no lockd etc. is running.

How I got the logs:
=========
I moved /sbin/udev to /sbin/utest/ and created a script /sbin/udev with

    #!/bin/bash
    strace -o /var/log/udev.log.`uname -n`.${$} -f /sbin/utest/`basename $0` $@

The first two logs are from the some udev call initiated during the system start, likely by /etc/init.d/boot.device-mapper. The .hangs log is from the hanging udev process.
It was not killed manually, because we did not have a shell at this point, so after some time we hard-rebooted the computer.
The second "succeed" is from the same computer, 5 boots later. So the error does not occur every time.

The other two logs are from a call "/sbin/udev block" initiated by /etc/hotplug/block.agent when calling "pktsetup mycd /dev/cdrecorder" manually. Here we killed the process after 15 minutes as you can see.

The logs are almost identical, just some difference w.r.t to locking.
E.g., the hanging pktsetup process issues some
fcntl64(0, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=4, len=1}) = -1 EAGAIN (Resource temporarily unavailable).

The main difference is at the end: The hanging process hang after some F_SETLKW command:

udevstart.hangs:
========
...

1073  unlink("/dev/mapper/control")     = 0
1073  symlink("../device-mapper", "/dev/mapper/control") = 0
1073  fcntl64(0, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start32, len=1}) = 0
1073  fcntl64(0, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start4, len=1}) = 0

<hangs forever>

udevstart.succeeds:
=========...

1073  unlink("/dev/mapper/control")     = 0
1073  symlink("../device-mapper", "/dev/mapper/control") = 0
1073  fcntl64(0, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start32, len=1}) = 0
1073  fcntl64(0, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start32, len=1}) = 0
1073  open("/etc/dev.d/device-mapper", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = -1 ENOENT (No such file or directory)
1073  open("/etc/dev.d/misc", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = -1 ENOENT (No such file or directory)
1073  open("/etc/dev.d/default", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = -1 ENOENT (No such file or directory)
1073  munmap(0x4001a000, 16384)         = 0
1073  close(0)                          = 0
1073  exit_group(0)                     = ?

udev.pktsetup.hangs:
==========
...
lstat64("/sys/block/pktcdvd0/device", 0xbffff37c) = -1 ENOENT (No such file or directory)
time(NULL) = 1095859917
fcntl64(0, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, startB4, len=1}) = 0
fcntl64(0, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start4, len=1}) = ? ERESTARTSYS (To be restarted) --- SIGTERM (Terminated) @ 0 (0) --- < we killed it here >

munmap(0x4001a000, 114688)              = 0
close(0)                                = 0
exit_group(35)                          = ?

udev.pktsetup.succeds:
===========
...

3161  chmod("/dev/pktcdvd0", 060600)    = 0
3161  fcntl64(0, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, startB4, len=1}) = 0
3161  fcntl64(0, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start4, len=1}) = 0
3161  fcntl64(0, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start4, len=1}) = 0
3161  fcntl64(0, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, startB4, len=1}) = 0
3161  open("/etc/dev.d/pktcdvd0", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = -1 ENOENT (No such file or directory)
3161  open("/etc/dev.d/block", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = -1 ENOENT (No such file or directory)
3161  open("/etc/dev.d/default", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = -1 ENOENT (No such file or directory)
3161  munmap(0x4001a000, 32768)         = 0
3161  close(0)                          = 0
3161  exit_group(0)                     = ?

Could that be a problem related to /dev mounted with "nolock" via NFS, or just some bug in NFS?

I didn't send the full logs, they are quite long. They are here it someone needs to take a look:
http://www.bio.ifi.lmu.de/~steiner/udevstart.hangs
http://www.bio.ifi.lmu.de/~steiner/udevstart.succeeds
http://www.bio.ifi.lmu.de/~steiner/udev.pktsetup.hangs
http://www.bio.ifi.lmu.de/~steiner/udev.pktsetup.succeeds

I greatly appreciate any hints, because this problem hits our hosts quite often and users cannot kill this udev process, so they have to find some admin to kill it :-(

cu,
Frank

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#1 lore raw
Quoted 10 lines · Frank Steiner

Hi,

I also sent this to the NFS list, because I'm not sure if this is an NFS or an udev problem. I hope it's ok to ask here!

The issue:
=====
From time to time some udev process goes mad and comsumes allmost all the CPU power, making the whole system terribly slow.

This isn't a NFS specific bug. I've had a number of reports of this in the past. It traces itself back to a tdb "issue" that the internal database links are getting messed up and looping on themselves wrongly.

Unfortunately I haven't had the time to look into this fully, but hopefully near the end of this week I will.

I'll post here if I find anything out.

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

#2 lore raw
In reply to Frank Steiner
Quoted 7 lines · Greg KH
Quoted 6 lines · Frank Steiner

Hi,

I also sent this to the NFS list, because I'm not sure if this is an NFS or an udev problem. I hope it's ok to ask here!

Quoted 8 lines
Quoted 4 lines

The issue:
=====
From time to time some udev process goes mad and comsumes allmost all the CPU power, making the whole system terribly slow.

This isn't a NFS specific bug. I've had a number of reports of this in the past. It traces itself back to a tdb "issue" that the internal database links are getting messed up and looping on themselves wrongly.

Seems we have two different problems here, one that sounds like a loop consuming all the CPU and onother one, like the trace, which looks like a F_SETLKW deadlock.
The traces are indicating a deadlock, where processes are simply waiting for each other for a write-lock on the udev.tdb to be released.

Kay

-------------------------------------------------------
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

#3 lore raw
In reply to Frank Steiner
Quoted 17 lines · Kay Sievers
Quoted 7 lines · Greg KH
Quoted 6 lines · Frank Steiner

Hi,

I also sent this to the NFS list, because I'm not sure if this is an NFS or an udev problem. I hope it's ok to ask here!

Quoted 8 lines
Quoted 4 lines

The issue:
==========
From time to time some udev process goes mad and comsumes allmost all the CPU power, making the whole system terribly slow.

This isn't a NFS specific bug. I've had a number of reports of this in the past. It traces itself back to a tdb "issue" that the internal database links are getting messed up and looping on themselves wrongly.

Quoted 5 lines

Seems we have two different problems here, one that sounds like a loop consuming all the CPU and onother one, like the trace, which looks like a F_SETLKW deadlock.
The traces are indicating a deadlock, where processes are simply waiting for each other for a write-lock on the udev.tdb to be released.

Here is a patch that implements a timeout for the dead udev process. After 20 seconds the lock system call is interrupted and the error debug from tdb is logged to the syslog. I needed to port the sleep() calls, cause they are not compatible with alarm().

As I can't reproduce this on my box, I locked the complete database with a simple test program. A deadlock in the db-open call now looks like this:

udev: main: looking at '/block/hda'
udev: error: timout reached, node probably not created, please report to <[email protected]>
udev: tdb_brlock failed (fd=4) at offset 0 rw_type=1 lck_type=7
udev: tdb_open_ex: failed to get global lock on /dev/.udev.tdb: Interrupted system call
udev: udevdb_init: unable to initialize database at '/dev/.udev.tdb'
udev: main: unable to initialize database

Maybe this will help to bring some light into the tdb failure.

Good luck,
Kay

===== namedev.c 1.146 vs edited =====

namedev.c +6 -13
@@ -29,7 +29,6 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <errno.h>
-#include <time.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/sysinfo.h>
@@ -353,7 +352,6 @@ static struct bus_file {
 	{}
 };
 
-#define SECONDS_TO_WAIT_FOR_FILE	10
 static void wait_for_device_to_initialize(struct sysfs_device *sysfs_device)
 {
 	/* sleep until we see the file for this specific bus type show up this
@@ -367,14 +365,14 @@ static void wait_for_device_to_initializ
 	struct bus_file *b = &bus_files[0];
 	struct sysfs_attribute *tmpattr;
 	int found = 0;
-	int loop = SECONDS_TO_WAIT_FOR_FILE;
+	int loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 
 	while (1) {
 		if (b->bus == NULL) {
 			if (!found)
 				break;
-			/* sleep to give the kernel a chance to create the file */
-			sleep(1);
+			/* give the kernel a chance to create the file */
+			usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 			--loop;
 			if (loop == 0)
 				break;
@@ -682,7 +680,6 @@ static struct sysfs_device *get_sysfs_de
 {
 	struct sysfs_device *sysfs_device;
 	struct sysfs_class_device *class_dev_parent;
-	struct timespec tspec;
 	int loop;
 
 	/* Figure out where the device symlink is at.  For char devices this will
@@ -698,16 +695,14 @@ static struct sysfs_device *get_sysfs_de
 	if (class_dev_parent != NULL) 
 		dbg("given class device has a parent, use this instead");
 
-	tspec.tv_sec = 0;
-	tspec.tv_nsec = 10000000;  /* sleep 10 millisec */
-	loop = 10;
+	loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 	while (loop--) {
 		if (udev_sleep) {
 			if (whitelist_search(class_dev)) {
 				sysfs_device = NULL;
 				goto exit;
 			}
-			nanosleep(&tspec, NULL);
+			usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 		}
 
 		if (class_dev_parent)
@@ -729,11 +724,9 @@ device_found:
 		if (sysfs_device->bus[0] != '\0')
 			goto bus_found;
 
-		loop = 10;
-		tspec.tv_nsec = 10000000;
 		while (loop--) {
 			if (udev_sleep)
-				nanosleep(&tspec, NULL);
+				usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 			sysfs_get_device_bus(sysfs_device);
 			
 			if (sysfs_device->bus[0] != '\0')

===== udev-add.c 1.73 vs edited =====

udev-add.c +2 -3
@@ -340,11 +340,10 @@ exit:
 /* wait for the "dev" file to show up in the directory in sysfs.
  * If it doesn't happen in about 10 seconds, give up.
  */
-#define SECONDS_TO_WAIT_FOR_FILE	10
 static int sleep_for_file(const char *path, char* file)
 {
 	char filename[SYSFS_PATH_MAX + 6];
-	int loop = SECONDS_TO_WAIT_FOR_FILE;
+	int loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 	int retval;
 
 	strfieldcpy(filename, sysfs_path);
@@ -360,7 +359,7 @@ static int sleep_for_file(const char *pa
 			goto exit;
 
 		/* sleep to give the kernel a chance to create the dev file */
-		sleep(1);
+		usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 	}
 	retval = -ENODEV;
 exit:

===== udev.c 1.62 vs edited =====

udev.c +16 -1
@@ -36,6 +36,9 @@
 #include "namedev.h"
 #include "udevdb.h"
 
+/* timeout flag for udevdb */
+extern sig_atomic_t gotalarm;
+
 /* global variables */
 char **main_argv;
 char **main_envp;
@@ -58,6 +61,11 @@ void log_message(int level, const char *
 asmlinkage static void sig_handler(int signum)
 {
 	switch (signum) {
+		case SIGALRM:
+			gotalarm = 1;
+			info("error: timout reached, node probably not created, "
+			     "please report to <[email protected]> ");
+			break;
 		case SIGINT:
 		case SIGTERM:
 			udevdb_exit();
@@ -147,14 +155,21 @@ int main(int argc, char *argv[], char *e
 	/* set signal handlers */
 	act.sa_handler = sig_handler;
 	sigemptyset (&act.sa_mask);
+
+	/* alarm should interrupt */
+	sigaction(SIGALRM, &act, NULL);
+
 	act.sa_flags = SA_RESTART;
 	sigaction(SIGINT, &act, NULL);
 	sigaction(SIGTERM, &act, NULL);
 
+	/* trigger timout */
+	alarm(20);
+
 	/* initialize udev database */
 	if (udevdb_init(UDEVDB_DEFAULT) != 0) {
 		dbg("unable to initialize database");
-		goto exit;
+		exit(1);
 	}
 
 	switch(act_type) {

===== udev.h 1.62 vs edited =====

udev.h +2 -0
@@ -26,6 +26,8 @@
 #include <sys/param.h>
 #include "libsysfs/sysfs/libsysfs.h"
 
+#define WAIT_FOR_FILE_SECONDS		10
+#define WAIT_FOR_FILE_RETRY_FREQ	10
 #define COMMENT_CHARACTER		'#'
 
 #define NAME_SIZE			256

===== udevdb.c 1.30 vs edited =====

udevdb.c +16 -2
@@ -42,7 +42,19 @@
 #include "tdb/tdb.h"
 
 static TDB_CONTEXT *udevdb;
+sig_atomic_t gotalarm;
 
+static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...)
+{
+	va_list args;
+
+	if (!udev_log)
+		return;
+
+	va_start(args, format);
+	vsyslog(level, format, args);
+	va_end(args);
+}
 
 int udevdb_add_dev(const char *path, const struct udevice *dev)
 {
@@ -121,7 +133,9 @@ int udevdb_init(int init_flag)
 	if (init_flag != UDEVDB_DEFAULT && init_flag != UDEVDB_INTERNAL)
 		return -EINVAL;
 
-	udevdb = tdb_open(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644);
+	tdb_set_lock_alarm(&gotalarm);
+
+	udevdb = tdb_open_ex(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644, tdb_log);
 	if (udevdb == NULL) {
 		if (init_flag == UDEVDB_INTERNAL)
 			dbg("unable to initialize in-memory database");
@@ -137,7 +151,7 @@ int udevdb_init(int init_flag)
  */
 int udevdb_open_ro(void)
 {
-	udevdb = tdb_open(udev_db_filename, 0, 0, O_RDONLY, 0);
+	udevdb = tdb_open_ex(udev_db_filename, 0, 0, O_RDONLY, 0, tdb_log);
 	if (udevdb == NULL) {
 		dbg("unable to open database at '%s'", udev_db_filename);
 		return -EACCES;
#4 lore raw
In reply to Frank Steiner

Kay Sievers wrote

Quoted 5 lines
Quoted 5 lines

Seems we have two different problems here, one that sounds like a loop consuming all the CPU and onother one, like the trace, which looks like a F_SETLKW deadlock.
The traces are indicating a deadlock, where processes are simply waiting for each other for a write-lock on the udev.tdb to be released.

That would match my observation that there seemed to be 2-3 udev processes started almost at the same time. Since I recorded all the udev traces with the ppid in the log name, I could see that there were always three processes started close together (the log files having the same timestamp and the ppids not differing much, like pids 29465, 29470 and 29473), so they might deadlock.

However, also note that these problems so far occured only on hosts having /dev/ mounted via NFS. Maybe the slow NFS traffic (in comparison to the local hard disk) is well-suited for triggering the deadlock.

Quoted 4 lines

Here is a patch that implements a timeout for the dead udev process. After 20 seconds the lock system call is interrupted and the error debug from tdb is logged to the syslog. I needed to port the sleep() calls, cause they are not compatible with alarm().

Thanks for the patch, I will apply it and try to reproduce the situations! If I get a log, I will send it here.

A general question: Someone on the NFS mailing list proposed to remove the NFS mount for dev and replace it by some tmpfs mounted on /dev. SuSE is not really prepared for it, so udevstart misses a lot of devices like /dev/stderr etc., but I could hack this myself easily. Is it safe to assume that one should have less problems with a tmpfs dev compared to a NFS mount?

cu,
Frank

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
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
#5 lore raw
In reply to Frank Steiner

Just one more comment:

Kay Sievers wrote

Quoted 2 lines
Quoted 2 lines

The traces are indicating a deadlock, where processes are simply waiting for each other for a write-lock on the udev.tdb to be released.

The /dev mounts are mounted with "nolock". Could that be a reason for that problem? Usually I would expect both processes to write concurrently without the "lock" option, maybe destroying the udev.tdb? But perhaps the effect of "nolock" is different in this case, causing the deadlock...

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
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
#6 lore raw
In reply to Frank Steiner
Quoted 8 lines · Frank Steiner

Kay Sievers wrote

Quoted 5 lines
Quoted 5 lines

Seems we have two different problems here, one that sounds like a loop consuming all the CPU and onother one, like the trace, which looks like a F_SETLKW deadlock.
The traces are indicating a deadlock, where processes are simply waiting for each other for a write-lock on the udev.tdb to be released.

Quoted 6 lines

That would match my observation that there seemed to be 2-3 udev processes started almost at the same time. Since I recorded all the udev traces with the ppid in the log name, I could see that there were always three processes started close together (the log files having the same timestamp and the ppids not differing much, like pids 29465, 29470 and 29473), so they might deadlock.

It would be nice to know, if there is posssibly one process spinning at this time, which blocks all the other processes? Or if there is a "real" deadlock, where all processes are blocking in the lock call. You may increase the alarm()-timout to have more than 20 seconds to investigate this :)

Quoted 3 lines

However, also note that these problems so far occured only on hosts having /dev/ mounted via NFS. Maybe the slow NFS traffic (in comparison to the local hard disk) is well-suited for triggering the deadlock.

Sounds possible.

Quoted 8 lines
Quoted 4 lines

Here is a patch that implements a timeout for the dead udev process. After 20 seconds the lock system call is interrupted and the error debug from tdb is logged to the syslog. I needed to port the sleep() calls, cause they are not compatible with alarm().

Thanks for the patch, I will apply it and try to reproduce the situations! If I get a log, I will send it here.

Quoted 6 lines

A general question: Someone on the NFS mailing list proposed to remove the NFS mount for dev and replace it by some tmpfs mounted on /dev. SuSE is not really prepared for it, so udevstart misses a lot of devices like /dev/stderr etc., but I could hack this myself easily. Is it safe to assume that one should have less problems with a tmpfs dev compared to a NFS mount?

Yeah, it does not sound very sane to do concurrent writing to the same file over nfs without proper locking. A local tmpfs-based /dev seems more appropriate for that. It should be faster anyway and there is no reason to store the /dev anywhere while using udev.

Thanks,
Kay

-------------------------------------------------------
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

#7 lore raw
In reply to Frank Steiner

Kay Sievers wrote

Quoted 3 lines

It would be nice to know, if there is posssibly one process spinning at this time, which blocks all the other processes? Or if there is a "real" deadlock, where all processes are blocking in the lock call.

As far as I remember, when the udev process was running with 90% cpu time, it was the only udev process (pgrep udev).

Quoted 2 lines

You may increase the alarm()-timout to have more than 20 seconds to investigate this :)

I will try, but the hosts where the problem occured most frequently are desktop clients of research asisstants. So it is not that easy to debug it without stopping the users from working :-)

Quoted 4 lines

Yeah, it does not sound very sane to do concurrent writing to the same file over nfs without proper locking. A local tmpfs-based /dev seems more appropriate for that. It should be faster anyway and there is no reason to store the /dev anywhere while using udev.

With debugging and logging enabled now (needed for your patch to compile), I get lots of messages from udev broadcasted to every shell, which is quite annoying for the users, because they get all their xterms filled:

Oct  1 05:46:50 noether udevinfo[336]: rec_read bad magic 0xd9fee666 at offsety12

And this about 15 times, every time the card reader reconnects. On the hosts where I already replaces /dev/ with a tmpfs, those messages do not appear at all. Apart from /dev-over-nfs vs. /dev-over-tmpfs there are no differences between these hosts. So it seems that the nfs causes some other problems, that tmpfs is not suffering from. I would like to switch all hosts to tmpfs immediately, but I'm afraid I won't get any deadlocks anymore so that we cannot do useful debugging :-)

cu,
Frank

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
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
#8 lore raw
In reply to Frank Steiner
Quoted 8 lines · Frank Steiner

Kay Sievers wrote

Quoted 3 lines

It would be nice to know, if there is posssibly one process spinning at this time, which blocks all the other processes? Or if there is a "real" deadlock, where all processes are blocking in the lock call.

As far as I remember, when the udev process was running with 90% cpu time, it was the only udev process (pgrep udev).

This may be the process that blocks all the other ones. If you can find one of these beasts, please attach gdb to the running process and look if we find something in the backtrace. Here is a sample from my "lock the whole file"-test application:

* [root@pim ~]# gdb -p 14727
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. Attaching to process 14727
...
Reading symbols from /home/kay/src/lock...(no debugging symbols found)...done.
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
0x0804839f in spin ()
* (gdb) bt
#0 0x0804839f in spin ()
#1 0x08048405 in main ()
* (gdb) q
The program is running. Quit anyway (and detach it)? (y or n) y Detaching from program: /home/kay/src/lock, process 14727 [root@pim ~]#

Quoted 5 lines

With debugging and logging enabled now (needed for your patch to compile), I get lots of messages from udev broadcasted to every shell, which is quite annoying for the users, because they get all their xterms filled:

Oct  1 05:46:50 noether udevinfo[336]: rec_read bad magic 0xd9fee666 at offsety12

Oops, that is from the tdb-code and indicates a corrupt database, which is likely the reason for all the bad behavior. You may try to "rm /dev/.udev.tdb" and look if these messages are going away. The next udev run will create a new one.

Does "udevinfo -d" (database dump) print anything?

The /dev is stored on nfs and not cleaned and recreated with udevstart before mounting, right? So the database may be corrupt since a long time?

Best,
Kay

-------------------------------------------------------
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

#9 lore raw
In reply to Frank Steiner

Hi,

here we go :-) On reboot, one of the clients ran into the haning udev process. Althoug the timeout patch was applied, the hanging udev process was not killed.
But it blocked a lot of other processes because there are messages about "timeout reached" in /var/log/messages. I had to reboot the PC (the professors client :-)), but I tried to collect all information that might be helpful.

I've put all the logs on a website. They include /var/log/messages from the point where the system bootet until it hung, a "ps -aux" output while udev was hanging, and the straces for all udev processes started during the boot. Recall that I replaced /sbin/udev{start} by

strace -o /var/log/udev.log.uname -n.${$} -f /sbin/utest/basename $0 $@

and moved the original udev and udevstart to /sbin/utest/. All the information is here: http://www.bio.ifi.lmu.de/~steiner/udev/
The udev traces are sorted in "ls -lat" order.

The udev process that was hanging had pid 9700. The matching strace is udev.log.noether.9652. After calling "pkill udev" to make the host usable again, three straces were changed. Those are listed with both versions, so that one can see what happened after killing (don't know if this helps). Again, the hanging udev process hung after F_SETLKW:
...

9700  fcntl64(5, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start(8, len=1}) = 0
9700  fcntl64(5, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, startt924, len=1}) = 0
9700  fcntl64(5, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, startt924, len=1}) = 0
9700  fcntl64(5, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start4, len=1}) = 0
9700  --- SIGALRM (Alarm clock) @ 0 (0) ---
9700  time([1096612648])                = 1096612648
9700  rt_sigaction(SIGPIPE, {0x40116ae0, [], SA_RESTORER, 0x40067aa8}, {SIG_DFL}, 8) = 0
9700  send(0, "<14>Oct  1 08:37:28 udev: error:"..., 137, 0) = 137
9700  rt_sigaction(SIGPIPE, {SIG_DFL}, NULL, 8) = 0
9700  sigreturn()                       = ? (mask now [])

And after "pkill udev" those lines were added:

9700  --- SIGTERM (Terminated) @ 0 (0) ---
9700  munmap(0x4001a000, 81920)         = 0
9700  close(5)                          = 0
9700  exit_group(35)                    = ?

I hope these information help!

cu,
Frank

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
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
#10 lore raw
In reply to Frank Steiner

Kay Sievers wrote

Quoted 4 lines

This may be the process that blocks all the other ones. If you can find one of these beasts, please attach gdb to the running process and look if we find something in the backtrace. Here is a sample from my "lock the whole file"-test application:

Arrrgggh damn! I wish I had waited a bit longer with killing the process so that I had read this mail before and could have tried the gdb :-(( But since it was the professors (my boss :-)) client, he wanted to have it back working quickly.

I will try to get the lock again on another host by rebooting it over and over again, maybe I can trigger the lock.

Quoted 11 lines
Quoted 5 lines

With debugging and logging enabled now (needed for your patch to compile), I get lots of messages from udev broadcasted to every shell, which is quite annoying for the users, because they get all their xterms filled:

Oct  1 05:46:50 noether udevinfo[336]: rec_read bad magic 0xd9fee666 at offsety12

Oops, that is from the tdb-code and indicates a corrupt database, which is likely the reason for all the bad behavior. You may try to "rm /dev/.udev.tdb" and look if these messages are going away. The next udev run will create a new one.

Hmm, this sounds like the problem is NFS without locking. Maybe two processes indeed write concurrently to the database, thus corrupting it. That would also explain why I don't see any of these messages on the tmpfs hosts.
I wish there was a solution for nfsroot with nfs locking :-(

Quoted 1 line

Does "udevinfo -d" (database dump) print anything?

Not very much, just 4 entries:

noether /var/log# udevinfo -d
P: /block/fd0
N: fd0
T: b
M: 060660
S:
O: root
G: disk
F:
L: 0
U: 55

P: /block/loop4
N: loop4
T: b
M: 060660
S:
O: root
G: disk
F:
L: 0
U: 55

P: /block/ram0
N: ram0
T: b
M: 060660
S:
O: root
G: disk
F:
L: 0
U: 56

P: /class/scsi_generic/sg0
N: sg0
T: c
M: 020640
S: by-path/usb-storage-00000000710D:0:0:0-generic
O: root
G: disk
F: /etc/udev/rules.d/udev.rules
L: 6
U: 498

noether /var/log#
Message from syslogd@noether at Fri Oct 1 09:44:59 2004 ... noether udevinfo[11629]: rec_read bad magic 0xd9fee666 at offsetc176

And that's it. On a hardware-identical host with /dev being a tmpfs, I have a bout 180 entries!

Quoted 4 lines

The /dev is stored on nfs and not cleaned and recreated with udevstart before mounting, right? So the database may be corrupt since a long time?

boot.udev is run on boot, so it recreates the database on every start, and thus, it looks like it gets corrupted again on almost every boot. Note that my scenario here is a little bit mixed because I just started using udev by backporting the hotplug stuff from SuSE 9.1 to SuSE 9.0. But SuSE 9.1 is still using a static /dev and udev just for certain things like hotplugging of e.g. usb devices or pktsetup etc. Since most of the boot script from SuSE are not prepared for working with an empty /dev, many devices are missing if I run udevstart on an empty /dev. E.g, things like /dev/stdin etc. Because I didn't want to hack every SuSE script, I kept their static devices (from a devs.rpm) but boot.udev is still running.

I can try to reproduce it on another host to get the gdb stuff, but I feel pretty sure now that it is problem with the "nolock" mount option for the NFS-based /dev...

cu,
Frank

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
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
#11 lore raw
In reply to Frank Steiner
Quoted 5 lines · Frank Steiner

Hi,

here we go :-) On reboot, one of the clients ran into the haning udev process. Althoug the timeout patch was applied, the hanging udev process was not killed.

That's ok. The signal handler does not kill the process. It is just a timeout to interrupt a system call waiting for the kernel. The tdb code return unsuccessful if it catches that timeout. The hanging udev version is spinning by itself (not hanging in a system call) and therefore will do that forever.

Quoted 4 lines

But it blocked a lot of other processes because there are messages about "timeout reached" in /var/log/messages. I had to reboot the PC (the professors client :-)), but I tried to collect all information that might be helpful.

Yes, sure, it is. We're getting closer.

Quoted 18 lines

I've put all the logs on a website. They include /var/log/messages from the point where the system bootet until it hung, a "ps -aux" output while udev was hanging, and the straces for all udev processes started during the boot. Recall that I replaced /sbin/udev{start} by

strace -o /var/log/udev.log.uname -n.${$} -f /sbin/utest/basename $0 $@

and moved the original udev and udevstart to /sbin/utest/. All the information is here: http://www.bio.ifi.lmu.de/~steiner/udev/
The udev traces are sorted in "ls -lat" order.

The udev process that was hanging had pid 9700. The matching strace is udev.log.noether.9652. After calling "pkill udev" to make the host usable again, three straces were changed. Those are listed with both versions, so that one can see what happened after killing (don't know if this helps). Again, the hanging udev process hung after F_SETLKW:
...

Quoted 10 lines
9700  fcntl64(5, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start(8, len=1}) = 0
9700  fcntl64(5, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, startt924, len=1}) = 0
9700  fcntl64(5, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, startt924, len=1}) = 0
9700  fcntl64(5, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start4, len=1}) = 0
9700  --- SIGALRM (Alarm clock) @ 0 (0) ---
9700  time([1096612648])                = 1096612648
9700  rt_sigaction(SIGPIPE, {0x40116ae0, [], SA_RESTORER, 0x40067aa8}, {SIG_DFL}, 8) = 0
9700  send(0, "<14>Oct  1 08:37:28 udev: error:"..., 137, 0) = 137
9700  rt_sigaction(SIGPIPE, {SIG_DFL}, NULL, 8) = 0
9700  sigreturn()                       = ? (mask now [])

Yes, that's the fault. Seems that this process locks the db-file and then keeps spinning forever without doing system calls. It's just a loop inside of the tdb code. It consumed a lot of your CPU:

Quoted 2 lines
root      9688  0.0  0.0  1696  600 ?        S<   08:37   0:00 strace -o /var/log/udev.log.noether.9652 -f /sbin/utest/udev scsi_generic
root      9700 99.9  0.0  1664  604 ?        R<   08:37  17:37 /sbin/utest/udev scsi_generic

Thanks,
Kay

-------------------------------------------------------
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

#12 lore raw
In reply to Frank Steiner

Kay Sievers wrote

Quoted 6 lines
Quoted 2 lines

boot.udev is run on boot, so it recreates the database on every start, and thus, it looks like it gets corrupted again on almost every boot.

Weird! Please double check that this script is really running. There is nothing in the boot.msg file, but I don't know if there should be some.

It is definitely running: The link is in boot.d:
noether /root# ls -la /etc/init.d/boot.d/S01boot.udev
lrwxrwxrwx 1 root root 12 2004-09-30 08:57 /etc/init.d/boot.d/S01boot.udev -> ../boot.udev

and boot.udev contains:
case "$1" in
start)
if [ -x /sbin/udev -a -x /sbin/udevstart ] ; then
echo -n "creating device nodes "
rm -f /dev/.udev.tdb
/sbin/udevstart

You can also see this in the strace log of the first udev process,
which is the last on the page (the lowest pid number). The first
line of this strace is
1037 execve("/sbin/utest/udevstart", ["/sbin/utest/udevstart"], [/* 174 vars */]) = 0

A general question for understanding things better: Let's assume that the errors indeed are caused by missing nfs locking on my /dev dir. It sounds reasonable that udev must be able to rely on propper locking for maintaining its database, so one should not expect it to work on a fs without locking.
Would it be reasonable to issue a warning if udev detects it's running on a fs without locking (if this is possible to detect)? Or, if in case of missing locks the hangs cannot be prevented, udev could even refuse to do any work. If one gets a message from udev "No locks available. I will not create any devices until you give me locks" this would definitely help people doing stupid things like mounting /dev via NFS :-)

I'm still trying to get another host hanging, so that I can login and call gdb. I'll let you know if it happens :-)

cu,
Frank

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
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
#13 lore raw
In reply to Frank Steiner
Quoted 8 lines · Frank Steiner

Kay Sievers wrote

Quoted 4 lines

This may be the process that blocks all the other ones. If you can find one of these beasts, please attach gdb to the running process and look if we find something in the backtrace. Here is a sample from my "lock the whole file"-test application:

Quoted 4 lines

Arrrgggh damn! I wish I had waited a bit longer with killing the process so that I had read this mail before and could have tried the gdb :-(( But since it was the professors (my boss :-)) client, he wanted to have it back working quickly.

Hey, it already consumed 17 minutes of the CPU. I think he has a better job for that CPU than a spinning udev :)

Quoted 8 lines
Quoted 7 lines
Quoted 1 line
Oct  1 05:46:50 noether udevinfo[336]: rec_read bad magic 0xd9fee666 at offsety12

Oops, that is from the tdb-code and indicates a corrupt database, which is likely the reason for all the bad behavior. You may try to "rm /dev/.udev.tdb" and look if these messages are going away. The next udev run will create a new one.

Quoted 4 lines

Hmm, this sounds like the problem is NFS without locking. Maybe two processes indeed write concurrently to the database, thus corrupting it. That would also explain why I don't see any of these messages on the tmpfs hosts.

This is probably what happens here, yes.

Quoted 3 lines
Quoted 1 line

Does "udevinfo -d" (database dump) print anything?

Not very much, just 4 entries:

This database if definitely corrupt.

Quoted 6 lines
Quoted 3 lines

The /dev is stored on nfs and not cleaned and recreated with udevstart before mounting, right? So the database may be corrupt since a long time?

boot.udev is run on boot, so it recreates the database on every start, and thus, it looks like it gets corrupted again on almost every boot.

Weird! Please double check that this script is really running. There is nothing in the boot.msg file, but I don't know if there should be some.

Thanks,
Kay

-------------------------------------------------------
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

#14 lore raw
In reply to Frank Steiner
Quoted 11 lines · Frank Steiner

A general question for understanding things better: Let's assume that the errors indeed are caused by missing nfs locking on my /dev dir. It sounds reasonable that udev must be able to rely on propper locking for maintaining its database, so one should not expect it to work on a fs without locking.
Would it be reasonable to issue a warning if udev detects it's running on a fs without locking (if this is possible to detect)? Or, if in case of missing locks the hangs cannot be prevented, udev could even refuse to do any work. If one gets a message from udev "No locks available. I will not create any devices until you give me locks" this would definitely help people doing stupid things like mounting /dev via NFS :-)

We should find the loop bug first. Then the alarm() should be sufficient to prevent a hanging udev. Yes, we may include a hint in the logged error.

We still can create nodes with udev, even with a corrupt database (I will change the alarm() patch to act like this later). Only the remove event will eventually fail, if a rule has set a custom name for the device.
Other programs asking with udevinfo, may also not work correctly, but it's better to create the node without bookkeeping than to do nothing, I think.

Best,
Kay

-------------------------------------------------------
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

#15 lore raw
In reply to Frank Steiner
Quoted 18 lines · Kay Sievers
Quoted 11 lines · Frank Steiner

A general question for understanding things better: Let's assume that the errors indeed are caused by missing nfs locking on my /dev dir. It sounds reasonable that udev must be able to rely on propper locking for maintaining its database, so one should not expect it to work on a fs without locking.
Would it be reasonable to issue a warning if udev detects it's running on a fs without locking (if this is possible to detect)? Or, if in case of missing locks the hangs cannot be prevented, udev could even refuse to do any work. If one gets a message from udev "No locks available. I will not create any devices until you give me locks" this would definitely help people doing stupid things like mounting /dev via NFS :-)

We should find the loop bug first. Then the alarm() should be sufficient to prevent a hanging udev. Yes, we may include a hint in the logged error.

Quoted 7 lines

We still can create nodes with udev, even with a corrupt database (I will change the alarm() patch to act like this later). Only the remove event will eventually fail, if a rule has set a custom name for the device.
Other programs asking with udevinfo, may also not work correctly, but it's better to create the node without bookkeeping than to do nothing, I think.

Here is a new patch to try to recover from a corrupted udev database. udev will now continue without database support in that case and log the failure to syslog. So the node should be generated in any case, remove will obviously not work for custom names. All tdb errors will be logged to syslog.

I've added two iteration limits to the tdb-code at the places I expect the endless loop. In the case we try to find more than 100.000 db-entries with the same hash, we better give up :)

Good luck,
Kay

===== namedev.c 1.146 vs edited =====

namedev.c +8 -14
@@ -29,7 +29,6 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <errno.h>
-#include <time.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/sysinfo.h>
@@ -353,7 +352,6 @@
 	{}
 };
 
-#define SECONDS_TO_WAIT_FOR_FILE	10
 static void wait_for_device_to_initialize(struct sysfs_device *sysfs_device)
 {
 	/* sleep until we see the file for this specific bus type show up this
@@ -367,14 +365,14 @@
 	struct bus_file *b = &bus_files[0];
 	struct sysfs_attribute *tmpattr;
 	int found = 0;
-	int loop = SECONDS_TO_WAIT_FOR_FILE;
+	int loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 
 	while (1) {
 		if (b->bus == NULL) {
 			if (!found)
 				break;
-			/* sleep to give the kernel a chance to create the file */
-			sleep(1);
+			/* give the kernel a chance to create the file */
+			usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 			--loop;
 			if (loop == 0)
 				break;
@@ -394,7 +392,8 @@
 	}
 	if (!found)
 		dbg("did not find bus type '%s' on list of bus_id_files, "
-		    "contact [email protected]", sysfs_device->bus);
+		    "please report to <[email protected]>",
+		    sysfs_device->bus);
 exit:
 	return; /* here to prevent compiler warning... */
 }
@@ -682,7 +681,6 @@
 {
 	struct sysfs_device *sysfs_device;
 	struct sysfs_class_device *class_dev_parent;
-	struct timespec tspec;
 	int loop;
 
 	/* Figure out where the device symlink is at.  For char devices this will
@@ -698,16 +696,14 @@
 	if (class_dev_parent != NULL) 
 		dbg("given class device has a parent, use this instead");
 
-	tspec.tv_sec = 0;
-	tspec.tv_nsec = 10000000;  /* sleep 10 millisec */
-	loop = 10;
+	loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 	while (loop--) {
 		if (udev_sleep) {
 			if (whitelist_search(class_dev)) {
 				sysfs_device = NULL;
 				goto exit;
 			}
-			nanosleep(&tspec, NULL);
+			usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 		}
 
 		if (class_dev_parent)
@@ -729,11 +725,9 @@
 		if (sysfs_device->bus[0] != '\0')
 			goto bus_found;
 
-		loop = 10;
-		tspec.tv_nsec = 10000000;
 		while (loop--) {
 			if (udev_sleep)
-				nanosleep(&tspec, NULL);
+				usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 			sysfs_get_device_bus(sysfs_device);
 			
 			if (sysfs_device->bus[0] != '\0')

===== udev-add.c 1.73 vs edited =====

udev-add.c +2 -3
@@ -340,11 +340,10 @@
 /* wait for the "dev" file to show up in the directory in sysfs.
  * If it doesn't happen in about 10 seconds, give up.
  */
-#define SECONDS_TO_WAIT_FOR_FILE	10
 static int sleep_for_file(const char *path, char* file)
 {
 	char filename[SYSFS_PATH_MAX + 6];
-	int loop = SECONDS_TO_WAIT_FOR_FILE;
+	int loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 	int retval;
 
 	strfieldcpy(filename, sysfs_path);
@@ -360,7 +359,7 @@
 			goto exit;
 
 		/* sleep to give the kernel a chance to create the dev file */
-		sleep(1);
+		usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 	}
 	retval = -ENODEV;
 exit:

===== udev.c 1.62 vs edited =====

udev.c +19 -5
@@ -36,6 +36,9 @@
 #include "namedev.h"
 #include "udevdb.h"
 
+/* timeout flag for udevdb */
+extern sig_atomic_t gotalarm;
+
 /* global variables */
 char **main_argv;
 char **main_envp;
@@ -58,6 +61,11 @@
 asmlinkage static void sig_handler(int signum)
 {
 	switch (signum) {
+		case SIGALRM:
+			gotalarm = 1;
+			info("error: timeout reached, event probably not handled correctly, "
+			     "please report to <[email protected]> ");
+			break;
 		case SIGINT:
 		case SIGTERM:
 			udevdb_exit();
@@ -94,7 +102,8 @@
 
 	dbg("version %s", UDEV_VERSION);
 
-	/* initialize our configuration */
+	init_logging("udev");
+
 	udev_init_config();
 
 	if (strstr(argv[0], "udevstart")) {
@@ -147,15 +156,20 @@
 	/* set signal handlers */
 	act.sa_handler = sig_handler;
 	sigemptyset (&act.sa_mask);
+
+	/* alarm should interrupt */
+	sigaction(SIGALRM, &act, NULL);
+
 	act.sa_flags = SA_RESTART;
 	sigaction(SIGINT, &act, NULL);
 	sigaction(SIGTERM, &act, NULL);
 
+	/* trigger timout to interrupt blocking syscalls */
+	alarm(ALARM_TIMEOUT);
+
 	/* initialize udev database */
-	if (udevdb_init(UDEVDB_DEFAULT) != 0) {
-		dbg("unable to initialize database");
-		goto exit;
-	}
+	if (udevdb_init(UDEVDB_DEFAULT) != 0)
+		info("error: unable to initialize database, continuing without database");
 
 	switch(act_type) {
 	case UDEVSTART:

===== udev.h 1.62 vs edited =====

udev.h +3 -0
@@ -26,6 +26,9 @@
 #include <sys/param.h>
 #include "libsysfs/sysfs/libsysfs.h"
 
+#define ALARM_TIMEOUT			20
+#define WAIT_FOR_FILE_SECONDS		10
+#define WAIT_FOR_FILE_RETRY_FREQ	10
 #define COMMENT_CHARACTER		'#'
 
 #define NAME_SIZE			256

===== udevdb.c 1.30 vs edited =====

udevdb.c +28 -2
@@ -42,13 +42,28 @@
 #include "tdb/tdb.h"
 
 static TDB_CONTEXT *udevdb;
+sig_atomic_t gotalarm;
 
+static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...)
+{
+	va_list args;
+
+	if (!udev_log)
+		return;
+
+	va_start(args, format);
+	vsyslog(level, format, args);
+	va_end(args);
+}
 
 int udevdb_add_dev(const char *path, const struct udevice *dev)
 {
 	TDB_DATA key, data;
 	char keystr[SYSFS_PATH_MAX];
 
+	if (udevdb == NULL)
+		return -1;
+
 	if ((path == NULL) || (dev == NULL))
 		return -ENODEV;
 
@@ -68,6 +83,9 @@
 {
 	TDB_DATA key, data;
 
+	if (udevdb == NULL)
+		return -1;
+
 	if (path == NULL)
 		return -ENODEV;
 
@@ -88,6 +106,9 @@
 	TDB_DATA key;
 	char keystr[SYSFS_PATH_MAX];
 
+	if (udevdb == NULL)
+		return -1;
+
 	if (path == NULL)
 		return -EINVAL;
 
@@ -121,7 +142,9 @@
 	if (init_flag != UDEVDB_DEFAULT && init_flag != UDEVDB_INTERNAL)
 		return -EINVAL;
 
-	udevdb = tdb_open(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644);
+	tdb_set_lock_alarm(&gotalarm);
+
+	udevdb = tdb_open_ex(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644, tdb_log);
 	if (udevdb == NULL) {
 		if (init_flag == UDEVDB_INTERNAL)
 			dbg("unable to initialize in-memory database");
@@ -137,7 +160,7 @@
  */
 int udevdb_open_ro(void)
 {
-	udevdb = tdb_open(udev_db_filename, 0, 0, O_RDONLY, 0);
+	udevdb = tdb_open_ex(udev_db_filename, 0, 0, O_RDONLY, 0, tdb_log);
 	if (udevdb == NULL) {
 		dbg("unable to open database at '%s'", udev_db_filename);
 		return -EACCES;
@@ -159,6 +182,9 @@
 int udevdb_call_foreach(int (*user_record_handler) (char *path, struct udevice *dev))
 {
 	int retval = 0;
+
+	if (udevdb == NULL)
+		return -1;
 
 	if (user_record_handler == NULL) {
 		dbg("invalid user record handling function");

===== tdb/tdb.c 1.3 vs edited =====

tdb/tdb.c +20 -2
@@ -980,12 +980,14 @@
 			struct list_struct *r)
 {
 	tdb_off rec_ptr;
-	
+	int maxloop;
+
 	/* read in the hash top */
 	if (ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1)
 		return 0;
 
 	/* keep looking until we find the right record */
+	maxloop = 100000;
 	while (rec_ptr) {
 		if (rec_read(tdb, rec_ptr, r) == -1)
 			return 0;
@@ -1005,6 +1007,12 @@
 			SAFE_FREE(k);
 		}
 		rec_ptr = r->next;
+
+		maxloop--;
+		if (maxloop == 0) {
+			TDB_LOG((tdb, 0, "tdb_find maxloop reached; corrupt database!\n"));
+			return TDB_ERRCODE(TDB_ERR_CORRUPT, 0);
+		}
 	}
 	return TDB_ERRCODE(TDB_ERR_NOEXIST, 0);
 }
@@ -1187,6 +1195,7 @@
 {
 	tdb_off last_ptr, i;
 	struct list_struct lastrec;
+	int maxloop;
 
 	if (tdb->read_only) return -1;
 
@@ -1201,9 +1210,18 @@
 	/* find previous record in hash chain */
 	if (ofs_read(tdb, TDB_HASH_TOP(rec->full_hash), &i) == -1)
 		return -1;
-	for (last_ptr = 0; i != rec_ptr; last_ptr = i, i = lastrec.next)
+
+	maxloop = 100000;
+	for (last_ptr = 0; i != rec_ptr; last_ptr = i, i = lastrec.next) {
 		if (rec_read(tdb, i, &lastrec) == -1)
 			return -1;
+
+		maxloop--;
+		if (maxloop == 0) {
+			TDB_LOG((tdb, 0, "(tdb)do_delete: maxloop reached; corrupt database!\n"));
+			return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
+		}
+	}
 
 	/* unlink it: next ptr is at start of record. */
 	if (last_ptr == 0)
#16 lore raw
In reply to Frank Steiner

Hi,

I got two hosts locked with those hanging udev processes. I can leave them in this state for at least the whole Monday.

Kay Sievers wrote

Quoted 16 lines

This may be the process that blocks all the other ones. If you can find one of these beasts, please attach gdb to the running process and look if we find something in the backtrace. Here is a sample from my "lock the whole file"-test application:

* [root@pim ~]# gdb -p 14727
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. Attaching to process 14727
...
Reading symbols from /home/kay/src/lock...(no debugging symbols found)...done.
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2

Quoted 8 lines

0x0804839f in spin ()
* (gdb) bt
#0 0x0804839f in spin ()
#1 0x08048405 in main ()
* (gdb) q
The program is running. Quit anyway (and detach it)? (y or n) y Detaching from program: /home/kay/src/lock, process 14727 [root@pim ~]#

Unfortunately, this fails :-(

GNU gdb 5.3.92
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-suse-linux".
Attaching to process 24498
ptrace: Operation not permitted.
/export/localhome/root/24498: No such file or directory.

From googling I learned that this could be a problem with child processes
that were forked or sth. similar...

Anything else I can do on the hanging hosts to provide helpful information?

I hope that they don't crash too soon, because there are a lot of hanging udev processes now, with only one taking all the cpu time, Likely the others are all just waiting for the one to unlock the database...

cu,
Frank

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr 17            Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:              -4054
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
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
#17 lore raw
In reply to Frank Steiner
Quoted 46 lines · Frank Steiner

Hi,

I got two hosts locked with those hanging udev processes. I can leave them in this state for at least the whole Monday.

Kay Sievers wrote

Quoted 16 lines

This may be the process that blocks all the other ones. If you can find one of these beasts, please attach gdb to the running process and look if we find something in the backtrace. Here is a sample from my "lock the whole file"-test application:

* [root@pim ~]# gdb -p 14727
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. Attaching to process 14727
...
Reading symbols from /home/kay/src/lock...(no debugging symbols found)...done.
Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2

Quoted 8 lines

0x0804839f in spin ()
* (gdb) bt
#0 0x0804839f in spin ()
#1 0x08048405 in main ()
* (gdb) q
The program is running. Quit anyway (and detach it)? (y or n) y Detaching from program: /home/kay/src/lock, process 14727 [root@pim ~]#

Unfortunately, this fails :-(

GNU gdb 5.3.92
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-suse-linux".
Attaching to process 24498
ptrace: Operation not permitted.
/export/localhome/root/24498: No such file or directory.

Quoted 2 lines

From googling I learned that this could be a problem with child processes
that were forked or sth. similar...

Oh, bad.
It's your running strace that prevents gbd to take the control over the process, I expect. Just try to send the strace parent-process a SIGUSR1 which may leave the udev process running.

Thanks,
Kay

-------------------------------------------------------
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

#18 lore raw
In reply to Frank Steiner

Kay Sievers wrote

Quoted 4 lines

Oh, bad.
It's your running strace that prevents gbd to take the control over the process, I expect. Just try to send the strace parent-process a SIGUSR1 which may leave the udev process running.

Yes, that worked :-) On one host there were already 3 udev processes sharing all the CPU time, on the second it was just one. All four traces look a little bit different, that's why I've attached all four of them. I hope you can fetch sth. useful from the traces...

cu,
Frank

P.S.: I will wait with the patch you sent until you tell me that you got all information from the hanging udevs you need. I can leave the hosts up and hanging for today, one of them even until end of the week!

Signature · 5 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *

turan /root# gdb -p 24498
GNU gdb 5.3.92
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-suse-linux".
Attaching to process 24498
Reading symbols from /sbin/utest/udev...done.
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libnss_compat.so.2...done.
Loaded symbols for /lib/libnss_compat.so.2
Reading symbols from /lib/libnsl.so.1...done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /lib/libnss_nis.so.2...done.
Loaded symbols for /lib/libnss_nis.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
0x400b91be in memcpy () from /lib/i686/libc.so.6
(gdb) bt
#0 0x400b91be in memcpy () from /lib/i686/libc.so.6
#1 0x08056164 in tdb_read (tdb=0x80640a8, off=1073871052, buf=0xbffff2d8,

    len=3221222108, cv=0) at tdb/tdb.c:407
#2  0x080562b9 in ofs_read (tdb=0x4, offset=22728, d=0xbffff2d8)
    at tdb/tdb.c:447
#3  0x080567e4 in remove_from_freelist (tdb=0x80640a8, off=28176, next=696)
    at tdb/tdb.c:628
#4  0x080568d4 in tdb_free (tdb=0x80640a8, offset=27268, rec=0xbffff370)
    at tdb/tdb.c:662
#5  0x08056e2e in tdb_allocate (tdb=0x80640a8, length=884, rec=0xbffff3e0)
    at tdb/tdb.c:910
#6  0x08057e5a in tdb_store (tdb=0x80640a8, key=
      {dptr = 0xbffff450 "/class/scsi_generic/sg3", dsize = 24}, dbuf=
      {dptr = 0xbffff6a0 "sg3", dsize = 856}, flag=1) at tdb/tdb.c:1497
#7  0x0804c361 in udevdb_add_dev (path=0xbfffff67 "/class/scsi_generic/sg3", 
    dev=0xbffff6a0) at udevdb.c:76
#8  0x0804bb66 in udev_add_device (path=0xbfffff67 "/class/scsi_generic/sg3", 
    subsystem=0xbfffff45 "scsi_generic", fake=0) at udev-add.c:446

#9 0x0804971f in main (argc=2, argv=0xbffffd70, envp=0x4) at udev.c:185 (gdb)

knuth /root# gdb -p 12063
GNU gdb 5.3.92
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-suse-linux".
Attaching to process 12063
Reading symbols from /sbin/utest/udev...done.
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
tdb_oob (tdb=0x80640a8, len=3221222944, probe=7004) at tdb/tdb.c:342
342 tdb/tdb.c: No such file or directory.
in tdb/tdb.c
(gdb) bt
#0 tdb_oob (tdb=0x80640a8, len=3221222944, probe=7004) at tdb/tdb.c:342 #1 0x0805638b in rec_read (tdb=0x80640a8, offset=7004, rec=0xbffff620)

    at tdb/tdb.c:466
#2  0x0805703e in tdb_find (tdb=0x80640a8, key=
      {dptr = 0xbfffff60 "/class/scsi_device/26:0:0:0", dsize = 28}, hash=536231552, 
    r=0xbffff620) at tdb/tdb.c:990
#3  0x080571b8 in tdb_find_lock (tdb=0x80640a8, key=
      {dptr = 0xbfffff60 "/class/scsi_device/26:0:0:0", dsize = 28}, locktype=0, 
    rec=0xbffff620) at tdb/tdb.c:1035
#4  0x080572ef in tdb_fetch (tdb=0x80640a8, key=
      {dptr = 0xbfffff60 "/class/scsi_device/26:0:0:0", dsize = 28}) at tdb/tdb.c:1113
#5  0x0804c3a3 in udevdb_get_dev (path=0xffffff00 <Address 0xffffff00 out of bounds>, 
    dev=0xbffff6a0) at udevdb.c:89
#6  0x0804c17f in udev_remove_device (path=0xbfffff60 "/class/scsi_device/26:0:0:0", 
    subsystem=0xbfffff45 "block") at udev-remove.c:170

#7 0x08049760 in main (argc=2, argv=0xbffffd70, envp=0x1b74) at udev.c:189

knuth /root# gdb -p 23587
GNU gdb 5.3.92
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-suse-linux".
Attaching to process 23587
Reading symbols from /sbin/utest/udev...done.
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
0x08055f9a in tdb_oob (tdb=0x80640a8, len=7028, probe=0) at tdb/tdb.c:344
344 tdb/tdb.c: No such file or directory.
in tdb/tdb.c
(gdb) bt
#0 0x08055f9a in tdb_oob (tdb=0x80640a8, len=7028, probe=0) at tdb/tdb.c:344 #1 0x0805613c in tdb_read (tdb=0x80640a8, off=7004, buf=0xbffff620, len=24, cv=0)

    at tdb/tdb.c:403
#2  0x0805631e in rec_read (tdb=0x80640a8, offset=7004, rec=0xbffff620)
    at tdb/tdb.c:458
#3  0x0805703e in tdb_find (tdb=0x80640a8, key=
      {dptr = 0xbfffff61 "/class/scsi_device/9:0:0:2", dsize = 27}, hash=3221149257, 
    r=0xbffff620) at tdb/tdb.c:990
#4  0x080571b8 in tdb_find_lock (tdb=0x80640a8, key=
      {dptr = 0xbfffff61 "/class/scsi_device/9:0:0:2", dsize = 27}, locktype=0, 
    rec=0xbffff620) at tdb/tdb.c:1035
#5  0x080572ef in tdb_fetch (tdb=0x80640a8, key=
      {dptr = 0xbfffff61 "/class/scsi_device/9:0:0:2", dsize = 27}) at tdb/tdb.c:1113
#6  0x0804c3a3 in udevdb_get_dev (path=0x0, dev=0xbffff6a0) at udevdb.c:89
#7  0x0804c17f in udev_remove_device (path=0xbfffff61 "/class/scsi_device/9:0:0:2", 
    subsystem=0xbfffff46 "block") at udev-remove.c:170

#8 0x08049760 in main (argc=2, argv=0xbffffd70, envp=0x0) at udev.c:189 (gdb)

knuth /root# gdb -p 25580
GNU gdb 5.3.92
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-suse-linux".
Attaching to process 25580
Reading symbols from /sbin/utest/udev...done.
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
ofs_read (tdb=0xbffff438, offset=20016, d=0x0) at tdb/tdb.c:446
446 tdb/tdb.c: No such file or directory.
in tdb/tdb.c
(gdb) bt
#0 ofs_read (tdb=0xbffff438, offset=20016, d=0x0) at tdb/tdb.c:446 #1 0x080567e4 in remove_from_freelist (tdb=0x80640a8, off=20016, next=0)

    at tdb/tdb.c:628
#2  0x080568d4 in tdb_free (tdb=0x80640a8, offset=19108, rec=0xbffff520)
    at tdb/tdb.c:662
#3  0x08057586 in do_delete (tdb=0x80640a8, rec_ptr=19108, rec=0xbffff520)
    at tdb/tdb.c:1215
#4  0x08057cc4 in tdb_delete (tdb=0x80640a8, key=
      {dptr = 0xbffff570 "/class/scsi_generic/sg2", dsize = 24}) at tdb/tdb.c:1434
#5  0x0804c475 in udevdb_delete_dev (path=0xbfffff64 "/class/scsi_generic/sg2")
    at udevdb.c:112
#6  0x0804c218 in udev_remove_device (path=0xbfffff64 "/class/scsi_generic/sg2", 
    subsystem=0xbfffff42 "scsi_generic") at udev-remove.c:182

#7 0x08049760 in main (argc=2, argv=0xbffffd70, envp=0xbffff438) at udev.c:189

#19 lore raw
In reply to Frank Steiner
Quoted 11 lines · Frank Steiner

Kay Sievers wrote

Quoted 4 lines

Oh, bad.
It's your running strace that prevents gbd to take the control over the process, I expect. Just try to send the strace parent-process a SIGUSR1 which may leave the udev process running.

Yes, that worked :-) On one host there were already 3 udev processes sharing all the CPU time, on the second it was just one. All four traces look a little bit different, that's why I've attached all four of them. I hope you can fetch sth. useful from the traces...

Ok, let's look at it:

Quoted 19 lines

(gdb) bt
#0 0x400b91be in memcpy () from /lib/i686/libc.so.6
#1 0x08056164 in tdb_read (tdb=0x80640a8, off=1073871052, buf=0xbffff2d8,

    len=3221222108, cv=0) at tdb/tdb.c:407
#2  0x080562b9 in ofs_read (tdb=0x4, offset=22728, d=0xbffff2d8)
    at tdb/tdb.c:447
#3  0x080567e4 in remove_from_freelist (tdb=0x80640a8, off=28176, next=696)
    at tdb/tdb.c:628
#4  0x080568d4 in tdb_free (tdb=0x80640a8, offset=27268, rec=0xbffff370)
    at tdb/tdb.c:662
#5  0x08056e2e in tdb_allocate (tdb=0x80640a8, length=884, rec=0xbffff3e0)
    at tdb/tdb.c:910
#6  0x08057e5a in tdb_store (tdb=0x80640a8, key=
      {dptr = 0xbffff450 "/class/scsi_generic/sg3", dsize = 24}, dbuf=
      {dptr = 0xbffff6a0 "sg3", dsize = 856}, flag=1) at tdb/tdb.c:1497
#7  0x0804c361 in udevdb_add_dev (path=0xbfffff67 "/class/scsi_generic/sg3", 
    dev=0xbffff6a0) at udevdb.c:76
#8  0x0804bb66 in udev_add_device (path=0xbfffff67 "/class/scsi_generic/sg3", 
    subsystem=0xbfffff45 "scsi_generic", fake=0) at udev-add.c:446
Quoted 1 line

#9 0x0804971f in main (argc=2, argv=0xbffffd70, envp=0x4) at udev.c:185

This seems to be a loop in tdb_allocate().

Quoted 16 lines

(gdb) bt
#0 tdb_oob (tdb=0x80640a8, len=3221222944, probe=7004) at tdb/tdb.c:342 #1 0x0805638b in rec_read (tdb=0x80640a8, offset=7004, rec=0xbffff620)

    at tdb/tdb.c:466
#2  0x0805703e in tdb_find (tdb=0x80640a8, key=
      {dptr = 0xbfffff60 "/class/scsi_device/26:0:0:0", dsize = 28}, hash=536231552, 
    r=0xbffff620) at tdb/tdb.c:990
#3  0x080571b8 in tdb_find_lock (tdb=0x80640a8, key=
      {dptr = 0xbfffff60 "/class/scsi_device/26:0:0:0", dsize = 28}, locktype=0, 
    rec=0xbffff620) at tdb/tdb.c:1035
#4  0x080572ef in tdb_fetch (tdb=0x80640a8, key=
      {dptr = 0xbfffff60 "/class/scsi_device/26:0:0:0", dsize = 28}) at tdb/tdb.c:1113
#5  0x0804c3a3 in udevdb_get_dev (path=0xffffff00 <Address 0xffffff00 out of bounds>, 
    dev=0xbffff6a0) at udevdb.c:89
#6  0x0804c17f in udev_remove_device (path=0xbfffff60 "/class/scsi_device/26:0:0:0", 
    subsystem=0xbfffff45 "block") at udev-remove.c:170
Quoted 1 line

#7 0x08049760 in main (argc=2, argv=0xbffffd70, envp=0x1b74) at udev.c:189

This is the loop in tdb_find().

Quoted 17 lines

(gdb) bt
#0 0x08055f9a in tdb_oob (tdb=0x80640a8, len=7028, probe=0) at tdb/tdb.c:344 #1 0x0805613c in tdb_read (tdb=0x80640a8, off=7004, buf=0xbffff620, len=24, cv=0)

    at tdb/tdb.c:403
#2  0x0805631e in rec_read (tdb=0x80640a8, offset=7004, rec=0xbffff620)
    at tdb/tdb.c:458
#3  0x0805703e in tdb_find (tdb=0x80640a8, key=
      {dptr = 0xbfffff61 "/class/scsi_device/9:0:0:2", dsize = 27}, hash=3221149257, 
    r=0xbffff620) at tdb/tdb.c:990
#4  0x080571b8 in tdb_find_lock (tdb=0x80640a8, key=
      {dptr = 0xbfffff61 "/class/scsi_device/9:0:0:2", dsize = 27}, locktype=0, 
    rec=0xbffff620) at tdb/tdb.c:1035
#5  0x080572ef in tdb_fetch (tdb=0x80640a8, key=
      {dptr = 0xbfffff61 "/class/scsi_device/9:0:0:2", dsize = 27}) at tdb/tdb.c:1113
#6  0x0804c3a3 in udevdb_get_dev (path=0x0, dev=0xbffff6a0) at udevdb.c:89
#7  0x0804c17f in udev_remove_device (path=0xbfffff61 "/class/scsi_device/9:0:0:2", 
    subsystem=0xbfffff46 "block") at udev-remove.c:170
Quoted 1 line

#8 0x08049760 in main (argc=2, argv=0xbffffd70, envp=0x0) at udev.c:189

The same tdb_find() loop.

Quoted 14 lines

(gdb) bt
#0 ofs_read (tdb=0xbffff438, offset=20016, d=0x0) at tdb/tdb.c:446 #1 0x080567e4 in remove_from_freelist (tdb=0x80640a8, off=20016, next=0)

    at tdb/tdb.c:628
#2  0x080568d4 in tdb_free (tdb=0x80640a8, offset=19108, rec=0xbffff520)
    at tdb/tdb.c:662
#3  0x08057586 in do_delete (tdb=0x80640a8, rec_ptr=19108, rec=0xbffff520)
    at tdb/tdb.c:1215
#4  0x08057cc4 in tdb_delete (tdb=0x80640a8, key=
      {dptr = 0xbffff570 "/class/scsi_generic/sg2", dsize = 24}) at tdb/tdb.c:1434
#5  0x0804c475 in udevdb_delete_dev (path=0xbfffff64 "/class/scsi_generic/sg2")
    at udevdb.c:112
#6  0x0804c218 in udev_remove_device (path=0xbfffff64 "/class/scsi_generic/sg2", 
    subsystem=0xbfffff42 "scsi_generic") at udev-remove.c:182
Quoted 1 line

#7 0x08049760 in main (argc=2, argv=0xbffffd70, envp=0xbffff438) at udev.c:189

Seems to be a loop in remove_from_freelist().

All here known failure paths are now covered in the attached patch by limiting the iteration count for loops over data read from disk. Let's see what happens next :)

Kay

===== namedev.c 1.146 vs edited =====

namedev.c +8 -14
@@ -29,7 +29,6 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <errno.h>
-#include <time.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/sysinfo.h>
@@ -353,7 +352,6 @@ static struct bus_file {
 	{}
 };
 
-#define SECONDS_TO_WAIT_FOR_FILE	10
 static void wait_for_device_to_initialize(struct sysfs_device *sysfs_device)
 {
 	/* sleep until we see the file for this specific bus type show up this
@@ -367,14 +365,14 @@ static void wait_for_device_to_initializ
 	struct bus_file *b = &bus_files[0];
 	struct sysfs_attribute *tmpattr;
 	int found = 0;
-	int loop = SECONDS_TO_WAIT_FOR_FILE;
+	int loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 
 	while (1) {
 		if (b->bus == NULL) {
 			if (!found)
 				break;
-			/* sleep to give the kernel a chance to create the file */
-			sleep(1);
+			/* give the kernel a chance to create the file */
+			usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 			--loop;
 			if (loop == 0)
 				break;
@@ -394,7 +392,8 @@ static void wait_for_device_to_initializ
 	}
 	if (!found)
 		dbg("did not find bus type '%s' on list of bus_id_files, "
-		    "contact [email protected]", sysfs_device->bus);
+		    "please report to <[email protected]>",
+		    sysfs_device->bus);
 exit:
 	return; /* here to prevent compiler warning... */
 }
@@ -682,7 +681,6 @@ static struct sysfs_device *get_sysfs_de
 {
 	struct sysfs_device *sysfs_device;
 	struct sysfs_class_device *class_dev_parent;
-	struct timespec tspec;
 	int loop;
 
 	/* Figure out where the device symlink is at.  For char devices this will
@@ -698,16 +696,14 @@ static struct sysfs_device *get_sysfs_de
 	if (class_dev_parent != NULL) 
 		dbg("given class device has a parent, use this instead");
 
-	tspec.tv_sec = 0;
-	tspec.tv_nsec = 10000000;  /* sleep 10 millisec */
-	loop = 10;
+	loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 	while (loop--) {
 		if (udev_sleep) {
 			if (whitelist_search(class_dev)) {
 				sysfs_device = NULL;
 				goto exit;
 			}
-			nanosleep(&tspec, NULL);
+			usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 		}
 
 		if (class_dev_parent)
@@ -729,11 +725,9 @@ device_found:
 		if (sysfs_device->bus[0] != '\0')
 			goto bus_found;
 
-		loop = 10;
-		tspec.tv_nsec = 10000000;
 		while (loop--) {
 			if (udev_sleep)
-				nanosleep(&tspec, NULL);
+				usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 			sysfs_get_device_bus(sysfs_device);
 			
 			if (sysfs_device->bus[0] != '\0')

===== udev-add.c 1.73 vs edited =====

udev-add.c +2 -3
@@ -340,11 +340,10 @@ exit:
 /* wait for the "dev" file to show up in the directory in sysfs.
  * If it doesn't happen in about 10 seconds, give up.
  */
-#define SECONDS_TO_WAIT_FOR_FILE	10
 static int sleep_for_file(const char *path, char* file)
 {
 	char filename[SYSFS_PATH_MAX + 6];
-	int loop = SECONDS_TO_WAIT_FOR_FILE;
+	int loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 	int retval;
 
 	strfieldcpy(filename, sysfs_path);
@@ -360,7 +359,7 @@ static int sleep_for_file(const char *pa
 			goto exit;
 
 		/* sleep to give the kernel a chance to create the dev file */
-		sleep(1);
+		usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 	}
 	retval = -ENODEV;
 exit:

===== udev.c 1.62 vs edited =====

udev.c +19 -5
@@ -36,6 +36,9 @@
 #include "namedev.h"
 #include "udevdb.h"
 
+/* timeout flag for udevdb */
+extern sig_atomic_t gotalarm;
+
 /* global variables */
 char **main_argv;
 char **main_envp;
@@ -58,6 +61,11 @@ void log_message(int level, const char *
 asmlinkage static void sig_handler(int signum)
 {
 	switch (signum) {
+		case SIGALRM:
+			gotalarm = 1;
+			info("error: timeout reached, event probably not handled correctly, "
+			     "please report to <[email protected]> ");
+			break;
 		case SIGINT:
 		case SIGTERM:
 			udevdb_exit();
@@ -94,7 +102,8 @@ int main(int argc, char *argv[], char *e
 
 	dbg("version %s", UDEV_VERSION);
 
-	/* initialize our configuration */
+	init_logging("udev");
+
 	udev_init_config();
 
 	if (strstr(argv[0], "udevstart")) {
@@ -147,15 +156,20 @@ int main(int argc, char *argv[], char *e
 	/* set signal handlers */
 	act.sa_handler = sig_handler;
 	sigemptyset (&act.sa_mask);
+
+	/* alarm should interrupt */
+	sigaction(SIGALRM, &act, NULL);
+
 	act.sa_flags = SA_RESTART;
 	sigaction(SIGINT, &act, NULL);
 	sigaction(SIGTERM, &act, NULL);
 
+	/* trigger timout to interrupt blocking syscalls */
+	alarm(ALARM_TIMEOUT);
+
 	/* initialize udev database */
-	if (udevdb_init(UDEVDB_DEFAULT) != 0) {
-		dbg("unable to initialize database");
-		goto exit;
-	}
+	if (udevdb_init(UDEVDB_DEFAULT) != 0)
+		info("error: unable to initialize database, continuing without database");
 
 	switch(act_type) {
 	case UDEVSTART:

===== udev.h 1.62 vs edited =====

udev.h +3 -0
@@ -26,6 +26,9 @@
 #include <sys/param.h>
 #include "libsysfs/sysfs/libsysfs.h"
 
+#define ALARM_TIMEOUT			20
+#define WAIT_FOR_FILE_SECONDS		10
+#define WAIT_FOR_FILE_RETRY_FREQ	10
 #define COMMENT_CHARACTER		'#'
 
 #define NAME_SIZE			256

===== udevdb.c 1.30 vs edited =====

udevdb.c +28 -2
@@ -42,13 +42,28 @@
 #include "tdb/tdb.h"
 
 static TDB_CONTEXT *udevdb;
+sig_atomic_t gotalarm;
 
+static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...)
+{
+	va_list args;
+
+	if (!udev_log)
+		return;
+
+	va_start(args, format);
+	vsyslog(level, format, args);
+	va_end(args);
+}
 
 int udevdb_add_dev(const char *path, const struct udevice *dev)
 {
 	TDB_DATA key, data;
 	char keystr[SYSFS_PATH_MAX];
 
+	if (udevdb == NULL)
+		return -1;
+
 	if ((path == NULL) || (dev == NULL))
 		return -ENODEV;
 
@@ -68,6 +83,9 @@ int udevdb_get_dev(const char *path, str
 {
 	TDB_DATA key, data;
 
+	if (udevdb == NULL)
+		return -1;
+
 	if (path == NULL)
 		return -ENODEV;
 
@@ -88,6 +106,9 @@ int udevdb_delete_dev(const char *path)
 	TDB_DATA key;
 	char keystr[SYSFS_PATH_MAX];
 
+	if (udevdb == NULL)
+		return -1;
+
 	if (path == NULL)
 		return -EINVAL;
 
@@ -121,7 +142,9 @@ int udevdb_init(int init_flag)
 	if (init_flag != UDEVDB_DEFAULT && init_flag != UDEVDB_INTERNAL)
 		return -EINVAL;
 
-	udevdb = tdb_open(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644);
+	tdb_set_lock_alarm(&gotalarm);
+
+	udevdb = tdb_open_ex(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644, tdb_log);
 	if (udevdb == NULL) {
 		if (init_flag == UDEVDB_INTERNAL)
 			dbg("unable to initialize in-memory database");
@@ -137,7 +160,7 @@ int udevdb_init(int init_flag)
  */
 int udevdb_open_ro(void)
 {
-	udevdb = tdb_open(udev_db_filename, 0, 0, O_RDONLY, 0);
+	udevdb = tdb_open_ex(udev_db_filename, 0, 0, O_RDONLY, 0, tdb_log);
 	if (udevdb == NULL) {
 		dbg("unable to open database at '%s'", udev_db_filename);
 		return -EACCES;
@@ -159,6 +182,9 @@ static int traverse_callback(TDB_CONTEXT
 int udevdb_call_foreach(int (*user_record_handler) (char *path, struct udevice *dev))
 {
 	int retval = 0;
+
+	if (udevdb == NULL)
+		return -1;
 
 	if (user_record_handler == NULL) {
 		dbg("invalid user record handling function");

===== tdb/tdb.c 1.3 vs edited =====

tdb/tdb.c +36 -2
@@ -616,8 +616,10 @@ int tdb_printfreelist(TDB_CONTEXT *tdb)
 static int remove_from_freelist(TDB_CONTEXT *tdb, tdb_off off, tdb_off next)
 {
 	tdb_off last_ptr, i;
+	int maxloop;
 
 	/* read in the freelist top */
+	maxloop = 100000;
 	last_ptr = FREELIST_TOP;
 	while (ofs_read(tdb, last_ptr, &i) != -1 && i != 0) {
 		if (i == off) {
@@ -626,6 +628,12 @@ static int remove_from_freelist(TDB_CONT
 		}
 		/* Follow chain (next offset is at start of record) */
 		last_ptr = i;
+
+		maxloop--;
+		if (maxloop == 0) {
+			TDB_LOG((tdb, 0, "remove_from_freelist: maxloop reached; corrupt database!\n"));
+			return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
+		}
 	}
 	TDB_LOG((tdb, 0,"remove_from_freelist: not on list at off=%d\n", off));
 	return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
@@ -852,6 +860,7 @@ static tdb_off tdb_allocate(TDB_CONTEXT 
 {
 	tdb_off rec_ptr, last_ptr, newrec_ptr;
 	struct list_struct newrec;
+	int maxloop;
 
 	if (tdb_lock(tdb, -1, F_WRLCK) == -1)
 		return 0;
@@ -867,6 +876,7 @@ static tdb_off tdb_allocate(TDB_CONTEXT 
 		goto fail;
 
 	/* keep looking until we find a freelist record big enough */
+	maxloop = 100000;
 	while (rec_ptr) {
 		if (rec_free_read(tdb, rec_ptr, rec) == -1)
 			goto fail;
@@ -918,6 +928,12 @@ static tdb_off tdb_allocate(TDB_CONTEXT 
 		/* move to the next record */
 		last_ptr = rec_ptr;
 		rec_ptr = rec->next;
+
+		maxloop--;
+		if (maxloop == 0) {
+			TDB_LOG((tdb, 0, "tdb_allocate: maxloop reached; corrupt database!\n"));
+			return TDB_ERRCODE(TDB_ERR_CORRUPT, 0);
+		}
 	}
 	/* we didn't find enough space. See if we can expand the
 	   database and if we can then try again */
@@ -980,12 +996,14 @@ static tdb_off tdb_find(TDB_CONTEXT *tdb
 			struct list_struct *r)
 {
 	tdb_off rec_ptr;
-	
+	int maxloop;
+
 	/* read in the hash top */
 	if (ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1)
 		return 0;
 
 	/* keep looking until we find the right record */
+	maxloop = 100000;
 	while (rec_ptr) {
 		if (rec_read(tdb, rec_ptr, r) == -1)
 			return 0;
@@ -1005,6 +1023,12 @@ static tdb_off tdb_find(TDB_CONTEXT *tdb
 			SAFE_FREE(k);
 		}
 		rec_ptr = r->next;
+
+		maxloop--;
+		if (maxloop == 0) {
+			TDB_LOG((tdb, 0, "tdb_find maxloop reached; corrupt database!\n"));
+			return TDB_ERRCODE(TDB_ERR_CORRUPT, 0);
+		}
 	}
 	return TDB_ERRCODE(TDB_ERR_NOEXIST, 0);
 }
@@ -1187,6 +1211,7 @@ static int do_delete(TDB_CONTEXT *tdb, t
 {
 	tdb_off last_ptr, i;
 	struct list_struct lastrec;
+	int maxloop;
 
 	if (tdb->read_only) return -1;
 
@@ -1201,9 +1226,18 @@ static int do_delete(TDB_CONTEXT *tdb, t
 	/* find previous record in hash chain */
 	if (ofs_read(tdb, TDB_HASH_TOP(rec->full_hash), &i) == -1)
 		return -1;
-	for (last_ptr = 0; i != rec_ptr; last_ptr = i, i = lastrec.next)
+
+	maxloop = 100000;
+	for (last_ptr = 0; i != rec_ptr; last_ptr = i, i = lastrec.next) {
 		if (rec_read(tdb, i, &lastrec) == -1)
 			return -1;
+
+		maxloop--;
+		if (maxloop == 0) {
+			TDB_LOG((tdb, 0, "(tdb)do_delete: maxloop reached; corrupt database!\n"));
+			return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
+		}
+	}
 
 	/* unlink it: next ptr is at start of record. */
 	if (last_ptr == 0)
#20 lore raw
In reply to Frank Steiner

Kay Sievers wrote

Quoted 3 lines

All here known failure paths are now covered in the attached patch by limiting the iteration count for loops over data read from disk. Let's see what happens next :)

Ok :-) I'm running this patch in parallel on hosts using tmpfs for /dev as well as "old" ones still using NFS. I will report success or failures!

cu,
Frank

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
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
#21 lore raw
In reply to Frank Steiner
Quoted 8 lines · Frank Steiner

Kay Sievers wrote

Quoted 3 lines

All here known failure paths are now covered in the attached patch by limiting the iteration count for loops over data read from disk. Let's see what happens next :)

Ok :-) I'm running this patch in parallel on hosts using tmpfs for /dev as well as "old" ones still using NFS. I will report success or failures!

Nice, thanks for taking the time to investigate this. I hope we catch all these failures now.

Here is the debug from the corrupt tdb-file you sent me. As expected, the concurrent writing from multiple processes on a filesystem without proper locking created an endless loop. Here is the debug with a loop over three records:
696 -> 16384 -> 18200 ==> 696 -> 16384 -> 18200 ==> ...

[kay@pim ~]$ ./dumpit /home/kay/udev.tdb
hash
rec: offseti6 next384 rec_lenˆ4 key_len$ data_len…6 full_hash=0x13792fac magic=0x26011999
rec: offset384 next200 rec_lenˆ4 key_len$ data_len…6 full_hash=0x13792fac magic=0xd9fee666
rec: offset200 nexti6 rec_lenˆ4 key_len$ data_len…6 full_hash=0xa713efac magic=0x26011999
rec: offseti6 next384 rec_lenˆ4 key_len$ data_len…6 full_hash=0x13792fac magic=0x26011999
rec: offset384 next200 rec_lenˆ4 key_len$ data_len…6 full_hash=0x13792fac magic=0xd9fee666
rec: offset200 nexti6 rec_lenˆ4 key_len$ data_len…6 full_hash=0xa713efac magic=0x26011999
rec: offseti6 next384 rec_lenˆ4 key_len$ data_len…6 full_hash=0x13792fac magic=0x26011999
rec: offset384 next200 rec_lenˆ4 key_len$ data_len…6 full_hash=0x13792fac magic=0xd9fee666
rec: offset200 nexti6 rec_lenˆ4 key_len$ data_len…6 full_hash=0xa713efac magic=0x26011999
rec: offseti6 next384 rec_lenˆ4 key_len$ data_len…6 full_hash=0x13792fac magic=0x26011999
rec: offset384 next200 rec_lenˆ4 key_len$ data_len…6 full_hash=0x13792fac magic=0xd9fee666
rec: offset200 nexti6 rec_lenˆ4 key_len$ data_len…6 full_hash=0xa713efac magic=0x26011999
rec: offseti6 next384 rec_lenˆ4 key_len$ data_len…6 full_hash=0x13792fac magic=0x26011999
...

Thanks,
Kay

-------------------------------------------------------
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

#22 lore raw
In reply to Frank Steiner

Frank Steiner wrote

Quoted 10 lines

Kay Sievers wrote

Quoted 3 lines

All here known failure paths are now covered in the attached patch by limiting the iteration count for loops over data read from disk. Let's see what happens next :)

Ok :-) I'm running this patch in parallel on hosts using tmpfs for /dev as well as "old" ones still using NFS. I will report success or failures!

Well, we are not done yet :-) Another udev hanging with 100% CPU, with the latest deadlock patch applied. Here's the trace (I removed the "(gdb) s" lines):

knuth /root# gdb -p 3480
GNU gdb 5.3.92
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i586-suse-linux".
Attaching to process 3480
Reading symbols from /sbin/udev...done.
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
0x4010db79 in chown@@GLIBC_2.1 () from /lib/i686/libc.so.6
(gdb) bt
#0 0x4010db79 in chown@@GLIBC_2.1 () from /lib/i686/libc.so.6
#1 0x0804be05 in secure_unlink (filename=0xbffff360 "/dev/sg2173337579")

    at udev-remove.c:78
#2  0x0804c018 in delete_node (dev=0xbffff690) at udev-remove.c:127
#3  0x0804c2c5 in udev_remove_device (path=0xbfffff70 "/class/scsi_generic/sg2",
    subsystem=0xbfffff3b "scsi_generic") at udev-remove.c:185

#4 0x080497f1 in main (argc=2, argv=0xbffffd60, envp=0xfffffe00) at udev.c:188 (gdb) s
Single stepping until exit from function chown@@GLIBC_2.1,
which has no line number information.
secure_unlink (filename=0xbffff360 "/dev/sg2173337579") at udev-remove.c:79
79 udev-remove.c: No such file or directory.
in udev-remove.c
81 in udev-remove.c
log_message (level=7, format=0x805a060 "%s: chown(%s, 0, 0) failed with error '%s'")

    at udev.c:52
52      udev.c: No such file or directory.
        in udev.c
55      in udev.c
56      in udev.c
58      in udev.c

secure_unlink (filename=0xbffff360 "/dev/sg2173337579") at udev-remove.c:87
87 udev-remove.c: No such file or directory.
in udev-remove.c
88 in udev-remove.c
90 in udev-remove.c
log_message (level=7, format=0x805a0a0 "%s: chmod(%s, 0000) failed with error '%s'")

    at udev.c:52

52 udev.c: No such file or directory.
in udev.c
55 in udev.c
56 in udev.c
...
and so on. The device in question does not exist (at least not after I exited tdb):
knuth /root# ls -la /dev/sg2173337579
ls: /dev/sg2173337579: No such file or directory

Just in case I also attached the .udev.tdb from this state if it helps. I'll leave the host in this state until you say you don't need more info from it :-)

All the hosts running tmpfs have not reported any errors yet!

cu,
Frank

Signature · 5 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *
#23 lore raw
In reply to Frank Steiner
Quoted 10 lines · Frank Steiner

Frank Steiner wrote

Quoted 8 lines

Kay Sievers wrote

Quoted 3 lines

All here known failure paths are now covered in the attached patch by limiting the iteration count for loops over data read from disk. Let's see what happens next :)

Quoted 6 lines
Quoted 2 lines

Ok :-) I'm running this patch in parallel on hosts using tmpfs for /dev as well as "old" ones still using NFS. I will report success or failures!

Well, we are not done yet :-) Another udev hanging with 100% CPU, with the latest deadlock patch applied. Here's the trace (I removed the "(gdb) s" lines):

Funny, this is not inside the tdb, it's caused by getting garbage from the udev database.

You don't use {all_partitions}, right?

I expect, that the payload-data from the tdb is corrupt and the record claims, that the udev_add has added > 2.000.000 partition-nodes for the device :) You should have something like this in the syslog:
"removing partitions 'sg2[1-24532432]'"

Here is a patch for it. It's against the current tree after our patch session yesterday. But it should successfully apply to your tree with offsets.

Thanks,
Kay

===== namedev.c 1.147 vs edited =====

namedev.c +8 -14
@@ -29,7 +29,6 @@
 #include <ctype.h>
 #include <unistd.h>
 #include <errno.h>
-#include <time.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/sysinfo.h>
@@ -353,7 +352,6 @@ static struct bus_file {
 	{}
 };
 
-#define SECONDS_TO_WAIT_FOR_FILE	10
 static void wait_for_device_to_initialize(struct sysfs_device *sysfs_device)
 {
 	/* sleep until we see the file for this specific bus type show up this
@@ -367,14 +365,14 @@ static void wait_for_device_to_initializ
 	struct bus_file *b = &bus_files[0];
 	struct sysfs_attribute *tmpattr;
 	int found = 0;
-	int loop = SECONDS_TO_WAIT_FOR_FILE;
+	int loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 
 	while (1) {
 		if (b->bus == NULL) {
 			if (!found)
 				break;
-			/* sleep to give the kernel a chance to create the file */
-			sleep(1);
+			/* give the kernel a chance to create the file */
+			usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 			--loop;
 			if (loop == 0)
 				break;
@@ -394,7 +392,8 @@ static void wait_for_device_to_initializ
 	}
 	if (!found)
 		dbg("did not find bus type '%s' on list of bus_id_files, "
-		    "contact [email protected]", sysfs_device->bus);
+		    "please report to <[email protected]>",
+		    sysfs_device->bus);
 exit:
 	return; /* here to prevent compiler warning... */
 }
@@ -680,7 +679,6 @@ static struct sysfs_device *get_sysfs_de
 {
 	struct sysfs_device *sysfs_device;
 	struct sysfs_class_device *class_dev_parent;
-	struct timespec tspec;
 	int loop;
 
 	/* Figure out where the device symlink is at.  For char devices this will
@@ -696,16 +694,14 @@ static struct sysfs_device *get_sysfs_de
 	if (class_dev_parent != NULL) 
 		dbg("given class device has a parent, use this instead");
 
-	tspec.tv_sec = 0;
-	tspec.tv_nsec = 10000000;  /* sleep 10 millisec */
-	loop = 10;
+	loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 	while (loop--) {
 		if (udev_sleep) {
 			if (whitelist_search(class_dev)) {
 				sysfs_device = NULL;
 				goto exit;
 			}
-			nanosleep(&tspec, NULL);
+			usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 		}
 
 		if (class_dev_parent)
@@ -727,11 +723,9 @@ device_found:
 		if (sysfs_device->bus[0] != '\0')
 			goto bus_found;
 
-		loop = 10;
-		tspec.tv_nsec = 10000000;
 		while (loop--) {
 			if (udev_sleep)
-				nanosleep(&tspec, NULL);
+				usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 			sysfs_get_device_bus(sysfs_device);
 			
 			if (sysfs_device->bus[0] != '\0')

===== udev-add.c 1.74 vs edited =====

udev-add.c +2 -3
@@ -348,11 +348,10 @@ exit:
 /* wait for the "dev" file to show up in the directory in sysfs.
  * If it doesn't happen in about 10 seconds, give up.
  */
-#define SECONDS_TO_WAIT_FOR_FILE	10
 static int sleep_for_file(const char *path, char* file)
 {
 	char filename[SYSFS_PATH_MAX + 6];
-	int loop = SECONDS_TO_WAIT_FOR_FILE;
+	int loop = WAIT_FOR_FILE_SECONDS * WAIT_FOR_FILE_RETRY_FREQ;
 	int retval;
 
 	strfieldcpy(filename, sysfs_path);
@@ -368,7 +367,7 @@ static int sleep_for_file(const char *pa
 			goto exit;
 
 		/* sleep to give the kernel a chance to create the dev file */
-		sleep(1);
+		usleep(1000 * 1000 / WAIT_FOR_FILE_RETRY_FREQ);
 	}
 	retval = -ENODEV;
 exit:

===== udev-remove.c 1.33 vs edited =====

udev-remove.c +10 -4
@@ -109,6 +109,7 @@ static int delete_node(struct udevice *d
 	int i;
 	char *pos;
 	int len;
+	int num;
 
 	strfieldcpy(filename, udev_root);
 	strfieldcat(filename, dev->name);
@@ -118,10 +119,15 @@ static int delete_node(struct udevice *d
 	if (retval)
 		return retval;
 
-	/* remove partition nodes */
-	if (dev->partitions > 0) {
-		info("removing partitions '%s[1-%i]'", filename, dev->partitions);
-		for (i = 1; i <= dev->partitions; i++) {
+	/* remove all_partitions nodes */
+	num = dev->partitions;
+	if (num > 0) {
+		info("removing all_partitions '%s[1-%i]'", filename, num);
+		if (num > PARTITIONS_COUNT) {
+			info("garbage from udev database, skip all_partitions removal");
+			return -1;
+		}
+		for (i = 1; i <= num; i++) {
 			strfieldcpy(partitionname, filename);
 			strintcat(partitionname, i);
 			secure_unlink(partitionname);

===== udev.c 1.62 vs edited =====

udev.c +19 -5
@@ -36,6 +36,9 @@
 #include "namedev.h"
 #include "udevdb.h"
 
+/* timeout flag for udevdb */
+extern sig_atomic_t gotalarm;
+
 /* global variables */
 char **main_argv;
 char **main_envp;
@@ -58,6 +61,11 @@ void log_message(int level, const char *
 asmlinkage static void sig_handler(int signum)
 {
 	switch (signum) {
+		case SIGALRM:
+			gotalarm = 1;
+			info("error: timeout reached, event probably not handled correctly, "
+			     "please report to <[email protected]> ");
+			break;
 		case SIGINT:
 		case SIGTERM:
 			udevdb_exit();
@@ -94,7 +102,8 @@ int main(int argc, char *argv[], char *e
 
 	dbg("version %s", UDEV_VERSION);
 
-	/* initialize our configuration */
+	init_logging("udev");
+
 	udev_init_config();
 
 	if (strstr(argv[0], "udevstart")) {
@@ -147,15 +156,20 @@ int main(int argc, char *argv[], char *e
 	/* set signal handlers */
 	act.sa_handler = sig_handler;
 	sigemptyset (&act.sa_mask);
+
+	/* alarm should interrupt */
+	sigaction(SIGALRM, &act, NULL);
+
 	act.sa_flags = SA_RESTART;
 	sigaction(SIGINT, &act, NULL);
 	sigaction(SIGTERM, &act, NULL);
 
+	/* trigger timout to interrupt blocking syscalls */
+	alarm(ALARM_TIMEOUT);
+
 	/* initialize udev database */
-	if (udevdb_init(UDEVDB_DEFAULT) != 0) {
-		dbg("unable to initialize database");
-		goto exit;
-	}
+	if (udevdb_init(UDEVDB_DEFAULT) != 0)
+		info("error: unable to initialize database, continuing without database");
 
 	switch(act_type) {
 	case UDEVSTART:

===== udev.h 1.62 vs edited =====

udev.h +3 -0
@@ -26,6 +26,9 @@
 #include <sys/param.h>
 #include "libsysfs/sysfs/libsysfs.h"
 
+#define ALARM_TIMEOUT			20
+#define WAIT_FOR_FILE_SECONDS		10
+#define WAIT_FOR_FILE_RETRY_FREQ	10
 #define COMMENT_CHARACTER		'#'
 
 #define NAME_SIZE			256

===== udevdb.c 1.30 vs edited =====

udevdb.c +28 -2
@@ -42,13 +42,28 @@
 #include "tdb/tdb.h"
 
 static TDB_CONTEXT *udevdb;
+sig_atomic_t gotalarm;
 
+static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...)
+{
+	va_list args;
+
+	if (!udev_log)
+		return;
+
+	va_start(args, format);
+	vsyslog(level, format, args);
+	va_end(args);
+}
 
 int udevdb_add_dev(const char *path, const struct udevice *dev)
 {
 	TDB_DATA key, data;
 	char keystr[SYSFS_PATH_MAX];
 
+	if (udevdb == NULL)
+		return -1;
+
 	if ((path == NULL) || (dev == NULL))
 		return -ENODEV;
 
@@ -68,6 +83,9 @@ int udevdb_get_dev(const char *path, str
 {
 	TDB_DATA key, data;
 
+	if (udevdb == NULL)
+		return -1;
+
 	if (path == NULL)
 		return -ENODEV;
 
@@ -88,6 +106,9 @@ int udevdb_delete_dev(const char *path)
 	TDB_DATA key;
 	char keystr[SYSFS_PATH_MAX];
 
+	if (udevdb == NULL)
+		return -1;
+
 	if (path == NULL)
 		return -EINVAL;
 
@@ -121,7 +142,9 @@ int udevdb_init(int init_flag)
 	if (init_flag != UDEVDB_DEFAULT && init_flag != UDEVDB_INTERNAL)
 		return -EINVAL;
 
-	udevdb = tdb_open(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644);
+	tdb_set_lock_alarm(&gotalarm);
+
+	udevdb = tdb_open_ex(udev_db_filename, 0, init_flag, O_RDWR | O_CREAT, 0644, tdb_log);
 	if (udevdb == NULL) {
 		if (init_flag == UDEVDB_INTERNAL)
 			dbg("unable to initialize in-memory database");
@@ -137,7 +160,7 @@ int udevdb_init(int init_flag)
  */
 int udevdb_open_ro(void)
 {
-	udevdb = tdb_open(udev_db_filename, 0, 0, O_RDONLY, 0);
+	udevdb = tdb_open_ex(udev_db_filename, 0, 0, O_RDONLY, 0, tdb_log);
 	if (udevdb == NULL) {
 		dbg("unable to open database at '%s'", udev_db_filename);
 		return -EACCES;
@@ -159,6 +182,9 @@ static int traverse_callback(TDB_CONTEXT
 int udevdb_call_foreach(int (*user_record_handler) (char *path, struct udevice *dev))
 {
 	int retval = 0;
+
+	if (udevdb == NULL)
+		return -1;
 
 	if (user_record_handler == NULL) {
 		dbg("invalid user record handling function");

===== tdb/tdb.c 1.4 vs edited =====

tdb/tdb.c +36 -2
@@ -617,8 +617,10 @@ int tdb_printfreelist(TDB_CONTEXT *tdb)
 static int remove_from_freelist(TDB_CONTEXT *tdb, tdb_off off, tdb_off next)
 {
 	tdb_off last_ptr, i;
+	int maxloop;
 
 	/* read in the freelist top */
+	maxloop = 100000;
 	last_ptr = FREELIST_TOP;
 	while (ofs_read(tdb, last_ptr, &i) != -1 && i != 0) {
 		if (i == off) {
@@ -627,6 +629,12 @@ static int remove_from_freelist(TDB_CONT
 		}
 		/* Follow chain (next offset is at start of record) */
 		last_ptr = i;
+
+		maxloop--;
+		if (maxloop == 0) {
+			TDB_LOG((tdb, 0, "remove_from_freelist: maxloop reached; corrupt database!\n"));
+			return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
+		}
 	}
 	TDB_LOG((tdb, 0,"remove_from_freelist: not on list at off=%d\n", off));
 	return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
@@ -853,6 +861,7 @@ static tdb_off tdb_allocate(TDB_CONTEXT 
 {
 	tdb_off rec_ptr, last_ptr, newrec_ptr;
 	struct list_struct newrec;
+	int maxloop;
 
 	if (tdb_lock(tdb, -1, F_WRLCK) == -1)
 		return 0;
@@ -868,6 +877,7 @@ static tdb_off tdb_allocate(TDB_CONTEXT 
 		goto fail;
 
 	/* keep looking until we find a freelist record big enough */
+	maxloop = 100000;
 	while (rec_ptr) {
 		if (rec_free_read(tdb, rec_ptr, rec) == -1)
 			goto fail;
@@ -919,6 +929,12 @@ static tdb_off tdb_allocate(TDB_CONTEXT 
 		/* move to the next record */
 		last_ptr = rec_ptr;
 		rec_ptr = rec->next;
+
+		maxloop--;
+		if (maxloop == 0) {
+			TDB_LOG((tdb, 0, "tdb_allocate: maxloop reached; corrupt database!\n"));
+			return TDB_ERRCODE(TDB_ERR_CORRUPT, 0);
+		}
 	}
 	/* we didn't find enough space. See if we can expand the
 	   database and if we can then try again */
@@ -981,12 +997,14 @@ static tdb_off tdb_find(TDB_CONTEXT *tdb
 			struct list_struct *r)
 {
 	tdb_off rec_ptr;
-	
+	int maxloop;
+
 	/* read in the hash top */
 	if (ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1)
 		return 0;
 
 	/* keep looking until we find the right record */
+	maxloop = 100000;
 	while (rec_ptr) {
 		if (rec_read(tdb, rec_ptr, r) == -1)
 			return 0;
@@ -1006,6 +1024,12 @@ static tdb_off tdb_find(TDB_CONTEXT *tdb
 			SAFE_FREE(k);
 		}
 		rec_ptr = r->next;
+
+		maxloop--;
+		if (maxloop == 0) {
+			TDB_LOG((tdb, 0, "tdb_find maxloop reached; corrupt database!\n"));
+			return TDB_ERRCODE(TDB_ERR_CORRUPT, 0);
+		}
 	}
 	return TDB_ERRCODE(TDB_ERR_NOEXIST, 0);
 }
@@ -1188,6 +1212,7 @@ static int do_delete(TDB_CONTEXT *tdb, t
 {
 	tdb_off last_ptr, i;
 	struct list_struct lastrec;
+	int maxloop;
 
 	if (tdb->read_only) return -1;
 
@@ -1202,9 +1227,18 @@ static int do_delete(TDB_CONTEXT *tdb, t
 	/* find previous record in hash chain */
 	if (ofs_read(tdb, TDB_HASH_TOP(rec->full_hash), &i) == -1)
 		return -1;
-	for (last_ptr = 0; i != rec_ptr; last_ptr = i, i = lastrec.next)
+
+	maxloop = 100000;
+	for (last_ptr = 0; i != rec_ptr; last_ptr = i, i = lastrec.next) {
 		if (rec_read(tdb, i, &lastrec) == -1)
 			return -1;
+
+		maxloop--;
+		if (maxloop == 0) {
+			TDB_LOG((tdb, 0, "(tdb)do_delete: maxloop reached; corrupt database!\n"));
+			return TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
+		}
+	}
 
 	/* unlink it: next ptr is at start of record. */
 	if (last_ptr == 0)
#24 lore raw
In reply to Frank Steiner

Kay Sievers wrote

Quoted 5 lines

Funny, this is not inside the tdb, it's caused by getting garbage from the udev database.

You don't use {all_partitions}, right?

No. I just took over SuSE udev.rules, and they don't use it, but everything without card readers etc. always worked find, so never looked into this.

Quoted 5 lines

I expect, that the payload-data from the tdb is corrupt and the record claims, that the udev_add has added > 2.000.000 partition-nodes for the device :) You should have something like this in the syslog:
"removing partitions 'sg2[1-24532432]'"

No, but there are ssyslog messages missing for about 9 hours. Sth. very weird must have happened to this host tonight :-)

Quoted 3 lines

Here is a patch for it. It's against the current tree after our patch session yesterday. But it should successfully apply to your tree with offsets.

Thanks, let's for the next run :-)

cu,
Frank

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
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
#25 lore raw
In reply to Frank Steiner

Hi Kay,

with version 04 of your deadlock patch, the three hosts which still use /dev over nfs have now been rebooting in a loop (rebooting every 5 minutes with extra, parallel udevstart calls) for two days without any lockups. The same rebooting mechanism reliably locked them up in all the former tests, so I guess that all possible deadlocks (at least those caused by non-locking NFS) are fixed! I see all the warnings in the logs, so I can tell that the deadlock situations happen a few times a day, but patch unbreaks them all. So I guess you can make it final.

The hosts running tmps didn't have any problems at all, with or without the patch.

Just a minor problem: With the deadlock patch I can't compile udev with "USE_LOGúlse DEBUGúlse". I fixed that by putting an #ifdef around, i.e.,

+static void tdb_log(TDB_CONTEXT *tdb, int level, const char *format, ...) +{
+ va_list args;
+
+ if (!udev_log)
+ return;
+
+#ifdef LOG
+ va_start(args, format);
+ vsyslog(level, format, args);
+ va_end(args);
+#endif
+}

Not sure if that makes any sense except making it compile, but you will know better :-)

Thanks again for all your help and consistent patching :-) cu,
Frank

Signature · 16 lines
Dipl.-Inform. Frank Steiner   Web:  http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik    Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17           Phone: +49 89 2180-4049
80333 Muenchen, Germany       Fax:   +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *


-------------------------------------------------------
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