[OpenAFS-devel] Re: Error of VGetVolume() call in venus/fs.c
Andrew Deason
adeason@sinenomine.net
Mon, 9 Apr 2012 13:13:53 -0500
On Mon, 9 Apr 2012 13:47:34 -0400
xianwei zhang <cinwell.chang@gmail.com> wrote:
> Currently I am doing a small project on OpenAFS. Now, I am planning to
> read the Vnode associated with a file. My idea is let user enter the
> command 'fs getvnode FILE_NAME' to view the vnode (status)
> information:
> (1) user enters 'fs getvnode /afs'
> (2) first get the fid for that file and then use the fid to get the vnode
>
> while for (1) response is in the file /venus/fs.c, the function to get
> vnode is implemented in file /vol/vnode.c. I want to call the VGetVnode()
> in fs.c. But
You can't really use VGetVnode() in the 'fs' command. Conceptually, the
'fs' command runs on the client, and only interacts directly with the
'libafs' kernel module via pioctl(). VGetVnode() is to be run on a
fileserver as root, and it reads from /vicepX directly from disk on the
fileserver. The fileserver can be (and usually is) on a completely
different machine than the client.
In order to get the information you want via the 'fs' command, you need
to ask the 'libafs' client for the information, and the client will ask
the fileserver. As an example of how the codepath goes from 'fs' to the
VGetVnode call, try looking at the 'fs examine' command. This follows a
codepath like:
venus/fs.c:
main -> pioctl(VIOCGETVOLSTAT) -> [syscall magic] ->
afs/afs_pioctl.c:
PGetVolumeStatus -> RXAFS_GetVolumeStatus -> [Rx RPC magic] ->
viced/afsfilesprocs.c:
SRXAFS_GetVolumeStatus -> GetVolumePackage
-> GetVolumePackageWithCall -> CheckVnodeWithCall -> VGetVnode
Although that just looks for the root vnode, not the vnode the user
specified.
What kind of "status information" are you trying to display? You may be
able to get the information from the client cache, which already takes
of actually finding the information for you. The status information we
cache is in 'struct fvcache' and 'struct vcache', which you can find in
afs/afs.h. You will not be able to use that structure directly from
'fs', but 'fs' can ask the client kernel module for that information,
and you can use those structures directly in afs/afs_pioctl.c.
--
Andrew Deason
adeason@sinenomine.net