| .. | .. |
|---|
| 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 { |
|---|
| .. | .. |
|---|
| 40 | 42 | }; |
|---|
| 41 | 43 | |
|---|
| 42 | 44 | struct ovl_path { |
|---|
| 43 | | - struct ovl_layer *layer; |
|---|
| 45 | + const struct ovl_layer *layer; |
|---|
| 44 | 46 | struct dentry *dentry; |
|---|
| 45 | 47 | }; |
|---|
| 46 | 48 | |
|---|
| 47 | 49 | /* private information held for overlayfs's superblock */ |
|---|
| 48 | 50 | 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; |
|---|
| 51 | + unsigned int numlayer; |
|---|
| 52 | + /* Number of unique fs among layers including upper fs */ |
|---|
| 53 | + unsigned int numfs; |
|---|
| 54 | + const struct ovl_layer *layers; |
|---|
| 55 | + struct ovl_sb *fs; |
|---|
| 55 | 56 | /* workbasedir is the path at workdir= mount option */ |
|---|
| 56 | 57 | struct dentry *workbasedir; |
|---|
| 57 | 58 | /* workdir is the 'work' directory under workbasedir */ |
|---|
| .. | .. |
|---|
| 68 | 69 | /* Did we take the inuse lock? */ |
|---|
| 69 | 70 | bool upperdir_locked; |
|---|
| 70 | 71 | bool workdir_locked; |
|---|
| 72 | + bool share_whiteout; |
|---|
| 71 | 73 | /* Traps in ovl inode cache */ |
|---|
| 72 | | - struct inode *upperdir_trap; |
|---|
| 73 | 74 | struct inode *workbasedir_trap; |
|---|
| 74 | 75 | struct inode *workdir_trap; |
|---|
| 75 | 76 | struct inode *indexdir_trap; |
|---|
| 76 | | - /* Inode numbers in all layers do not use the high xino_bits */ |
|---|
| 77 | | - unsigned int xino_bits; |
|---|
| 77 | + /* -1: disabled, 0: same fs, 1..32: number of unused ino bits */ |
|---|
| 78 | + int xino_mode; |
|---|
| 79 | + /* For allocation of non-persistent inode numbers */ |
|---|
| 80 | + atomic_long_t last_ino; |
|---|
| 81 | + /* Whiteout dentry cache */ |
|---|
| 82 | + struct dentry *whiteout; |
|---|
| 83 | + /* r/o snapshot of upperdir sb's only taken on volatile mounts */ |
|---|
| 84 | + errseq_t errseq; |
|---|
| 78 | 85 | }; |
|---|
| 79 | 86 | |
|---|
| 87 | +static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs) |
|---|
| 88 | +{ |
|---|
| 89 | + return ofs->layers[0].mnt; |
|---|
| 90 | +} |
|---|
| 91 | + |
|---|
| 92 | +static inline struct ovl_fs *OVL_FS(struct super_block *sb) |
|---|
| 93 | +{ |
|---|
| 94 | + return (struct ovl_fs *)sb->s_fs_info; |
|---|
| 95 | +} |
|---|
| 96 | + |
|---|
| 97 | +static inline bool ovl_should_sync(struct ovl_fs *ofs) |
|---|
| 98 | +{ |
|---|
| 99 | + return !ofs->config.ovl_volatile; |
|---|
| 100 | +} |
|---|
| 101 | + |
|---|
| 80 | 102 | /* private information held for every overlayfs dentry */ |
|---|
| 81 | 103 | struct ovl_entry { |
|---|
| 82 | 104 | union { |
|---|