| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2011 Novell Inc. |
|---|
| 4 | 5 | * 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. |
|---|
| 9 | 6 | */ |
|---|
| 10 | 7 | |
|---|
| 11 | 8 | struct ovl_config { |
|---|
| .. | .. |
|---|
| 20 | 17 | bool nfs_export; |
|---|
| 21 | 18 | int xino; |
|---|
| 22 | 19 | bool metacopy; |
|---|
| 20 | + bool ovl_volatile; |
|---|
| 23 | 21 | bool override_creds; |
|---|
| 24 | 22 | }; |
|---|
| 25 | 23 | |
|---|
| 26 | 24 | struct ovl_sb { |
|---|
| 27 | 25 | struct super_block *sb; |
|---|
| 28 | 26 | 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; |
|---|
| 29 | 31 | }; |
|---|
| 30 | 32 | |
|---|
| 31 | 33 | struct ovl_layer { |
|---|
| 34 | + /* ovl_free_fs() relies on @mnt being the first member! */ |
|---|
| 32 | 35 | struct vfsmount *mnt; |
|---|
| 33 | 36 | /* Trap in ovl inode cache */ |
|---|
| 34 | 37 | struct inode *trap; |
|---|
| .. | .. |
|---|
| 39 | 42 | int fsid; |
|---|
| 40 | 43 | }; |
|---|
| 41 | 44 | |
|---|
| 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 | + |
|---|
| 42 | 53 | struct ovl_path { |
|---|
| 43 | | - struct ovl_layer *layer; |
|---|
| 54 | + const struct ovl_layer *layer; |
|---|
| 44 | 55 | struct dentry *dentry; |
|---|
| 45 | 56 | }; |
|---|
| 46 | 57 | |
|---|
| 47 | 58 | /* private information held for overlayfs's superblock */ |
|---|
| 48 | 59 | 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; |
|---|
| 55 | 65 | /* workbasedir is the path at workdir= mount option */ |
|---|
| 56 | 66 | struct dentry *workbasedir; |
|---|
| 57 | 67 | /* workdir is the 'work' directory under workbasedir */ |
|---|
| .. | .. |
|---|
| 68 | 78 | /* Did we take the inuse lock? */ |
|---|
| 69 | 79 | bool upperdir_locked; |
|---|
| 70 | 80 | bool workdir_locked; |
|---|
| 81 | + bool share_whiteout; |
|---|
| 71 | 82 | /* Traps in ovl inode cache */ |
|---|
| 72 | | - struct inode *upperdir_trap; |
|---|
| 73 | 83 | struct inode *workbasedir_trap; |
|---|
| 74 | 84 | struct inode *workdir_trap; |
|---|
| 75 | 85 | 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; |
|---|
| 78 | 94 | }; |
|---|
| 79 | 95 | |
|---|
| 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 | + |
|---|
| 80 | 111 | /* private information held for every overlayfs dentry */ |
|---|
| 81 | 112 | struct ovl_entry { |
|---|
| 82 | 113 | union { |
|---|