]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - Documentation/filesystems/aufs/design/07export.txt
UBUNTU: SAUCE: Import aufs driver
[mirror_ubuntu-artful-kernel.git] / Documentation / filesystems / aufs / design / 07export.txt
1
2 # Copyright (C) 2005-2017 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, see <http://www.gnu.org/licenses/>.
16
17 Export Aufs via NFS
18 ----------------------------------------------------------------------
19 Here is an approach.
20 - like xino/xib, add a new file 'xigen' which stores aufs inode
21 generation.
22 - iget_locked(): initialize aufs inode generation for a new inode, and
23 store it in xigen file.
24 - destroy_inode(): increment aufs inode generation and store it in xigen
25 file. it is necessary even if it is not unlinked, because any data of
26 inode may be changed by UDBA.
27 - encode_fh(): for a root dir, simply return FILEID_ROOT. otherwise
28 build file handle by
29 + branch id (4 bytes)
30 + superblock generation (4 bytes)
31 + inode number (4 or 8 bytes)
32 + parent dir inode number (4 or 8 bytes)
33 + inode generation (4 bytes))
34 + return value of exportfs_encode_fh() for the parent on a branch (4
35 bytes)
36 + file handle for a branch (by exportfs_encode_fh())
37 - fh_to_dentry():
38 + find the index of a branch from its id in handle, and check it is
39 still exist in aufs.
40 + 1st level: get the inode number from handle and search it in cache.
41 + 2nd level: if not found in cache, get the parent inode number from
42 the handle and search it in cache. and then open the found parent
43 dir, find the matching inode number by vfs_readdir() and get its
44 name, and call lookup_one_len() for the target dentry.
45 + 3rd level: if the parent dir is not cached, call
46 exportfs_decode_fh() for a branch and get the parent on a branch,
47 build a pathname of it, convert it a pathname in aufs, call
48 path_lookup(). now aufs gets a parent dir dentry, then handle it as
49 the 2nd level.
50 + to open the dir, aufs needs struct vfsmount. aufs keeps vfsmount
51 for every branch, but not itself. to get this, (currently) aufs
52 searches in current->nsproxy->mnt_ns list. it may not be a good
53 idea, but I didn't get other approach.
54 + test the generation of the gotten inode.
55 - every inode operation: they may get EBUSY due to UDBA. in this case,
56 convert it into ESTALE for NFSD.
57 - readdir(): call lockdep_on/off() because filldir in NFSD calls
58 lookup_one_len(), vfs_getattr(), encode_fh() and others.