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) */
36 /* Trap in ovl inode cache */
39 /* Index of this layer in fs root (upper idx == 0) */
41 /* One fsid per unique underlying sb (upper fsid == 0) */
46 const struct ovl_layer *layer;
47 struct dentry *dentry;
50 /* private information held for overlayfs's superblock */
52 unsigned int numlayer;
53 /* Number of unique fs among layers including upper fs */
55 const struct ovl_layer *layers;
57 /* workbasedir is the path at workdir= mount option */
58 struct dentry *workbasedir;
59 /* workdir is the 'work' directory under workbasedir */
60 struct dentry *workdir;
61 /* index directory listing overlay inodes by origin file handle */
62 struct dentry *indexdir;
64 /* pathnames of lower and upper dirs, for show_options */
65 struct ovl_config config;
66 /* creds of process who forced instantiation of super block */
67 const struct cred *creator_cred;
70 /* Did we take the inuse lock? */
74 /* Traps in ovl inode cache */
75 struct inode *workbasedir_trap;
76 struct inode *workdir_trap;
77 struct inode *indexdir_trap;
78 /* -1: disabled, 0: same fs, 1..32: number of unused ino bits */
80 /* For allocation of non-persistent inode numbers */
81 atomic_long_t last_ino;
82 /* Whiteout dentry cache */
83 struct dentry *whiteout;
84 /* r/o snapshot of upperdir sb's only taken on volatile mounts */
88 static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
90 return ofs->layers[0].mnt;
93 static inline struct user_namespace *ovl_upper_mnt_userns(struct ovl_fs *ofs)
95 return mnt_user_ns(ovl_upper_mnt(ofs));
98 static inline struct ovl_fs *OVL_FS(struct super_block *sb)
100 return (struct ovl_fs *)sb->s_fs_info;
103 static inline bool ovl_should_sync(struct ovl_fs *ofs)
105 return !ofs->config.ovl_volatile;
108 /* private information held for every overlayfs dentry */
117 struct ovl_path lowerstack[];
120 struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
122 static inline struct ovl_entry *OVL_E(struct dentry *dentry)
124 return (struct ovl_entry *) dentry->d_fsdata;
129 struct ovl_dir_cache *cache; /* directory */
130 struct inode *lowerdata; /* regular file */
132 const char *redirect;
135 struct inode vfs_inode;
136 struct dentry *__upperdentry;
137 struct ovl_path lowerpath;
139 /* synchronize copy up and more */
143 static inline struct ovl_inode *OVL_I(struct inode *inode)
145 return container_of(inode, struct ovl_inode, vfs_inode);
148 static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
150 return READ_ONCE(oi->__upperdentry);