Subject: ext2fs_statvfs and mtn_stat.
To: None <tech-kern@netbsd.org>
From: Adam Hamsik <haaaad@gmail.com>
List: tech-kern
Date: 08/29/2007 01:38:43
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi folks!!

I'm working on improving our ext2fs support to ext3. Ext3fs's  
superblock contains inode number where journal superblock (aka JBD  
superblock) is stored.

I use ext2fs_vget to translate this inode number to vnode. After that  
I want to
read jbd superblock from disk to the memory with VOP_READ. But I  
receive panic at [1] (panic message is integer divide error code=0)

Problem is that mp->mnt_stat is not allocated because I mount this  
disk as non root partition. mp->mnt_stat is structure statvfs and is  
filled with ext2fs_statvfs function. But this function is called only  
once from [2].

I have two problems here. :)

1) I don't understand how can this work in real usage, when I mount  
disk as non root partition. When and where mp->mnt_stat get filled in  
and why we doesn't call ext2fs_statvfs also in ext2fs_mount. When I  
try to read file from mounted filesystem mp->mnt_stat is filled with  
correct data although ext2fs_statvfs was not called and filesystem is  
mounted as non root. *

2)what is correct solution for this ? If I add ext2fs_statvfs to the  
ext2fs_mount everything works. This behaviour is shared across all  
our ufs based filesystems I checked ffs[4],ext2fs.

*One possible solution for this is that runp[3] is null when I read  
data from disk in userspace and not null when I try this in kernel  
space.


IMO this is bug and we have to fix it, because I can't call VOP_READ  
(or ext2fs_read) from kernel with out panic. As a workaround I have  
added ext2fs_stavfs to the ext2fs_mount and everythings works fine.

[1]http://opengrok.netbsd.org/source/xref/sys/ufs/ext2fs/ 
ext2fs_bmap.c#168
[2] http://opengrok.netbsd.org/source/xref/sys/ufs/ext2fs/ 
ext2fs_vfsops.c#240
[3]http://opengrok.netbsd.org/source/xref/sys/ufs/ext2fs/ 
ext2fs_bmap.c#160
    http://opengrok.netbsd.org/source/xref/sys/miscfs/genfs/ 
genfs_vnops.c#799
[4]http://opengrok.netbsd.org/source/xref/sys/ufs/ufs/ufs_bmap.c#138
Regards
- -----------------------------------------
Adam Hamsik
jabber: haad@jabber.org
icq: 249727910

Proud NetBSD user.

We program to have fun.
Even when we program for money, we want to have fun as well.
~ Yukihiro Matsumoto




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iD8DBQFG1LIDlIxPgX3Go0MRAsBlAJ0SmUFSIHmJ6/dZcTfV6HOITPWr4gCcDs1m
aDVTVoFzrB4plKcWJJx1Zj4=
=Y9Wk
-----END PGP SIGNATURE-----