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;
25 struct super_block *sb;
27 /* Unusable (conflicting) uuid */
29 /* Used as a lower layer (but maybe also as upper) */
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 const struct ovl_layer *layer;
46 struct dentry *dentry;
49 /* private information held for overlayfs's superblock */
51 unsigned int numlayer;
52 /* Number of unique fs among layers including upper fs */
54 const struct ovl_layer *layers;
56 /* workbasedir is the path at workdir= mount option */
57 struct dentry *workbasedir;
58 /* workdir is the 'work' directory under workbasedir */
59 struct dentry *workdir;
60 /* index directory listing overlay inodes by origin file handle */
61 struct dentry *indexdir;
63 /* pathnames of lower and upper dirs, for show_options */
64 struct ovl_config config;
65 /* creds of process who forced instantiation of super block */
66 const struct cred *creator_cred;
69 /* Did we take the inuse lock? */
73 /* Traps in ovl inode cache */
74 struct inode *workbasedir_trap;
75 struct inode *workdir_trap;
76 struct inode *indexdir_trap;
77 /* -1: disabled, 0: same fs, 1..32: number of unused ino bits */
79 /* For allocation of non-persistent inode numbers */
80 atomic_long_t last_ino;
81 /* Whiteout dentry cache */
82 struct dentry *whiteout;
85 static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
87 return ofs->layers[0].mnt;
90 static inline struct ovl_fs *OVL_FS(struct super_block *sb)
92 return (struct ovl_fs *)sb->s_fs_info;
95 static inline bool ovl_should_sync(struct ovl_fs *ofs)
97 return !ofs->config.ovl_volatile;
100 /* private information held for every overlayfs dentry */
109 struct ovl_path lowerstack[];
112 struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
114 static inline struct ovl_entry *OVL_E(struct dentry *dentry)
116 return (struct ovl_entry *) dentry->d_fsdata;
121 struct ovl_dir_cache *cache; /* directory */
122 struct inode *lowerdata; /* regular file */
124 const char *redirect;
127 struct inode vfs_inode;
128 struct dentry *__upperdentry;
131 /* synchronize copy up and more */
135 static inline struct ovl_inode *OVL_I(struct inode *inode)
137 return container_of(inode, struct ovl_inode, vfs_inode);
140 static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
142 return READ_ONCE(oi->__upperdentry);