]>
Commit | Line | Data |
---|---|---|
b6450630 SF |
1 | /* |
2 | * Copyright (C) 2005-2017 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 | * module initialization and module-global | |
20 | */ | |
21 | ||
22 | #ifndef __AUFS_MODULE_H__ | |
23 | #define __AUFS_MODULE_H__ | |
24 | ||
25 | #ifdef __KERNEL__ | |
26 | ||
27 | #include <linux/slab.h> | |
28 | ||
29 | struct path; | |
30 | struct seq_file; | |
31 | ||
32 | /* module parameters */ | |
33 | extern int sysaufs_brs; | |
34 | extern bool au_userns; | |
35 | ||
36 | /* ---------------------------------------------------------------------- */ | |
37 | ||
38 | extern int au_dir_roflags; | |
39 | ||
40 | void *au_krealloc(void *p, unsigned int new_sz, gfp_t gfp, int may_shrink); | |
41 | void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp, | |
42 | int may_shrink); | |
43 | ||
44 | static inline int au_kmidx_sub(size_t sz, size_t new_sz) | |
45 | { | |
46 | #ifndef CONFIG_SLOB | |
47 | return kmalloc_index(sz) - kmalloc_index(new_sz); | |
48 | #else | |
49 | return -1; /* SLOB is untested */ | |
50 | #endif | |
51 | } | |
52 | ||
53 | int au_seq_path(struct seq_file *seq, struct path *path); | |
54 | ||
55 | #ifdef CONFIG_PROC_FS | |
56 | /* procfs.c */ | |
57 | int __init au_procfs_init(void); | |
58 | void au_procfs_fin(void); | |
59 | #else | |
60 | AuStubInt0(au_procfs_init, void); | |
61 | AuStubVoid(au_procfs_fin, void); | |
62 | #endif | |
63 | ||
64 | /* ---------------------------------------------------------------------- */ | |
65 | ||
66 | /* kmem cache */ | |
67 | enum { | |
68 | AuCache_DINFO, | |
69 | AuCache_ICNTNR, | |
70 | AuCache_FINFO, | |
71 | AuCache_VDIR, | |
72 | AuCache_DEHSTR, | |
73 | AuCache_HNOTIFY, /* must be last */ | |
74 | AuCache_Last | |
75 | }; | |
76 | ||
77 | extern struct kmem_cache *au_cache[AuCache_Last]; | |
78 | ||
79 | #define AuCacheFlags (SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD) | |
80 | #define AuCache(type) KMEM_CACHE(type, AuCacheFlags) | |
81 | #define AuCacheCtor(type, ctor) \ | |
82 | kmem_cache_create(#type, sizeof(struct type), \ | |
83 | __alignof__(struct type), AuCacheFlags, ctor) | |
84 | ||
85 | #define AuCacheFuncs(name, index) \ | |
86 | static inline struct au_##name *au_cache_alloc_##name(void) \ | |
87 | { return kmem_cache_alloc(au_cache[AuCache_##index], GFP_NOFS); } \ | |
88 | static inline void au_cache_free_##name(struct au_##name *p) \ | |
89 | { kmem_cache_free(au_cache[AuCache_##index], p); } | |
90 | ||
91 | AuCacheFuncs(dinfo, DINFO); | |
92 | AuCacheFuncs(icntnr, ICNTNR); | |
93 | AuCacheFuncs(finfo, FINFO); | |
94 | AuCacheFuncs(vdir, VDIR); | |
95 | AuCacheFuncs(vdir_dehstr, DEHSTR); | |
96 | #ifdef CONFIG_AUFS_HNOTIFY | |
97 | AuCacheFuncs(hnotify, HNOTIFY); | |
98 | #endif | |
99 | ||
100 | #endif /* __KERNEL__ */ | |
101 | #endif /* __AUFS_MODULE_H__ */ |