Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2011 Novell Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2016 Red Hat, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) struct ovl_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 	char *lowerdir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 	char *upperdir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 	char *workdir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 	bool default_permissions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	bool redirect_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	bool redirect_follow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	const char *redirect_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	bool index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	bool nfs_export;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	int xino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	bool metacopy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	bool ovl_volatile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	bool override_creds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) struct ovl_sb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	struct super_block *sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	dev_t pseudo_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	/* Unusable (conflicting) uuid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	bool bad_uuid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	/* Used as a lower layer (but maybe also as upper) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	bool is_lower;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) struct ovl_layer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct vfsmount *mnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	/* Trap in ovl inode cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct inode *trap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct ovl_sb *fs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	/* Index of this layer in fs root (upper idx == 0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	/* One fsid per unique underlying sb (upper fsid == 0) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	int fsid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) struct ovl_path {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	const struct ovl_layer *layer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	struct dentry *dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /* private information held for overlayfs's superblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) struct ovl_fs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	unsigned int numlayer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	/* Number of unique fs among layers including upper fs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	unsigned int numfs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	const struct ovl_layer *layers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	struct ovl_sb *fs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	/* workbasedir is the path at workdir= mount option */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct dentry *workbasedir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	/* workdir is the 'work' directory under workbasedir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct dentry *workdir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	/* index directory listing overlay inodes by origin file handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	struct dentry *indexdir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	long namelen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	/* pathnames of lower and upper dirs, for show_options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	struct ovl_config config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	/* creds of process who forced instantiation of super block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	const struct cred *creator_cred;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	bool tmpfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	bool noxattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	/* Did we take the inuse lock? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	bool upperdir_locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	bool workdir_locked;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	bool share_whiteout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	/* Traps in ovl inode cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	struct inode *workbasedir_trap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct inode *workdir_trap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct inode *indexdir_trap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	/* -1: disabled, 0: same fs, 1..32: number of unused ino bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	int xino_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	/* For allocation of non-persistent inode numbers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	atomic_long_t last_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	/* Whiteout dentry cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	struct dentry *whiteout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	/* r/o snapshot of upperdir sb's only taken on volatile mounts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	errseq_t errseq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	return ofs->layers[0].mnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) static inline struct ovl_fs *OVL_FS(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	return (struct ovl_fs *)sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static inline bool ovl_should_sync(struct ovl_fs *ofs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return !ofs->config.ovl_volatile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /* private information held for every overlayfs dentry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct ovl_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	unsigned numlower;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	struct ovl_path lowerstack[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct ovl_entry *ovl_alloc_entry(unsigned int numlower);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static inline struct ovl_entry *OVL_E(struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	return (struct ovl_entry *) dentry->d_fsdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct ovl_inode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		struct ovl_dir_cache *cache;	/* directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		struct inode *lowerdata;	/* regular file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	const char *redirect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	u64 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	struct dentry *__upperdentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	struct inode *lower;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	/* synchronize copy up and more */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static inline struct ovl_inode *OVL_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	return container_of(inode, struct ovl_inode, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static inline struct dentry *ovl_upperdentry_dereference(struct ovl_inode *oi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	return READ_ONCE(oi->__upperdentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }