Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled page fault in zuf_create #4

Open
lujiwei opened this issue May 13, 2021 · 2 comments
Open

Unhandled page fault in zuf_create #4

lujiwei opened this issue May 13, 2021 · 2 comments

Comments

@lujiwei
Copy link

lujiwei commented May 13, 2021

Hi Authors,

I managed to build zuf.ko, on my Ubuntu 20 (5.4.0-73-generic) with gcc 9.3.0
For zusd, libzus.so and libtoyfs.so, I had to make the following changes to build:

  1. create .config under zus/ which looks like the following:
    ZUF_KERN_DIR=../zuf
    DEBUG=0
    CONFIG_PEDANTIC = 0
    CONFIG_OPTIMIZE_LEVEL = 2
    CONFIG_TRY_ANON_MMAP = 0
    CONFIG_ZUF_DEF_PATH = /sys/fs/zuf
    CONFIG_BUILD_VERBOSE = 0
    CONFIG_LIBFS_MODULES = toyfs

  2. add "no-incompatible-pointer-types" to CWARNS inside common.zus.mk

  3. get rid of the 3rd NULL parameter in those _zus_iom_start() invocations inside fs/toyfs/mmap.c as the declaration of that function inside iom_enc.h only takes two params.

I also created a /dev/pmem0 device via DRAM emulation by adding " memmap=16G!4G" to GRUB_CMDLINE_LINUX in grub config.

After that I was able to insmod zuf.ko, mount /sys/fs/zuf, mount /mnt/toyfs. However when I tried to create a file or directory under /mnt/toyfs, I always hit the following fault:

[ 5999.029269] zuf: vfs [zuf_lookup:68] [1] dentry-name=file
[ 5999.029352] zuf: error [zuf_lookup:77] zufc_dispatch failed => -2
[ 5999.029365] zuf: vfs [zuf_create:106] [1] dentry-name=file mode=0x81b6
[ 5999.029472] zuf: d-oto [zuf_new_inode:361] inode=00000000a6332c56 name=file
[ 5999.029483] zuf: acl [zuf_get_acl:205] [1] type=0x4000
[ 5999.029500] zuf: vfs [__zuf_getxattr:79] [1] type=2 name=posix_acl_default size=4096 ioc_size=66
[ 5999.029779] zuf: error [zuf_new_inode:391] zufc_dispatch failed => -568299520
[ 5999.029792] zuf: error [zuf_evict_inode:277] [0] inode without zi mode=0x8000 size=0x0
[ 5999.029819] BUG: unable to handle page fault for address: ffffffffde207020
[ 5999.038812] #PF: supervisor write access in kernel mode
[ 5999.045469] #PF: error_code(0x0002) - not-present page

With some investigation I pinpointed the problem in zuf_new_inode. See below for details:

static int zuf_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl) {
struct inode *inode;
zuf_pcpu_inc(SBI(dir->i_sb), zu_pcpu_us_create);
zuf_dbg_vfs("[%ld] dentry-name=%s mode=0x%x\n",
dir->i_ino, dentry->d_name.name, mode);
inode = zuf_new_inode(dir, mode, &dentry->d_name, NULL, 0, false); <= returns a large error code -568299520
if (IS_ERR(inode)) <= IS_ERR fails to detect the error
return PTR_ERR(inode);
inode->i_op = &zuf_file_inode_operations; <= dereferencing inode->i_op caused an page fault
inode->i_mapping->a_ops = &zuf_aops;
inode->i_fop = &zuf_file_operations;
_instantiate_unlock(dentry, inode);
return 0;
}

Can anyone help to address my problem?

@aepotapov
Copy link

Hi!
I'm not author but I spent some time fixing this.
You should update toyfs_new_inode function from fs/toyfs/inode.c module to return int as result and put zii structure to ioc_new like this ioc_new->zus_ii = zii

@Boaz17
Copy link
Contributor

Boaz17 commented Oct 27, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants