]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - Documentation/filesystems/aufs/design/06dirren.txt
UBUNTU: ubuntu: vbox -- update to 5.2.6-dfsg-5
[mirror_ubuntu-bionic-kernel.git] / Documentation / filesystems / aufs / design / 06dirren.txt
CommitLineData
0006ebb4
SF
1
2# Copyright (C) 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
17Special handling for renaming a directory (DIRREN)
18----------------------------------------------------------------------
19First, let's assume we have a simple usecase.
20
21- /u = /rw + /ro
22- /rw/dirA exists
23- /ro/dirA and /ro/dirA/file exist too
24- there is no dirB on both branches
25- a user issues rename("dirA", "dirB")
26
27Now, what should aufs behave against this rename(2)?
28There are a few possible cases.
29
30A. returns EROFS.
31 since dirA exists on a readonly branch which cannot be renamed.
32B. returns EXDEV.
33 it is possible to copy-up dirA (only the dir itself), but the child
34 entries ("file" in this case) should not be. it must be a bad
35 approach to copy-up recursively.
36C. returns a success.
37 even the branch /ro is readonly, aufs tries renaming it. Obviously it
38 is a violation of aufs' policy.
39D. construct an extra information which indicates that /ro/dirA should
40 be handled as the name of dirB.
41 overlayfs has a similar feature called REDIRECT.
42
43Until now, aufs implements the case B only which returns EXDEV, and
44expects the userspace application behaves like mv(1) which tries
45issueing rename(2) recursively.
46
47A new aufs feature called DIRREN is introduced which implements the case
48D. There are several "extra information" added.
49
501. detailed info per renamed directory
51 path: /rw/dirB/$AUFS_WH_DR_INFO_PFX.<lower branch-id>
522. the inode-number list of directories on a branch
53 path: /rw/dirB/$AUFS_WH_DR_BRHINO
54
55The filename of "detailed info per directory" represents the lower
56branch, and its format is
57- a type of the branch id
58 one of these.
59 + uuid (not implemented yet)
60 + fsid
61 + dev
62- the inode-number of the branch root dir
63
64And it contains these info in a single regular file.
65- magic number
66- branch's inode-number of the logically renamed dir
67- the name of the before-renamed dir
68
69The "detailed info per directory" file is created in aufs rename(2), and
70loaded in any lookup.
71The info is considered in lookup for the matching case only. Here
72"matching" means that the root of branch (in the info filename) is same
73to the current looking-up branch. After looking-up the before-renamed
74name, the inode-number is compared. And the matched dentry is used.
75
76The "inode-number list of directories" is a regular file which contains
77simply the inode-numbers on the branch. The file is created or updated
78in removing the branch, and loaded in adding the branch. Its lifetime is
79equal to the branch.
80The list is refered in lookup, and when the current target inode is
81found in the list, the aufs tries loading the "detailed info per
82directory" and get the changed and valid name of the dir.
83
84Theoretically these "extra informaiton" may be able to be put into XATTR
85in the dir inode. But aufs doesn't choose this way because
861. XATTR may not be supported by the branch (or its configuration)
872. XATTR may have its size limit.
883. XATTR may be less easy to convert than a regular file, when the
89 format of the info is changed in the future.
90At the same time, I agree that the regular file approach is much slower
91than XATTR approach. So, in the future, aufs may take the XATTR or other
92better approach.
93
94This DIRREN feature is enabled by aufs configuration, and is activated
95by a new mount option.
96
97For the more complicated case, there is a work with UDBA option, which
98is to dected the direct access to the branches (by-passing aufs) and to
99maintain the cashes in aufs. Since a single cached aufs dentry may
100contains two names, before- and after-rename, the name comparision in
101UDBA handler may not work correctly. In this case, the behaviour will be
102equivalen to udba=reval case.