All of lore.kernel.org
 help / color / mirror / Atom feed
* Fwd: blkid descends into /dev/.udev/... and stucks.
@ 2006-01-26 15:17 Hai Zaar
  2006-01-26 15:31 ` Kay Sievers
  2006-01-26 16:10 ` Hai Zaar
  0 siblings, 2 replies; 3+ messages in thread
From: Hai Zaar @ 2006-01-26 15:17 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1195 bytes --]

Hi, guys!

Message below is directly related to hotplug, but I've encountered the
described problem while playing with 2.6.15 + new udev - and it took
me decent amount of hours to find the problem.

Take care...

---------- Forwarded message ----------
From: Hai Zaar <haizaar@gmail.com>
Date: Jan 26, 2006 5:09 PM
Subject: blkid descends into /dev/.udev/... and stucks.
To: tytso@thunk.org


Hi!

I've encountered blkid being stuck on the following scenario:
I use 2.6.15 with udev to manage device nodes.
Suppose I load storage module (say ata_piix + sd_mod), then after some
time (say A), /proc/paritions is updated. After a bit more time (say
A+B), udev will create corresponding device nodes. Now the problem:
If you run blkid between time A and time B, it will scan /dev
recursivly trying to find device node with appripriate major/minor to
match /proc/partitions entry. The problem is that there is
/dev/.udev/failed dir, that contains links to /sys, and from where one
may easily go to infinite loop - and that is what blkid does.

The attached patch just makes blkid to skip /dev/.udev* when doing the
search for device node.

--
Zaar




--
Zaar

[-- Attachment #2: e2fsprogs-1.38-blkid-skip.udev-1.patch --]
[-- Type: text/x-patch, Size: 1136 bytes --]

When blkid searchs for devices that match /proc/partitions entries, it should NOT decend
into /dev/.udev/ directory. That directory may contain various symbolic links that may
cause blkid to loop forever. 
Typical scenario: You load modules and /proc/partitions is populated, but udev have not
created devices yet. If you run blkid at this point, it will start more thoughout search
looking for devices that match /proc/partitions etries. During the search it will scan all
of the /dev directory, including /dev/.udev* = inifinite loop. 
That patch prevents descending into /dev/.udev*

Author:	Hai Zaar <haizaar@gmail.com>

--- e2fsprogs-1.38/lib/blkid/devno.c.orig	2006-01-25 14:53:29.000000000 +0200
+++ e2fsprogs-1.38/lib/blkid/devno.c	2006-01-25 14:54:27.000000000 +0200
@@ -113,7 +113,8 @@
 
 		if (dp->d_name[0] == '.' &&
 		    ((dp->d_name[1] == 0) ||
-		     ((dp->d_name[1] == '.') && (dp->d_name[2] == 0))))
+		     ((dp->d_name[1] == '.') && (dp->d_name[2] == 0)) ||
+			 (strncmp(dp->d_name+1, "udev", 4) == 0)   )) /* never descend to .udev* entries! */
 			continue;
 
 		sprintf(path, "%s/%s", dirname, dp->d_name);




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

* Re: Fwd: blkid descends into /dev/.udev/... and stucks.
  2006-01-26 15:17 Fwd: blkid descends into /dev/.udev/... and stucks Hai Zaar
@ 2006-01-26 15:31 ` Kay Sievers
  2006-01-26 16:10 ` Hai Zaar
  1 sibling, 0 replies; 3+ messages in thread
From: Kay Sievers @ 2006-01-26 15:31 UTC (permalink / raw)
  To: linux-hotplug

On Thu, Jan 26, 2006 at 05:17:07PM +0200, Hai Zaar wrote:
> Message below is directly related to hotplug, but I've encountered the
> described problem while playing with 2.6.15 + new udev - and it took
> me decent amount of hours to find the problem.

Scanning /dev is evil and blkid is usually not used in udev context, cause
udev supplies the vol_id program. (On SUSE we even patch mount(8) to link
against the udev provided libvolume_id instead of libblkid.)

Use vol_id, it fits better on a udev system. Note, you may not need anything
custom here, if you use the persistent symlinks in /dev/disk, which almost
all distros have these days.

And please send the blkid patch to the e2fsprogs maintainer, as it would be good
to have this fixed soon. But I think it's better to ignore _any_ dot file in /dev
instead of the udev directory only.

Thanks,
Kay


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x103432&bid#0486&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: Fwd: blkid descends into /dev/.udev/... and stucks.
  2006-01-26 15:17 Fwd: blkid descends into /dev/.udev/... and stucks Hai Zaar
  2006-01-26 15:31 ` Kay Sievers
@ 2006-01-26 16:10 ` Hai Zaar
  1 sibling, 0 replies; 3+ messages in thread
From: Hai Zaar @ 2006-01-26 16:10 UTC (permalink / raw)
  To: linux-hotplug

<skipped>
> Use vol_id, it fits better on a udev system. Note, you may not need anything
> custom here, if you use the persistent symlinks in /dev/disk, which almost
> all distros have these days.
Thanks for the hint! Actually what I can do in initramfs is just:
-----------------------------
trigger_all_events
# now lets find device by uuid. UUID value is hardcoded to /init by my
mkinitramfs script.
timeout0
while ((timeout > 0); do
    if [[ -e /dev/disk/by-uuid/$UUID ]];
        ROOTDEV=/dev/disk/by-uuid/$UUID
        break
    fi
    let timeout --
    sleep 1
done
if [[ "$ROOTDEV" != "" ]]; then
    mount $ROOTDEV  /newroot -o ro -t $(vol_id -t $ROOTDEV)
else
     exit
fi
-----------------------------
Another question:
Why halt command does not work in during initramfs?
How can I properly halt system at this stage?
For now I just use 'exit', but this is unpretty, since I get "kernel
panic - attempted to kill init"

> And please send the blkid patch to the e2fsprogs maintainer, as it would be good
> to have this fixed soon. But I think it's better to ignore _any_ dot file in /dev
> instead of the udev directory only.
Already there - actually I've posted a forward of the message I've sent to him.


P.S. Thank you guys for your great work! For me, udev and friends is
one of the most exciting features of 2.6.x

--
Zaar


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

end of thread, other threads:[~2006-01-26 16:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-26 15:17 Fwd: blkid descends into /dev/.udev/... and stucks Hai Zaar
2006-01-26 15:31 ` Kay Sievers
2006-01-26 16:10 ` Hai Zaar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.