mm/memunmap: don't access uninitialized memmap in memunmap_pages()
[linux-2.6-block.git] / fs / overlayfs / ovl_entry.h
CommitLineData
d2912cb1 1/* SPDX-License-Identifier: GPL-2.0-only */
bbb1e54d
MS
2/*
3 *
4 * Copyright (C) 2011 Novell Inc.
5 * Copyright (C) 2016 Red Hat, Inc.
bbb1e54d
MS
6 */
7
8struct ovl_config {
9 char *lowerdir;
10 char *upperdir;
11 char *workdir;
12 bool default_permissions;
a6c60655 13 bool redirect_dir;
438c84c2
MS
14 bool redirect_follow;
15 const char *redirect_mode;
02bcd157 16 bool index;
f168f109 17 bool nfs_export;
795939a9 18 int xino;
d5791044 19 bool metacopy;
bbb1e54d
MS
20};
21
5148626b
AG
22struct ovl_sb {
23 struct super_block *sb;
24 dev_t pseudo_dev;
25};
26
b9343632
CR
27struct ovl_layer {
28 struct vfsmount *mnt;
146d62e5
AG
29 /* Trap in ovl inode cache */
30 struct inode *trap;
5148626b
AG
31 struct ovl_sb *fs;
32 /* Index of this layer in fs root (upper idx == 0) */
d583ed7d 33 int idx;
5148626b
AG
34 /* One fsid per unique underlying sb (upper fsid == 0) */
35 int fsid;
b9343632
CR
36};
37
38struct ovl_path {
39 struct ovl_layer *layer;
40 struct dentry *dentry;
41};
42
bbb1e54d
MS
43/* private information held for overlayfs's superblock */
44struct ovl_fs {
45 struct vfsmount *upper_mnt;
5148626b
AG
46 unsigned int numlower;
47 /* Number of unique lower sb that differ from upper sb */
48 unsigned int numlowerfs;
b9343632 49 struct ovl_layer *lower_layers;
5148626b 50 struct ovl_sb *lower_fs;
2cac0c00
AG
51 /* workbasedir is the path at workdir= mount option */
52 struct dentry *workbasedir;
53 /* workdir is the 'work' directory under workbasedir */
bbb1e54d 54 struct dentry *workdir;
02bcd157
AG
55 /* index directory listing overlay inodes by origin file handle */
56 struct dentry *indexdir;
6b2d5fe4 57 long namelen;
bbb1e54d
MS
58 /* pathnames of lower and upper dirs, for show_options */
59 struct ovl_config config;
60 /* creds of process who forced instantiation of super block */
61 const struct cred *creator_cred;
e7f52429 62 bool tmpfile;
82b749b2 63 bool noxattr;
85fdee1e
AG
64 /* Did we take the inuse lock? */
65 bool upperdir_locked;
66 bool workdir_locked;
146d62e5
AG
67 /* Traps in ovl inode cache */
68 struct inode *upperdir_trap;
0be0bfd2 69 struct inode *workbasedir_trap;
146d62e5
AG
70 struct inode *workdir_trap;
71 struct inode *indexdir_trap;
e487d889
AG
72 /* Inode numbers in all layers do not use the high xino_bits */
73 unsigned int xino_bits;
bbb1e54d
MS
74};
75
76/* private information held for every overlayfs dentry */
77struct ovl_entry {
bbb1e54d 78 union {
55acc661 79 struct {
c62520a8 80 unsigned long flags;
55acc661 81 };
bbb1e54d
MS
82 struct rcu_head rcu;
83 };
84 unsigned numlower;
b9343632 85 struct ovl_path lowerstack[];
bbb1e54d
MS
86};
87
88struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
89
c62520a8
AG
90static inline struct ovl_entry *OVL_E(struct dentry *dentry)
91{
92 return (struct ovl_entry *) dentry->d_fsdata;
93}
94
13cf199d 95struct ovl_inode {
2664bd08
VG
96 union {
97 struct ovl_dir_cache *cache; /* directory */
98 struct inode *lowerdata; /* regular file */
99 };
cf31c463 100 const char *redirect;
04a01ac7 101 u64 version;
13c72075 102 unsigned long flags;
13cf199d 103 struct inode vfs_inode;
09d8b586 104 struct dentry *__upperdentry;
25b7713a 105 struct inode *lower;
a015dafc
AG
106
107 /* synchronize copy up and more */
108 struct mutex lock;
13cf199d
AG
109};
110
111static inline struct ovl_inode *OVL_I(struct inode *inode)
112{
113 return container_of(inode, struct ovl_inode, vfs_inode);
114}
09d8b586
MS
115
116static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
117{
506458ef 118 return READ_ONCE(oi->__upperdentry);
09d8b586 119}