mtdblock mount issue
Hi,
I am trying to mount a cramfs partition from flash. I have the low level driver written and MTDBLOCK_RO module is enabled in MTD,
My mount fails with invalid argument error.
/mount: Mounting /dev/mtdblock on /home/crfs failed: Invalid argument/
I am using a 512 byte NAND flash 16byte spare.
I can find cramfs in /proc/filesytems and the mtdblock is under /proc/devices.
I had enabled a few debug statements in the mtdblock_ro and the low level nand driver code. I find that the mount is reading 32 pages after which it fails with invalid argument. Below is the log.
If you see the log below, the flow of code is
cramfs_read ==> do_blktrans_request ==> mtdblock_readsect ==> mt_read(my low level read function which returns success)
I even dumped the hex of the data being read by my low level driver module and found to match the cramfs image that I wrote to the flash.
######################*LOG*##########################
/home # mkdir crfs
/home # cat /proc/devices | grep mtdblock
31 mtdblock
/home # cat proc/filesystems | grep cramfs
cramfs
/home #
/home # mknod /dev/mtdblock b 31 0
/home # mount -t cramfs /dev/mtdblock /home/crfs
mount: /dev/mtdblock is write-protected, mounting read-only cramfs_readdo_blktrans_request nsect:8 block:0mtdblock_readsectmt_read offset:0mt_read status:0mtdblock_readsectmt_read offset:512mt_read status:0mtdblock_readsectmt_read offset:1024mt_read status:0mtdblock_readsectmt_read offset:1536mt_read status:0mtdblock_readsectmt_read offset:2048mt_read status:0mtdblock_readsectmt_read offset:2560mt_read status:0mtdblock_readsectmt_read offset:3072mt_read status:0mtdblock_readsectmt_read offset:3584mt_read status:0do_blktrans_request nsect:8 block:0mtdblock_readsectmt_read offset:4096mt_read status:0mtdblock_readsectmt_read offset:4608mt_read status:0mtdblock_readsectmt_read offset:5120mt_read status:0mtdblock_readsectmt_read offset:5632mt_read status:0mtdblock_readsectmt_read offset:6144mt_read status:0mtdblock_readsectmt_read offset:6656mt_read status:0mtdblock_readsectmt_read offset:7168mt_read status:0mtdblock_readsectmt_read offset:7680mt_read status:0do_blktrans_request nsect:8 block:0mtdblock_readsectmt_read offset:8192mt_read status:0mtdblock_readsectmt_read offset:8704mt_read status:0mtdblock_readsectmt_read offset:9216mt_read status:0mtdblock_readsectmt_read offset:9728mt_read status:0mtdblock_readsectmt_read offset:10240mt_read status:0mtdblock_readsectmt_read offset:10752mt_read status:0mtdblock_readsectmt_read offset:11264mt_read status:0mtdblock_readsectmt_read offset:11776mt_read status:0do_blktrans_request nsect:8 block:0mtdblock_readsectmt_read offset:12288mt_read status:0mtdblock_readsectmt_read offset:12800mt_read status:0mtdblock_readsectmt_read offset:13312mt_read status:0mtdblock_readsectmt_read offset:13824mt_read status:0mtdblock_readsectmt_read offset:14336mt_read status:0mtdblock_readsectmt_read offset:14848mt_read status:0mtdblock_readsectmt_read offset:15360mt_read status:0mtdblock_readsectmt_read offset:15872mt_read status:0cramfs_read
mount: Mounting /dev/mtdblock on /home/crfs failed: Invalid argument /home #
########################################################
I hope I have provided the maximum information. Looking forward for some help.
begin:vcard
fn:M S
n:S;M
version:2.1
end:vcard
Quoted 153 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Max Stirling
Sent: Monday, February 04, 2008 6:20 AM
To: [email protected]
Subject: mtdblock mount issueHi,
I am trying to mount a cramfs partition from flash. I have the low level driver written and
MTDBLOCK_ROmodule is enabled in MTD,My mount fails with invalid argument error.
/mount: Mounting
/dev/mtdblockon/home/crfsfailed: Invalid argument/I am using a 512 byte NAND flash 16byte spare.
I can find cramfs in
/proc/filesytemsand the mtdblock is under/proc/devices.I had enabled a few debug statements in the
mtdblock_roand the low level nand driver code. I find that the mount is reading 32 pages after which it fails with invalid argument. Below is the log.If you see the log below, the flow of code is
cramfs_read==>do_blktrans_request==>mtdblock_readsect
==>mt_read(my low level read function which returns success)I even dumped the hex of the data being read by my low level driver module and found to match the cramfs image that I wrote to the flash.
######################*LOG*##########################
/home # mkdir crfs
/home # cat/proc/devices| grep mtdblock
31 mtdblock
/home # cat proc/filesystems | grep cramfs
cramfs
/home #
/home # mknod/dev/mtdblockb 31 0
/home # mount -t cramfs/dev/mtdblock/home/crfs
mount:/dev/mtdblockis write-protected, mounting read-onlycramfs_readdo_blktrans_requestnsect:8 block:0mtdblock_readsectmt_readoffset:0mt_readstatus:0mtdblock_readsectmt_readoffset:512mt_readstatus:0mtdblock_readsectmt_readoffset:1024mt_readstatus:0mtdblock_readsectmt_readoffset:1536mt_readstatus:0mtdblock_readsectmt_readoffset:2048mt_readstatus:0mtdblock_readsectmt_readoffset:2560mt_readstatus:0mtdblock_readsectmt_readoffset:3072mt_readstatus:0mtdblock_readsectmt_readoffset:3584mt_readstatus:0do_blktrans_requestnsect:8 block:0mtdblock_readsectmt_readoffset:4096mt_readstatus:0mtdblock_readsectmt_readoffset:4608mt_readstatus:0mtdblock_readsectmt_readoffset:5120mt_readstatus:0mtdblock_readsectmt_readoffset:5632mt_readstatus:0mtdblock_readsectmt_readoffset:6144mt_readstatus:0mtdblock_readsectmt_readoffset:6656mt_readstatus:0mtdblock_readsectmt_readoffset:7168mt_readstatus:0mtdblock_readsectmt_readoffset:7680mt_readstatus:0do_blktrans_requestnsect:8 block:0mtdblock_readsectmt_readoffset:8192mt_readstatus:0mtdblock_readsectmt_readoffset:8704mt_readstatus:0mtdblock_readsectmt_readoffset:9216mt_readstatus:0mtdblock_readsectmt_readoffset:9728mt_readstatus:0mtdblock_readsectmt_readoffset:10240mt_readstatus:0mtdblock_readsectmt_readoffset:10752mt_readstatus:0mtdblock_readsectmt_readoffset:11264mt_readstatus:0mtdblock_readsectmt_readoffset:11776mt_readstatus:0do_blktrans_requestnsect:8 block:0mtdblock_readsectmt_readoffset:12288mt_readstatus:0mtdblock_readsectmt_readoffset:12800mt_readstatus:0mtdblock_readsectmt_readoffset:13312mt_readstatus:0mtdblock_readsectmt_readoffset:13824mt_readstatus:0mtdblock_readsectmt_readoffset:14336mt_readstatus:0mtdblock_readsectmt_readoffset:14848mt_readstatus:0mtdblock_readsectmt_readoffset:15360mt_readstatus:0mtdblock_readsectmt_readoffset:15872mt_readstatus:0cramfs_read
mount: Mounting/dev/mtdblockon/home/crfsfailed: Invalid argument /home #
Quoted 7 lines
########################################################
I hope I have provided the maximum information. Looking forward for some
help.
You need to mount the file system as read only. I believe I've seen this error when I've mounted a squashfs (also a read only file system) without specifying the read only option.
Try this command:
mount /dev/mtdblock /home/crfs -t cramfs -o ro
Rick
Quoted 151 lines · Adams Richard-W36112 wrote:
Quoted 144 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Max Stirling
Sent: Monday, February 04, 2008 6:20 AM
To: [email protected]
Subject: mtdblock mount issueHi,
I am trying to mount a cramfs partition from flash. I have the low level driver written and
MTDBLOCK_ROmodule is enabled in MTD,My mount fails with invalid argument error.
/mount: Mounting
/dev/mtdblockon/home/crfsfailed: Invalid argument/I am using a 512 byte NAND flash 16byte spare.
I can find cramfs in
/proc/filesytemsand the mtdblock is under/proc/devices.I had enabled a few debug statements in the
mtdblock_roand the low level nand driver code. I find that the mount is reading 32 pages after which it fails with invalid argument. Below is the log.If you see the log below, the flow of code is
cramfs_read==>do_blktrans_request==>mtdblock_readsect
==>mt_read(my low level read function which returns success)I even dumped the hex of the data being read by my low level driver module and found to match the cramfs image that I wrote to the flash.
######################*LOG*##########################
/home # mkdir crfs
/home # cat/proc/devices| grep mtdblock
31 mtdblock
/home # cat proc/filesystems | grep cramfs
cramfs
/home #
/home # mknod/dev/mtdblockb 31 0
/home # mount -t cramfs/dev/mtdblock/home/crfs
mount:/dev/mtdblockis write-protected, mounting read-onlycramfs_readdo_blktrans_requestnsect:8 block:0mtdblock_readsectmt_readoffset:0mt_readstatus:0mtdblock_readsectmt_readoffset:512mt_readstatus:0mtdblock_readsectmt_readoffset:1024mt_readstatus:0mtdblock_readsectmt_readoffset:1536mt_readstatus:0mtdblock_readsectmt_readoffset:2048mt_readstatus:0mtdblock_readsectmt_readoffset:2560mt_readstatus:0mtdblock_readsectmt_readoffset:3072mt_readstatus:0mtdblock_readsectmt_readoffset:3584mt_readstatus:0do_blktrans_requestnsect:8 block:0mtdblock_readsectmt_readoffset:4096mt_readstatus:0mtdblock_readsectmt_readoffset:4608mt_readstatus:0mtdblock_readsectmt_readoffset:5120mt_readstatus:0mtdblock_readsectmt_readoffset:5632mt_readstatus:0mtdblock_readsectmt_readoffset:6144mt_readstatus:0mtdblock_readsectmt_readoffset:6656mt_readstatus:0mtdblock_readsectmt_readoffset:7168mt_readstatus:0mtdblock_readsectmt_readoffset:7680mt_readstatus:0do_blktrans_requestnsect:8 block:0mtdblock_readsectmt_readoffset:8192mt_readstatus:0mtdblock_readsectmt_readoffset:8704mt_readstatus:0mtdblock_readsectmt_readoffset:9216mt_readstatus:0mtdblock_readsectmt_readoffset:9728mt_readstatus:0mtdblock_readsectmt_readoffset:10240mt_readstatus:0mtdblock_readsectmt_readoffset:10752mt_readstatus:0mtdblock_readsectmt_readoffset:11264mt_readstatus:0mtdblock_readsectmt_readoffset:11776mt_readstatus:0do_blktrans_requestnsect:8 block:0mtdblock_readsectmt_readoffset:12288mt_readstatus:0mtdblock_readsectmt_readoffset:12800mt_readstatus:0mtdblock_readsectmt_readoffset:13312mt_readstatus:0mtdblock_readsectmt_readoffset:13824mt_readstatus:0mtdblock_readsectmt_readoffset:14336mt_readstatus:0mtdblock_readsectmt_readoffset:14848mt_readstatus:0mtdblock_readsectmt_readoffset:15360mt_readstatus:0mtdblock_readsectmt_readoffset:15872mt_readstatus:0cramfs_read
mount: Mounting/dev/mtdblockon/home/crfsfailed: Invalid argument /home #Quoted 6 lines
########################################################
I hope I have provided the maximum information. Looking forward for some help.
Quoted 9 lines
You need to mount the file system as read only. I believe I've seen this error when I've mounted a squashfs (also a read only file system) without specifying the read only option.
Try this command:
mount/dev/mtdblock/home/crfs-t cramfs -o roRick
Thanks mate. After some debugging I found that in cramfs_read function it calls read_cache_page and the returned superblock magic is not correct from cramfs_read.
I am not sure whatz gone wrong since in my low level driver code I dumped the data that is being copied to the buffer that readsect from block_ro passed and the magic was right there.
Have to dig into what might be causing this wrong data to be returned by read_cache_page. One more thing that I noticed was that for every run the magic in the page that read_cache_page returns is different !!!
I am using linux kernel 2.6.10, the latest kernel calls read_mapping_page_async in cramfs_read. Not sure if this was a fix to what I have been seeing or something wrong here.
Signature · 1 line
Max Stirling
Quoted 2 lines
I am trying to mount a cramfs partition from flash.
A word of warning. CRAMFS is broken in kernels < 2.6.18. As far as I can tell, under heavy load (e.g. reading multiple files in parallel that are not cached) it may fail with decompression errors. I think the issue is not exactly with cramfs but with some interaction with page cache. Backporting just cramfs files to 2.6.15 did not help. If you have drop_caches interface (kernel > 2.6.16 or just backport it) it is easy to reproduce. Otherwise it happens _very_ infrequently because most of the time files are already cached. However the consequences are severe - corrupted executables, etc.
Here is a script to reproduce the problem:
===============================================
# Copy large file from cramfs to tmpfs
cp /bin/smbd /tmp/
# First concurrent access to files/directories
while [ 1 ]; do cat /bin/* > /dev/null; done &
# Second concurrent access to test file and cache flush for((i=0;i<99999;i++)) do echo -n "cycle=$i ";
cmp /bin/smbd /tmp/smbd ;
echo 3 > /proc/sys/vm/drop_caches ;
done
===============================================
Note that /bin is in cramfs. smbd can be any large file.
I've also seen statements that drop_caches interface is not 100% reliable. Nevertheless I have experienced decompression errors even without forcing cache purge.
Above script has caused failures on PowerPC/2.6.16 and ARM9/2.6.15. 2.6.18 and 2.6.23 seem ok.
Regards,
Sergei
P.S. Yes, cramfs has little to do with MTD but since ppl here use it with flash I felt it was a good idea to post this warning.
Quoted 36 lines · Sergei Sharonov
Quoted 2 lines
I am trying to mount a cramfs partition from flash.
A word of warning. CRAMFS is broken in kernels < 2.6.18. As far as I can tell, under heavy load (e.g. reading multiple files in parallel that are not cached) it may fail with decompression errors. I think the issue is not exactly with cramfs but with some interaction with page cache. Backporting just cramfs files to 2.6.15 did not help. If you have
drop_cachesinterface (kernel > 2.6.16 or just backport it) it is easy to reproduce. Otherwise it happens _very_ infrequently because most of the time files are already cached. However the consequences are severe - corrupted executables, etc.
Here is a script to reproduce the problem:===============================================
# Copy large file from cramfs to tmpfs
cp/bin/smbd/tmp/# First concurrent access to files/directories while [ 1 ]; do cat
/bin/*>/dev/null; done &# Second concurrent access to test file and cache flush for((i=0;i<99999;i++)) do echo -n "cycle=$i ";
cmp/bin/smbd/tmp/smbd;
echo 3 >/proc/sys/vm/drop_caches;
done
===============================================Note that /bin is in cramfs. smbd can be any large file.
I've also seen statements thatdrop_cachesinterface is not 100% reliable. Nevertheless I have experienced decompression errors even without forcing cache purge. Above script has caused failures on PowerPC/2.6.16 and ARM9/2.6.15. 2.6.18 and 2.6.23 seem ok.Regards,
Sergei
Quoted 8 lines
P.S. Yes, cramfs has little to do with MTD but since ppl here use it with flash I felt it was a good idea to post this warning.______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
thanks for the info. I think I will check out squashfs then.
But before that I wanted to fix the issue that I am seeing. There might be something wrong in my implementation?
BTW I thought this was the right mailing list, since I am trying to mount cramfs image using MTD. Can you point me to the right mailing list?
begin:vcard
fn:M S
n:S;M
version:2.1
end:vcard