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