Just to explain my previous mail even better--
1. If I need to protect my driver from itself, it can add its own locking.
2. If the problem is that dcache_lock is used to protect critical variables from other parts of the kernel, I have two options-
a) I will need to restructure my code to avoid the issue
b) I need to find other suitable locking.
I specifically list
down the link to my kernel driver below where this dcache-lock is
present in 2.6.18 kernel and is absent in 3.8 kernel-
From what I could make out from our driver code is that -
hepunion_permission and hepunion_getattr are called by the VFS(or kernel) and both receive its parameters from VFS only-
a)static int hepunion_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *kstbuf)
b)static int hepunion_permission(struct inode *inode, int mask)
Now if you look at the function definition, you would find that both of them use
get_relative_path-
https://github.com/HeisSpiter/hepunion/blob/8ce91306a302afe797af09b0831d312ad87e495a/fs/hepunion/helpers.c#L446
and pass either inode or dentry respectively.
Inside this function either
a)get_full_path_d(dentry, real_path);//called if dentry is sent
b)get_full_path_i(inode, real_path);//called if inode is sent
Now inside get_full_path_i ultimately get_full_path_d gets called ultimately.
Now inside get_full_path_d only, we implement our dcache_lock to calculate the path.
Conclusion- So I conclude that in our code "dcache_lock is used to protect critical variables from other parts of the kernel,"
What critical variable?
See I have registered my driver functions to respective system calls through which VFS calls them.
Now when I do mount, the following system calls gets generated-
1. mount(get_sb in the new kernel) - which calls hepunion_read_super and the super block gets assigned
2.permission---mapped to hepunion_permission
3.getattr------mapped to hepunion_getattr
Now when I do a ls
hepunion_permission again gets called and this time the VM gets hanged
SO NOW DIFFERENT PARAMETRS ARE BEING PASSED TO
THE FUNCTION
THIS TIME AND THIS MAYBE CAUSING THE HANG
so maybe for "ls" VFS sent different parameters to hepunion_permission() in "ls "
command that it did during mount.
Regards,
Saket Sinha