xref: /titanic_41/usr/src/uts/common/sys/fs/lofs_info.h (revision 989f28072d20c73ae0955d6a1e3e2fc74831cb39)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * Loopback mount info - one per mount
28  */
29 
30 #ifndef _SYS_FS_LOFS_INFO_H
31 #define	_SYS_FS_LOFS_INFO_H
32 
33 #ifdef _KERNEL
34 #include <sys/vfs_opreg.h>
35 #endif
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 struct lnode;
42 
43 struct lobucket {
44 	kmutex_t	lh_lock;	/* lock protecting bucket contents */
45 	struct lnode	*lh_chain;	/* vnode chain for this bucket */
46 	uint_t		lh_count;	/* Number of vnodes in chain */
47 	/* Pad up to 64-byte boundary to avoid false sharing */
48 #ifdef _LP64
49 	char		_pad[44];
50 #else
51 	char		_pad[48];
52 #endif
53 };
54 
55 struct lo_retired_ht {
56 	struct lo_retired_ht	*lrh_next;
57 	struct lobucket		*lrh_table;
58 	uint_t			lrh_size;
59 };
60 
61 struct loinfo {
62 	struct vfs	*li_realvfs;	/* real vfs of mount */
63 	struct vfs	*li_mountvfs;	/* loopback vfs */
64 	struct vnode	*li_rootvp;	/* root vnode of this vfs */
65 	int		 li_mflag;	/* mount flags to inherit */
66 	int		 li_dflag;	/* mount flags to not inherit */
67 	uint_t		 li_refct;	/* # outstanding vnodes */
68 	volatile uint_t	 li_htsize;	/* # buckets in hashtable */
69 	struct lobucket *volatile li_hashtable; /* table of per-mount vnodes */
70 	struct lfsnode	*li_lfs;	/* list of other vfss */
71 	kmutex_t	 li_lfslock;	/* lock protecting li_lfs */
72 	kmutex_t	 li_htlock;	/* protect hashtable, htsize, retired */
73 	struct lo_retired_ht *li_retired; /* list of retired hashtables */
74 	int		 li_flag;	/* filesystem behavior flags */
75 };
76 
77 /* inheritable mount flags - propagated from real vfs to loopback */
78 #define	INHERIT_VFS_FLAG	\
79 	(VFS_RDONLY|VFS_NOSETUID|VFS_NODEVICES|VFS_XATTR|VFS_NBMAND|VFS_NOEXEC)
80 
81 /*
82  * "nosub" is used to provide NFS server-like semantics for lo_lookup(): never
83  * traverse mount points for sub-mounts.  The lookup will instead look under
84  * the mount point.
85  */
86 #define	MNTOPT_LOFS_NOSUB	"nosub"
87 #define	MNTOPT_LOFS_SUB		"sub"
88 
89 /*
90  * Flag values (for li_flag)
91  */
92 #define	LO_NOSUB	0x02	/* don't traverse sub-mounts */
93 
94 /*
95  * lfsnodes are allocated as new real vfs's are encountered
96  * when looking up things in a loopback name space
97  * It contains a new vfs which is paired with the real vfs
98  * so that vfs ops (fsstat) can get to the correct real vfs
99  * given just a loopback vfs
100  */
101 struct lfsnode {
102 	struct lfsnode	*lfs_next;	/* next in loinfo list */
103 	struct vfs	*lfs_realvfs;	/* real vfs */
104 	struct vnode    *lfs_realrootvp; /* real root vp */
105 	struct vfs	 lfs_vfs;	/* new loopback vfs */
106 };
107 
108 #define	vtoli(VFSP)	((struct loinfo *)((VFSP)->vfs_data))
109 
110 #ifdef _KERNEL
111 extern struct vfs *lo_realvfs(struct vfs *, struct vnode **);
112 extern void lofs_subrinit(void);
113 extern void lofs_subrfini(void);
114 
115 extern void lsetup(struct loinfo *, uint_t);
116 extern void ldestroy(struct loinfo *);
117 
118 extern const struct fs_operation_def lo_vnodeops_template[];
119 
120 extern struct vnodeops *lo_vnodeops;
121 extern vfsops_t *lo_vfsops;
122 extern struct mod_ops mod_fsops;
123 
124 #endif /* _KERNEL */
125 
126 
127 #ifdef	__cplusplus
128 }
129 #endif
130 
131 #endif	/* _SYS_FS_LOFS_INFO_H */
132