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;
24 struct super_block *sb;
26 /* Unusable (conflicting) uuid */
28 /* Used as a lower layer (but maybe also as upper) */
33 /* ovl_free_fs() relies on @mnt being the first member! */
35 /* Trap in ovl inode cache */
38 /* Index of this layer in fs root (upper idx == 0) */
40 /* One fsid per unique underlying sb (upper fsid == 0) */
45 * ovl_free_fs() relies on @mnt being the first member when unmounting
46 * the private mounts created for each layer. Let's check both the
49 static_assert(offsetof(struct ovl_layer, mnt) == 0);
50 static_assert(__same_type(typeof_member(struct ovl_layer, mnt), struct vfsmount *));
53 const struct ovl_layer *layer;
54 struct dentry *dentry;
57 /* private information held for overlayfs's superblock */
59 unsigned int numlayer;
60 /* Number of unique fs among layers including upper fs */
62 const struct ovl_layer *layers;
64 /* workbasedir is the path at workdir= mount option */
65 struct dentry *workbasedir;
66 /* workdir is the 'work' directory under workbasedir */
67 struct dentry *workdir;
68 /* index directory listing overlay inodes by origin file handle */
69 struct dentry *indexdir;
71 /* pathnames of lower and upper dirs, for show_options */
72 struct ovl_config config;
73 /* creds of process who forced instantiation of super block */
74 const struct cred *creator_cred;
77 /* Did we take the inuse lock? */
81 /* Traps in ovl inode cache */
82 struct inode *workbasedir_trap;
83 struct inode *workdir_trap;
84 struct inode *indexdir_trap;
85 /* -1: disabled, 0: same fs, 1..32: number of unused ino bits */
87 /* For allocation of non-persistent inode numbers */
88 atomic_long_t last_ino;
89 /* Whiteout dentry cache */
90 struct dentry *whiteout;
91 /* r/o snapshot of upperdir sb's only taken on volatile mounts */
95 static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
97 return ofs->layers[0].mnt;
100 static inline struct ovl_fs *OVL_FS(struct super_block *sb)
102 return (struct ovl_fs *)sb->s_fs_info;
105 static inline bool ovl_should_sync(struct ovl_fs *ofs)
107 return !ofs->config.ovl_volatile;
110 /* private information held for every overlayfs dentry */
119 struct ovl_path lowerstack[];
122 struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
124 static inline struct ovl_entry *OVL_E(struct dentry *dentry)
126 return (struct ovl_entry *) dentry->d_fsdata;
131 struct ovl_dir_cache *cache; /* directory */
132 struct inode *lowerdata; /* regular file */
134 const char *redirect;
137 struct inode vfs_inode;
138 struct dentry *__upperdentry;
141 /* synchronize copy up and more */
145 static inline struct ovl_inode *OVL_I(struct inode *inode)
147 return container_of(inode, struct ovl_inode, vfs_inode);
150 static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
152 return READ_ONCE(oi->__upperdentry);