hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/overlayfs/ovl_entry.h
....@@ -1,11 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 *
34 * Copyright (C) 2011 Novell Inc.
45 * Copyright (C) 2016 Red Hat, Inc.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms of the GNU General Public License version 2 as published by
8
- * the Free Software Foundation.
96 */
107
118 struct ovl_config {
....@@ -20,15 +17,21 @@
2017 bool nfs_export;
2118 int xino;
2219 bool metacopy;
20
+ bool ovl_volatile;
2321 bool override_creds;
2422 };
2523
2624 struct ovl_sb {
2725 struct super_block *sb;
2826 dev_t pseudo_dev;
27
+ /* Unusable (conflicting) uuid */
28
+ bool bad_uuid;
29
+ /* Used as a lower layer (but maybe also as upper) */
30
+ bool is_lower;
2931 };
3032
3133 struct ovl_layer {
34
+ /* ovl_free_fs() relies on @mnt being the first member! */
3235 struct vfsmount *mnt;
3336 /* Trap in ovl inode cache */
3437 struct inode *trap;
....@@ -39,19 +42,26 @@
3942 int fsid;
4043 };
4144
45
+/*
46
+ * ovl_free_fs() relies on @mnt being the first member when unmounting
47
+ * the private mounts created for each layer. Let's check both the
48
+ * offset and type.
49
+ */
50
+static_assert(offsetof(struct ovl_layer, mnt) == 0);
51
+static_assert(__same_type(typeof_member(struct ovl_layer, mnt), struct vfsmount *));
52
+
4253 struct ovl_path {
43
- struct ovl_layer *layer;
54
+ const struct ovl_layer *layer;
4455 struct dentry *dentry;
4556 };
4657
4758 /* private information held for overlayfs's superblock */
4859 struct ovl_fs {
49
- struct vfsmount *upper_mnt;
50
- unsigned int numlower;
51
- /* Number of unique lower sb that differ from upper sb */
52
- unsigned int numlowerfs;
53
- struct ovl_layer *lower_layers;
54
- struct ovl_sb *lower_fs;
60
+ unsigned int numlayer;
61
+ /* Number of unique fs among layers including upper fs */
62
+ unsigned int numfs;
63
+ const struct ovl_layer *layers;
64
+ struct ovl_sb *fs;
5565 /* workbasedir is the path at workdir= mount option */
5666 struct dentry *workbasedir;
5767 /* workdir is the 'work' directory under workbasedir */
....@@ -68,15 +78,36 @@
6878 /* Did we take the inuse lock? */
6979 bool upperdir_locked;
7080 bool workdir_locked;
81
+ bool share_whiteout;
7182 /* Traps in ovl inode cache */
72
- struct inode *upperdir_trap;
7383 struct inode *workbasedir_trap;
7484 struct inode *workdir_trap;
7585 struct inode *indexdir_trap;
76
- /* Inode numbers in all layers do not use the high xino_bits */
77
- unsigned int xino_bits;
86
+ /* -1: disabled, 0: same fs, 1..32: number of unused ino bits */
87
+ int xino_mode;
88
+ /* For allocation of non-persistent inode numbers */
89
+ atomic_long_t last_ino;
90
+ /* Whiteout dentry cache */
91
+ struct dentry *whiteout;
92
+ /* r/o snapshot of upperdir sb's only taken on volatile mounts */
93
+ errseq_t errseq;
7894 };
7995
96
+static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
97
+{
98
+ return ofs->layers[0].mnt;
99
+}
100
+
101
+static inline struct ovl_fs *OVL_FS(struct super_block *sb)
102
+{
103
+ return (struct ovl_fs *)sb->s_fs_info;
104
+}
105
+
106
+static inline bool ovl_should_sync(struct ovl_fs *ofs)
107
+{
108
+ return !ofs->config.ovl_volatile;
109
+}
110
+
80111 /* private information held for every overlayfs dentry */
81112 struct ovl_entry {
82113 union {