[OpenAFS] afs major number ?

Jeffrey Hutzelman jhutz@cmu.edu
Sun, 04 Dec 2005 21:20:08 -0500


On Tuesday, November 15, 2005 08:55:56 PM -0500 Ron Croonenberg 
<ronc@DePauw.edu> wrote:

> Well i have OpenAFS working on OpenSI for a while now.
>
> Things seem to work pretty stable, however we needed a "hack" in some SSI
> filesystem handling when a process migrates to another clusternode.
>
> We think we have a good solution for it instead of just a hack.
>
> the question is, does AFS have a unique major number ?

Actually, the question you're trying to ask is whether AFS has a reserved
major number, such that the device number of a mounted AFS filesystem will
be consistent across all systems.  The answer is that it does not.  In
Linux, filesystems which have no physical device backing them are attached
to an unnamed device with a device number allocated by the kernel.  This
number will be distinct from any other block device number in use in the
system, but it will not be consistent from one system to the next, or even
from one boot to the next.

> if (S_ISAFS(inode->i_mode)) {
>     if ((inode->i_ino == path->ino &&
>     inode->i_generation == path->generation &&
>     par_mount(inode->i_sb->s_ssidev, path->ssidev)))
>     return 1;
>     }

If you are in user mode, the correct way to determine whether two paths 
represent the same AFS file is to use the VIOCGETFID pioctl to obtain the 
FID's for each file, and compare them.  If the file is not in AFS, the 
pioctl will fail with EINVAL.  Note that while there is no interface to 
obtain the FID of an open file descriptor, in Linux you can cheat by 
calling the pioctl on /proc/self/fd/N

If you are in kernel mode, you will need access to macros and private data 
structures belonging to the cache manager in order to determine whether a 
vnode belongs to AFS and safely extract its FID.

-- Jeff