]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - fs/aufs/opts.h
UBUNTU: SAUCE: aufs: bugfix, for v4.10, copy-up on XFS branch
[mirror_ubuntu-zesty-kernel.git] / fs / aufs / opts.h
1 /*
2 * Copyright (C) 2005-2016 Junjiro R. Okajima
3 *
4 * This program, aufs 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
18 /*
19 * mount options/flags
20 */
21
22 #ifndef __AUFS_OPTS_H__
23 #define __AUFS_OPTS_H__
24
25 #ifdef __KERNEL__
26
27 #include <linux/path.h>
28
29 struct file;
30 struct super_block;
31
32 /* ---------------------------------------------------------------------- */
33
34 /* mount flags */
35 #define AuOpt_XINO 1 /* external inode number bitmap
36 and translation table */
37 #define AuOpt_TRUNC_XINO (1 << 1) /* truncate xino files */
38 #define AuOpt_UDBA_NONE (1 << 2) /* users direct branch access */
39 #define AuOpt_UDBA_REVAL (1 << 3)
40 #define AuOpt_UDBA_HNOTIFY (1 << 4)
41 #define AuOpt_SHWH (1 << 5) /* show whiteout */
42 #define AuOpt_PLINK (1 << 6) /* pseudo-link */
43 #define AuOpt_DIRPERM1 (1 << 7) /* ignore the lower dir's perm
44 bits */
45 #define AuOpt_ALWAYS_DIROPQ (1 << 9) /* policy to creating diropq */
46 #define AuOpt_SUM (1 << 10) /* summation for statfs(2) */
47 #define AuOpt_SUM_W (1 << 11) /* unimplemented */
48 #define AuOpt_WARN_PERM (1 << 12) /* warn when add-branch */
49 #define AuOpt_VERBOSE (1 << 13) /* busy inode when del-branch */
50 #define AuOpt_DIO (1 << 14) /* direct io */
51
52 #ifndef CONFIG_AUFS_HNOTIFY
53 #undef AuOpt_UDBA_HNOTIFY
54 #define AuOpt_UDBA_HNOTIFY 0
55 #endif
56 #ifndef CONFIG_AUFS_SHWH
57 #undef AuOpt_SHWH
58 #define AuOpt_SHWH 0
59 #endif
60
61 #define AuOpt_Def (AuOpt_XINO \
62 | AuOpt_UDBA_REVAL \
63 | AuOpt_PLINK \
64 /* | AuOpt_DIRPERM1 */ \
65 | AuOpt_WARN_PERM)
66 #define AuOptMask_UDBA (AuOpt_UDBA_NONE \
67 | AuOpt_UDBA_REVAL \
68 | AuOpt_UDBA_HNOTIFY)
69
70 #define au_opt_test(flags, name) (flags & AuOpt_##name)
71 #define au_opt_set(flags, name) do { \
72 BUILD_BUG_ON(AuOpt_##name & AuOptMask_UDBA); \
73 ((flags) |= AuOpt_##name); \
74 } while (0)
75 #define au_opt_set_udba(flags, name) do { \
76 (flags) &= ~AuOptMask_UDBA; \
77 ((flags) |= AuOpt_##name); \
78 } while (0)
79 #define au_opt_clr(flags, name) do { \
80 ((flags) &= ~AuOpt_##name); \
81 } while (0)
82
83 static inline unsigned int au_opts_plink(unsigned int mntflags)
84 {
85 #ifdef CONFIG_PROC_FS
86 return mntflags;
87 #else
88 return mntflags & ~AuOpt_PLINK;
89 #endif
90 }
91
92 /* ---------------------------------------------------------------------- */
93
94 /* policies to select one among multiple writable branches */
95 enum {
96 AuWbrCreate_TDP, /* top down parent */
97 AuWbrCreate_RR, /* round robin */
98 AuWbrCreate_MFS, /* most free space */
99 AuWbrCreate_MFSV, /* mfs with seconds */
100 AuWbrCreate_MFSRR, /* mfs then rr */
101 AuWbrCreate_MFSRRV, /* mfs then rr with seconds */
102 AuWbrCreate_TDMFS, /* top down regardless parent and mfs */
103 AuWbrCreate_TDMFSV, /* top down regardless parent and mfs */
104 AuWbrCreate_PMFS, /* parent and mfs */
105 AuWbrCreate_PMFSV, /* parent and mfs with seconds */
106 AuWbrCreate_PMFSRR, /* parent, mfs and round-robin */
107 AuWbrCreate_PMFSRRV, /* plus seconds */
108
109 AuWbrCreate_Def = AuWbrCreate_TDP
110 };
111
112 enum {
113 AuWbrCopyup_TDP, /* top down parent */
114 AuWbrCopyup_BUP, /* bottom up parent */
115 AuWbrCopyup_BU, /* bottom up */
116
117 AuWbrCopyup_Def = AuWbrCopyup_TDP
118 };
119
120 /* ---------------------------------------------------------------------- */
121
122 struct au_opt_add {
123 aufs_bindex_t bindex;
124 char *pathname;
125 int perm;
126 struct path path;
127 };
128
129 struct au_opt_del {
130 char *pathname;
131 struct path h_path;
132 };
133
134 struct au_opt_mod {
135 char *path;
136 int perm;
137 struct dentry *h_root;
138 };
139
140 struct au_opt_xino {
141 char *path;
142 struct file *file;
143 };
144
145 struct au_opt_xino_itrunc {
146 aufs_bindex_t bindex;
147 };
148
149 struct au_opt_wbr_create {
150 int wbr_create;
151 int mfs_second;
152 unsigned long long mfsrr_watermark;
153 };
154
155 struct au_opt {
156 int type;
157 union {
158 struct au_opt_xino xino;
159 struct au_opt_xino_itrunc xino_itrunc;
160 struct au_opt_add add;
161 struct au_opt_del del;
162 struct au_opt_mod mod;
163 int dirwh;
164 int rdcache;
165 unsigned int rdblk;
166 unsigned int rdhash;
167 int udba;
168 struct au_opt_wbr_create wbr_create;
169 int wbr_copyup;
170 unsigned int fhsm_second;
171 };
172 };
173
174 /* opts flags */
175 #define AuOpts_REMOUNT 1
176 #define AuOpts_REFRESH (1 << 1)
177 #define AuOpts_TRUNC_XIB (1 << 2)
178 #define AuOpts_REFRESH_DYAOP (1 << 3)
179 #define AuOpts_REFRESH_IDOP (1 << 4)
180 #define au_ftest_opts(flags, name) ((flags) & AuOpts_##name)
181 #define au_fset_opts(flags, name) \
182 do { (flags) |= AuOpts_##name; } while (0)
183 #define au_fclr_opts(flags, name) \
184 do { (flags) &= ~AuOpts_##name; } while (0)
185
186 struct au_opts {
187 struct au_opt *opt;
188 int max_opt;
189
190 unsigned int given_udba;
191 unsigned int flags;
192 unsigned long sb_flags;
193 };
194
195 /* ---------------------------------------------------------------------- */
196
197 /* opts.c */
198 void au_optstr_br_perm(au_br_perm_str_t *str, int perm);
199 const char *au_optstr_udba(int udba);
200 const char *au_optstr_wbr_copyup(int wbr_copyup);
201 const char *au_optstr_wbr_create(int wbr_create);
202
203 void au_opts_free(struct au_opts *opts);
204 int au_opts_parse(struct super_block *sb, char *str, struct au_opts *opts);
205 int au_opts_verify(struct super_block *sb, unsigned long sb_flags,
206 unsigned int pending);
207 int au_opts_mount(struct super_block *sb, struct au_opts *opts);
208 int au_opts_remount(struct super_block *sb, struct au_opts *opts);
209
210 unsigned int au_opt_udba(struct super_block *sb);
211
212 #endif /* __KERNEL__ */
213 #endif /* __AUFS_OPTS_H__ */