filesystem implementation questions

Deomid Ryabkov myself at rojer.pp.ru
Wed Aug 10 15:30:18 GMT 2005


Hello, hackers :)

I am implementing a custom filesystem, based on nullfs, its purpose is 
tracking changes made to the fs,
and the idea is to do that by changing the semantics of (largely unused 
anyway) atime attribute of the underlying UFS
(which is mounted -o noatime for that reason. and I don't really care 
about filesystems with no atime attribute. extreme portability is not a 
requirement).
Specifically, I want atime updated on directories from where the change 
has taken place all the way up to the mount point of my filesystem.
This way, a tree of changed directories can be built at any given time 
and synchronised to mirrors.
Now, I have a couple of questions about taking proper actions while 
doing my job inside the kernel.

1) I understand that it is generally impossible to find a parent 
directory for VREG or VLNK vnode (I don't care about pipes or sockets), 
as it may have many links.
   To overcome this, I store a pointer to a parent vnode as a member of 
my struct mirrfs_node upon successful lookup or creation of VREG vnode 
and create an additional
   refernce to the parent vnode. The refernce to parent is released when 
VREG vnode becomes inactive.
   The question is, what might be the implications of this? Could it be 
that I am doing something terribly wrong?
2) Each time I need to propagate a change, I walk my way up the 
directories starting at the directory where the change has occured
    by repeatedly calling VOP_LOOKUP with a hand-crafted struct 
componentname, where cnp.cn_nameptr is ".."
    Same question: is it the right thing to do? could this get me in 
trouble?
3) When updating directories while walking up, I might need root 
privileges which my curthread might not have.
    It is undesirable and might be impossible to have permissions needed 
for setattr to succeed for every curthread.
    So, I know what I am doing and I need root for that. The question 
is, what is the right way to get the needed struct ucred?
    I thought about crcopy'ing curthread->td_ucred and then 
change_[er]uid on it. Is that ok? Are there any implications?

Thanks in advance...

--
Deomid Ryabkov aka Rojer
myself at rojer.pp.ru
rojer at sysadmins.ru
ICQ: 8025844



More information about the freebsd-hackers mailing list