84932253d85ede56ecbf8b48fecc9150b017aad3
[pandora-kernel.git] / Documentation / filesystems / aufs / design / 07export.txt
1
2 # Copyright (C) 2005-2011 Junjiro R. Okajima
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 Export Aufs via NFS
19 ----------------------------------------------------------------------
20 Here is an approach.
21 - like xino/xib, add a new file 'xigen' which stores aufs inode
22   generation.
23 - iget_locked(): initialize aufs inode generation for a new inode, and
24   store it in xigen file.
25 - destroy_inode(): increment aufs inode generation and store it in xigen
26   file. it is necessary even if it is not unlinked, because any data of
27   inode may be changed by UDBA.
28 - encode_fh(): for a root dir, simply return FILEID_ROOT. otherwise
29   build file handle by
30   + branch id (4 bytes)
31   + superblock generation (4 bytes)
32   + inode number (4 or 8 bytes)
33   + parent dir inode number (4 or 8 bytes)
34   + inode generation (4 bytes))
35   + return value of exportfs_encode_fh() for the parent on a branch (4
36     bytes)
37   + file handle for a branch (by exportfs_encode_fh())
38 - fh_to_dentry():
39   + find the index of a branch from its id in handle, and check it is
40     still exist in aufs.
41   + 1st level: get the inode number from handle and search it in cache.
42   + 2nd level: if not found, get the parent inode number from handle and
43     search it in cache. and then open the parent dir, find the matching
44     inode number by vfs_readdir() and get its name, and call
45     lookup_one_len() for the target dentry.
46   + 3rd level: if the parent dir is not cached, call
47     exportfs_decode_fh() for a branch and get the parent on a branch,
48     build a pathname of it, convert it a pathname in aufs, call
49     path_lookup(). now aufs gets a parent dir dentry, then handle it as
50     the 2nd level.
51   + to open the dir, aufs needs struct vfsmount. aufs keeps vfsmount
52     for every branch, but not itself. to get this, (currently) aufs
53     searches in current->nsproxy->mnt_ns list. it may not be a good
54     idea, but I didn't get other approach.
55   + test the generation of the gotten inode.
56 - every inode operation: they may get EBUSY due to UDBA. in this case,
57   convert it into ESTALE for NFSD.
58 - readdir(): call lockdep_on/off() because filldir in NFSD calls
59   lookup_one_len(), vfs_getattr(), encode_fh() and others.