<div dir="ltr"><div style="font-family:arial,sans-serif;font-size:13px"> I am facing some issue on a filesystem-driver I ported from 2.6.18 kernel to 3.8. Now a lot has changed in the VFS since 2.6.18 to 3.8, which has caused a lot of problem for this driver. One of the biggest core change is the change in <span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;line-height:22px">Path resolution.</span></div>
<div style="font-family:arial,sans-serif;font-size:13px"><span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;line-height:22px"><br></span></div><div style="font-family:arial,sans-serif;font-size:13px">
<span style="background-color:rgb(251,251,251);color:rgb(51,51,51);font-family:Helvetica,arial,freesans,clean,sans-serif;line-height:22px"><b>LET ME GIVE SOME Basic Information</b> </span></div><div style="font-family:arial,sans-serif;font-size:13px">
<span style="background-color:rgb(251,251,251);line-height:22px"><font color="#333333" face="Helvetica, arial, freesans, clean, sans-serif"><div>Path resolution is the finding a dentry corresponding to a path name string, by performing a path walk.</div>
<div>Paths are resolved by walking the namespace tree, starting with the first component of the pathname (eg. root or cwd) with a known dentry, then finding the child of that dentry, which is named the next component in the path string. Then repeating the lookup from the child dentry and finding its child with the next element, and so on.</div>
<div>Kindly have a look at the below image-<br></div><div><a href="http://lwn.net/images/ns/kernel/dentry.png" target="_blank">http://lwn.net/images/ns/kernel/dentry.png</a></div><div><br></div><div>In my driver code it is done here in the function-</div>
<div>int get_full_path_d(const struct dentry *dentry, char *real_path) at the below link-</div><div><a href="https://github.com/disdi/hepunion/blob/master/fs/hepunion/helpers.c#L375" target="_blank">https://github.com/disdi/hepunion/blob/master/fs/hepunion/helpers.c#L375</a></div>
<div><b>I would like to point out here that I had dcache_lock on 2.6.18 kernel to protect this lookup but on 3.8 kernel, I haven't found a suitable replacement<br></b></div><div><br></div><div>The entire code flow chart of my driver can be found here-</div>
<div><a href="https://github.com/disdi/hepunion/issues/6" target="_blank">https://github.com/disdi/hepunion/issues/6</a><br></div><div><br></div><div>Since 2.6.38, RCU is used to make a significant part of the entire path walk (including dcache look-up) completely "store-free" (so, no locks, atomics, or even stores into cachelines of common dentries). This is known as "rcu-walk" path walking. rcu-walk uses a d_seq protected snapshot. When looking up a child of this parent snapshot, we open d_seq critical section on the child before closing d_seq critical section on the parent. This gives an interlocking ladder of snapshots to walk down.<br>
</div><div>Something like the below link-<br><a href="http://spatula-city.org/~im14u2c/images/man_running_up_crumbling_stairs.jpg" target="_blank" style="color:rgb(65,131,196);text-decoration:none">http://spatula-city.org/~im14u2c/images/man_running_up_crumbling_stairs.jpg</a></div>
<div><br></div><div><b>PROBLEM</b></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;line-height:normal;background-color:rgb(255,255,255)">Since this filesystem does not follow RCU-lookup as of now or since I have not done anything to upgrade our driver to tell VFS whether we follow RCU or not and simply ported the driver to 3.8 kernel by changing the kernel functions or APIs but the respective replacements. Now there is no compilier error but at runtime, I find myself caught in some endless loop and in the stack or dmesg I see something called </span><b style="line-height:normal;color:rgb(34,34,34);font-family:arial,sans-serif">lg_local_lock.</b></div>
<div><span style="line-height:normal;color:rgb(34,34,34);font-family:arial,sans-serif"><br></span></div><div><span style="line-height:normal;color:rgb(34,34,34);font-family:arial,sans-serif">The entire kernel stack of my driver can be found here -</span></div>
<div><a href="https://github.com/disdi/hepunion/issues/5" target="_blank">https://github.com/disdi/hepunion/issues/5</a><span style="line-height:normal;color:rgb(34,34,34);font-family:arial,sans-serif"><br></span></div><div>
<br></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;line-height:normal;background-color:rgb(255,255,255)">I searched and found the following link describing it thoroughly-</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;line-height:normal;background-color:rgb(255,255,255)">
<a href="http://lwn.net/Articles/401738/" target="_blank">http://lwn.net/Articles/401738/</a><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;line-height:normal;background-color:rgb(255,255,255)"><br>
</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;line-height:normal;background-color:rgb(255,255,255)">To sum up</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;line-height:normal;background-color:rgb(255,255,255)">
1. This thing has come up with the new RCU-lookup change.</div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;line-height:normal;background-color:rgb(255,255,255)"><div>2. lglocks is to <b>protect the list of open files</b> which is attached to each superblock structure.</div>
<div><br></div><div>Since this filesystem driver is failing when I do a "ls in mount point" and if we do a strace on "ls" we have</div><div> open("/scratch", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 <br>
</div><div>and in the stack after it hangs, it shows lg_lock</div><div><br></div><div>3.<span style="font-size:medium;font-family:'Times New Roman'">And most importanly</span></div><div><span style="font-size:medium;font-family:'Times New Roman'">"The real reason that the per-superblock open files list exists is to let the kernel check for writable files when a filesystem is being remounted read-only." </span></div>
<div><br></div><div>I have a union of filesystems in this filesystem, where one is Read Only and the other is Read-Write. I think I am violating some of this kernel protection mechanism and find mydriver stuck.</div><div>
<br></div><div>If you can have a look at this issue, I shall be grateful to you.</div><div><br></div><div>Regards,</div><div>Saket Sinha</div></div></font></span></div></div>