Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 212031
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Gentoo Genkernel Maintainers <genkernel@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: Robin Johnson <robbat2@gentoo.org>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
busybox-1.1.3+gentoo-mdev-1.9.0.patch busybox-1.1.3+gentoo-mdev-1.9.0.patch patch Robin Johnson 2008-03-02 02:41 0000 541 bytes Details | Diff
busybox-1.1.3+gentoo-mdev-block.patch busybox-1.1.3+gentoo-mdev-block.patch patch Robin Johnson 2008-03-02 02:51 0000 557 bytes Details | Diff
busybox-21977-mdev-chrblk.patch Proposed patch using strstr function to check for block devices patch virdiq 2008-05-14 06:42 0000 709 bytes Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 212031 depends on: Show dependency tree
Bug 212031 blocks: 218127 245389
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)


Not eligible to see or edit group visibility for this bug.






View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2008-03-02 00:13 0000
In 2.6.25* (-rc3 presently), the sysfs nodes have changed somewhat. Due to how
mdev works, this means is miscreates device nodes as character devices instead
of block devices. Meaning mounting doesn't work ("block device required"), and
LVM ignores the devices.

Reviewing the busybox-1.1.3+gentoo, the problem with mdev appears to be the use
of strncmp on the sysfs path.
path = /sys/%s
type = strncmp(path+5, "block/", 6) ? S_IFCHR : S_IFBLK;

This expects the /sys/block/FOO to be a directory. However, in 2.6.25,
/dev/block/FOO is a symlink to another location.

Here's an example:
root@grubbs-int:~ # ls -la /sys/block/
total 0
drwxr-xr-x  2 root root 0 2008-03-01 16:06 .
drwxr-xr-x 11 root root 0 2008-03-01 15:59 ..
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-0 ->
../devices/virtual/block/dm-0
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-1 ->
../devices/virtual/block/dm-1
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-10 ->
../devices/virtual/block/dm-10
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-11 ->
../devices/virtual/block/dm-11
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-12 ->
../devices/virtual/block/dm-12
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-13 ->
../devices/virtual/block/dm-13
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-14 ->
../devices/virtual/block/dm-14
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-15 ->
../devices/virtual/block/dm-15
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-16 ->
../devices/virtual/block/dm-16
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-17 ->
../devices/virtual/block/dm-17
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-18 ->
../devices/virtual/block/dm-18
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-19 ->
../devices/virtual/block/dm-19
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-2 ->
../devices/virtual/block/dm-2
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-20 ->
../devices/virtual/block/dm-20
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-21 ->
../devices/virtual/block/dm-21
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-22 ->
../devices/virtual/block/dm-22
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-23 ->
../devices/virtual/block/dm-23
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-24 ->
../devices/virtual/block/dm-24
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-25 ->
../devices/virtual/block/dm-25
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-26 ->
../devices/virtual/block/dm-26
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-3 ->
../devices/virtual/block/dm-3
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-4 ->
../devices/virtual/block/dm-4
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-5 ->
../devices/virtual/block/dm-5
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-6 ->
../devices/virtual/block/dm-6
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-7 ->
../devices/virtual/block/dm-7
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-8 ->
../devices/virtual/block/dm-8
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 dm-9 ->
../devices/virtual/block/dm-9
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 md2 -> ../devices/virtual/block/md2
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sda ->
../devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.0/host0/target0:0:0/0:0:0:0/block/sda
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sdb ->
../devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.0/host0/target0:0:0/0:0:0:1/block/sdb
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sdc ->
../devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.0/host0/target0:0:0/0:0:0:2/block/sdc
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sdd ->
../devices/pci0000:00/0000:00:1d.7/usb2/2-5/2-5:1.0/host0/target0:0:0/0:0:0:3/block/sdd
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sde ->
../devices/pci0000:00/0000:00:1c.2/0000:03:00.0/host2/target2:0:0/2:0:0:0/block/sde
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sdf ->
../devices/pci0000:00/0000:00:1c.2/0000:03:00.0/host2/target2:1:0/2:1:0:0/block/sdf
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sdg ->
../devices/pci0000:00/0000:00:1c.2/0000:03:00.0/host2/target2:2:0/2:2:0:0/block/sdg
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sdh ->
../devices/pci0000:00/0000:00:1c.2/0000:03:00.0/host2/target2:3:0/2:3:0:0/block/sdh
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sdi ->
../devices/pci0000:00/0000:00:1c.2/0000:03:00.0/host2/target2:4:0/2:4:0:0/block/sdi
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sdj ->
../devices/pci0000:00/0000:00:1e.0/0000:06:01.0/host11/target11:0:0/11:0:0:0/block/sdj
lrwxrwxrwx  1 root root 0 2008-03-01 16:06 sr0 ->
../devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0/block/sr0

sdj is my boot media (3ware). I think if we convert the strncmp of "block/" to
a plain strcmp, it should work, without any false positives.

------- Comment #1 From Robin Johnson 2008-03-02 02:03:26 0000 -------
Ok, the trivial change of strncmp -> strcmp doesn't help it. I'm trying a few
other bits, incl moving the entire busybox forward to 1.9.0, or back-porting
the 1.9.0 mdev.

------- Comment #2 From Robin Johnson 2008-03-02 02:41:16 0000 -------
Created an attachment (id=145057) [details]
busybox-1.1.3+gentoo-mdev-1.9.0.patch

This patch is the clones the code used to set the devnode type from 1.9.0 to
the 1.1.3 branch. It relies on the fact that the char devnodes 'dev' under
/sys/class. This is NOT foolproof, as ttyXX and a lot of other devices are
under the /sys/device hierarchy instead of /sys/class or /sys/block.

It does work, but I don't trust it.

------- Comment #3 From Robin Johnson 2008-03-02 02:51:03 0000 -------
Created an attachment (id=145058) [details]
busybox-1.1.3+gentoo-mdev-block.patch

Here's another patch that I came up with, it uses the detection of the string
"block/" using strstr(path,"block/").

The trailing slash is important because there are some items in sysfs that have
block as part of the name. This seems to work better than the check from 1.9.0
for now, and while it's not fool-proof, I'd call it good enough to use.

------- Comment #4 From Chris Gianelloni (RETIRED) 2008-03-13 19:24:28 0000 -------
Is this bug still valid with the new busybox in genkernel?

------- Comment #5 From Robin Johnson 2008-03-13 20:14:18 0000 -------
this bug can go away with the new busybox (which is where I borrowed the code
for the first patch on here anyway). 

Just if we have crazy devices in the initramfs in the future, remember the
second patch maybe.

------- Comment #6 From Andrew Gaffney 2008-03-14 15:58:08 0000 -------
I guess this is INVALID now, since the busybox with the problem is no longer
used :P

------- Comment #7 From Chris Gianelloni (RETIRED) 2008-03-27 02:26:30 0000 -------
Actually, this was FIXED...

------- Comment #8 From Chris Gianelloni (RETIRED) 2008-03-27 02:27:01 0000 -------
We'll RESOLVED-FIXED it once 3.4.10 final is out.

------- Comment #9 From virdiq 2008-05-08 15:03:53 0000 -------
I've tried both busybox 1.10.1-r2 (which includes current patches from
upstream) and my own vanilla busybox 1.10.1 with all upstream patches applied
directly from http://busybox.net/downloads/fixes-1.10.1/

The kernel I'm testing against is vanilla-sources-2.6.25.2 (with the deprecated
sysfs structures switched off).

I'm using a static build of busybox in an initrd script with mdev being used
with kernel hotplug (and also being used manually with mdev -s).

It seems that mdev is still populating /dev with character devices regardless
of what type of device it should actually be.

Can anyone please confirm if busybox-1.10.1-r2 actually fixes this mdev bug
(from experience/testing)? Or is it just me that is still having problems?

Thanks

------- Comment #10 From virdiq 2008-05-14 06:42:11 0000 -------
Created an attachment (id=153091) [details]
Proposed patch using strstr function to check for block devices

Also suggested upstream via the mailing list (see
http://busybox.net/lists/busybox/2008-May/031408.html)

------- Comment #11 From Andrej Gelenberg 2008-05-14 08:23:06 0000 -------
i have reportet this bug alredy: https://bugs.gentoo.org/show_bug.cgi?id=220993

------- Comment #12 From Dennis Schridde 2008-06-17 20:34:04 0000 -------
1.10.1-r3 still has the same issue...

------- Comment #13 From Dennis Schridde 2008-06-17 20:52:40 0000 -------
But fixed in 1.10.3 (vanilla), see bug #226101.

------- Comment #14 From Chris Gianelloni (RETIRED) 2008-06-26 17:43:13 0000 -------
So this is *not* fixed using genkernel 3.4.9 or 3.4.10-r1 (without modifying
the busybox version used) correct?

------- Comment #15 From Daniel Drake 2008-06-29 21:41:06 0000 -------
Friendly reminder: we'll probably push for 2.6.25 stable in the next week or
so, so it would be great to see this fixed

------- Comment #16 From Andrew Gaffney 2008-06-30 04:43:25 0000 -------
If this is going to get fixed soon, someone will need to provide a patch
against mdev in busybox-1.7.4, since that's what we're currently using in
genkernel-3.4.10. We just went through an upgrade of busybox from 1.1.3 to
1.7.4, and I'm not doing that again any time soon.

------- Comment #17 From Andrew Gaffney 2008-07-29 12:05:04 0000 -------
(In reply to comment #10)
> Created an attachment (id=153091) [edit] [details]
> Proposed patch using strstr function to check for block devices

Will this patch work properly with mdev from 1.7.4 as well?

------- Comment #18 From virdiq 2008-07-30 13:59:49 0000 -------
This appears to have finally been fixed upstream in revision 22814.

See:
http://busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/util-linux/mdev.c?rev=22814&r1=22813&r2=22814&diff_format=h

I haven't tried this upstream version yet. However it essentially the same as
the patch I posted here a few months ago, with a change to the if/else branch
to allow better CPU branch prediction (I think).

The patch I submitted here for revision 21977 will not work with 1.7.4 because
the block/char determination at that time was:

        /* Determine device name, type, major and minor */

        device_name = bb_basename(path);
        type = path[5]=='c' ? S_IFCHR : S_IFBLK;

(see
http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/util-linux/mdev.c?rev=19676&view=markup
)

It should however be fairly easy to backport revision 22814 to use strstr to
determine the value of 'type', rather than the old school method of checking
the 5th character in the device path name.

------- Comment #19 From Chris Gianelloni 2008-11-03 12:49:15 0000 -------
This one looks oh-so-fun... We probably want to try to get this done for
3.4.11's release.  Could any of you help us with the 1.7.4 patches?  If not,
it'll likely take much longer to get done, since the genkernel team has very
limited manpower and developer time.

------- Comment #20 From Andrew Gaffney 2008-11-03 13:43:03 0000 -------
Was there a change in newer kernels that fixed this? I've built a CD based of
2.6.26 and 2.6.27 without problems.

------- Comment #21 From Andrew Gaffney 2008-11-15 07:07:01 0000 -------
I'm going to call this one fixed, because I haven't seen this one myself with
the newer busybox and 2.6.2[67] kernels.

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug