2003-11-13 16:35:54

by Remco van Mook

[permalink] [raw]
Subject: 2.4 odd behaviour of ramdisk + cramfs


I am experiencing a problem when I try to run the following script:

#! /bin/sh
cat /flash/modules-2.4.21 > /dev/ram1
mount -t cramfs -o ro /dev/ram1 /lib/modules

Running it once causes the mount to fail with 'cramfs: wrong magic' -
running it twice will make mount succeed on the second try.

Oddly enough, repeating the 2 lines within the script doesn't work either.

The behaviour has been reproduced by several people with different 2.4
kernels.

As I need this to go into some boot scripts, I'd like this to work without
human intervention.

Any suggestions ?

Remco van Mook

Typical kernel config:
2.4.21 unpatched kernel tree
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=4096
CONFIG_BLK_DEV_INITRD=y
CONFIG_CRAMFS=y
CONFIG_TMPFS=y
CONFIG_RAMFS=y


2003-11-13 16:45:50

by bert hubert

[permalink] [raw]
Subject: buffer/page cache aliasing? Re: 2.4 odd behaviour of ramdisk + cramfs

On Thu, Nov 13, 2003 at 05:32:49PM +0100, Remco van Mook wrote:

> #! /bin/sh
> cat /flash/modules-2.4.21 > /dev/ram1
> mount -t cramfs -o ro /dev/ram1 /lib/modules
>
> Running it once causes the mount to fail with 'cramfs: wrong magic' -
> running it twice will make mount succeed on the second try.

Sounds like buffer/page cache aliasing perhaps? Does it work with other
filesystems?

--
http://www.PowerDNS.com Open source, database driven DNS Software
http://lartc.org Linux Advanced Routing & Traffic Control HOWTO

2003-11-13 17:03:06

by Remco van Mook

[permalink] [raw]
Subject: Re: buffer/page cache aliasing? Re: 2.4 odd behaviour of ramdisk + cramfs

At 17:45 13-11-2003 +0100, bert hubert wrote:
>On Thu, Nov 13, 2003 at 05:32:49PM +0100, Remco van Mook wrote:
>
> > #! /bin/sh
> > cat /flash/modules-2.4.21 > /dev/ram1
> > mount -t cramfs -o ro /dev/ram1 /lib/modules
> >
> > Running it once causes the mount to fail with 'cramfs: wrong magic' -
> > running it twice will make mount succeed on the second try.
>
>Sounds like buffer/page cache aliasing perhaps? Does it work with other
>filesystems?

I've just checked it with an ext2 filesystem - exactly the same thing happens.

Now, what's more interesting is that if I try again with a bigger filesystem
(3MB instead of 750KB) the problem only appears every now and again.

So it's probably got nothing to do with cramfs in particular, but more with the
size of the filesystem.

Remco

2003-11-13 16:59:56

by Meelis Roos

[permalink] [raw]
Subject: Re: 2.4 odd behaviour of ramdisk + cramfs

RvM> Running it once causes the mount to fail with 'cramfs: wrong magic' -

Debian kernel has a patch to help cramfs initrd's work. The symptoms
wothout the patch are very similar. This is the patch, extracted from
Debian kernel-source package:

diff -urN linux-2.4.22.orig/fs/block_dev.c linux-2.4.22/fs/block_dev.c
--- linux-2.4.22.orig/fs/block_dev.c 2003-06-01 13:06:32.000000000 +1000
+++ linux-2.4.22/fs/block_dev.c 2003-06-01 20:43:53.000000000 +1000
@@ -95,7 +95,7 @@
sync_buffers(dev, 2);
blksize_size[MAJOR(dev)][MINOR(dev)] = size;
bdev->bd_inode->i_blkbits = blksize_bits(size);
- kill_bdev(bdev);
+ invalidate_bdev(bdev, 1);
bdput(bdev);
return 0;
}

--
Meelis Roos ([email protected])

2003-11-13 17:17:46

by Remco van Mook

[permalink] [raw]
Subject: Re: 2.4 odd behaviour of ramdisk + cramfs


Hello Meelis,

thank you ! This patch works for me.

Does it have any side effects or might I suggest that this one is merged
into the mainstream kernel ?

Cheers,

Remco van Mook

At 18:59 13-11-2003 +0200, Meelis Roos wrote:
>RvM> Running it once causes the mount to fail with 'cramfs: wrong magic' -
>
>Debian kernel has a patch to help cramfs initrd's work. The symptoms
>wothout the patch are very similar. This is the patch, extracted from
>Debian kernel-source package:
>
>diff -urN linux-2.4.22.orig/fs/block_dev.c linux-2.4.22/fs/block_dev.c
>--- linux-2.4.22.orig/fs/block_dev.c 2003-06-01 13:06:32.000000000 +1000
>+++ linux-2.4.22/fs/block_dev.c 2003-06-01 20:43:53.000000000 +1000
>@@ -95,7 +95,7 @@
> sync_buffers(dev, 2);
> blksize_size[MAJOR(dev)][MINOR(dev)] = size;
> bdev->bd_inode->i_blkbits = blksize_bits(size);
>- kill_bdev(bdev);
>+ invalidate_bdev(bdev, 1);
> bdput(bdev);
> return 0;
> }
>
>--
>Meelis Roos ([email protected])
>-
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to [email protected]
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.tux.org/lkml/

2003-11-13 17:41:53

by Meelis Roos

[permalink] [raw]
Subject: Re: 2.4 odd behaviour of ramdisk + cramfs

> Does it have any side effects or might I suggest that this one is merged
> into the mainstream kernel ?

None that I know. It is included in Debian unstable packaged 2.4 kernels
for all archs. I use it successfully on x86 with custom kernel.

--
Meelis Roos ([email protected])