1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Copyright (C) 2011 Novell Inc.
5 * Copyright (C) 2016 Red Hat, Inc.
12 bool default_permissions;
15 const char *redirect_mode;
26 struct super_block *sb;
28 /* Unusable (conflicting) uuid */
30 /* Used as a lower layer (but maybe also as upper) */
35 /* ovl_free_fs() relies on @mnt being the first member! */
37 /* Trap in ovl inode cache */
40 /* Index of this layer in fs root (upper idx == 0) */
42 /* One fsid per unique underlying sb (upper fsid == 0) */
47 * ovl_free_fs() relies on @mnt being the first member when unmounting
48 * the private mounts created for each layer. Let's check both the
51 static_assert(offsetof(struct ovl_layer, mnt) == 0);
52 static_assert(__same_type(typeof_member(struct ovl_layer, mnt), struct vfsmount *));
55 const struct ovl_layer *layer;
56 struct dentry *dentry;
59 /* private information held for overlayfs's superblock */
61 unsigned int numlayer;
62 /* Number of unique fs among layers including upper fs */
64 const struct ovl_layer *layers;
66 /* workbasedir is the path at workdir= mount option */
67 struct dentry *workbasedir;
68 /* workdir is the 'work' directory under workbasedir */
69 struct dentry *workdir;
70 /* index directory listing overlay inodes by origin file handle */
71 struct dentry *indexdir;
73 /* pathnames of lower and upper dirs, for show_options */
74 struct ovl_config config;
75 /* creds of process who forced instantiation of super block */
76 const struct cred *creator_cred;
79 /* Did we take the inuse lock? */
83 /* Traps in ovl inode cache */
84 struct inode *workbasedir_trap;
85 struct inode *workdir_trap;
86 struct inode *indexdir_trap;
87 /* -1: disabled, 0: same fs, 1..32: number of unused ino bits */
89 /* For allocation of non-persistent inode numbers */
90 atomic_long_t last_ino;
91 /* Whiteout dentry cache */
92 struct dentry *whiteout;
93 /* r/o snapshot of upperdir sb's only taken on volatile mounts */
97 static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
99 return ofs->layers[0].mnt;
102 static inline struct ovl_fs *OVL_FS(struct super_block *sb)
104 return (struct ovl_fs *)sb->s_fs_info;
107 static inline bool ovl_should_sync(struct ovl_fs *ofs)
109 return !ofs->config.ovl_volatile;
112 /* private information held for every overlayfs dentry */
121 struct ovl_path lowerstack[];
124 struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
126 static inline struct ovl_entry *OVL_E(struct dentry *dentry)
128 return (struct ovl_entry *) dentry->d_fsdata;
133 struct ovl_dir_cache *cache; /* directory */
134 struct inode *lowerdata; /* regular file */
136 const char *redirect;
139 struct inode vfs_inode;
140 struct dentry *__upperdentry;
141 struct ovl_path lowerpath;
143 /* synchronize copy up and more */
147 static inline struct ovl_inode *OVL_I(struct inode *inode)
149 return container_of(inode, struct ovl_inode, vfs_inode);
152 static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
154 return READ_ONCE(oi->__upperdentry);