xref: /titanic_50/usr/src/uts/common/sys/fs/lofs_info.h (revision e5dcf7beb7c949f9234713d5818b581ec3825443)
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 2006 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 struct lnode;
40 
41 struct lobucket {
42 	kmutex_t	lh_lock;	/* lock protecting bucket contents */
43 	struct lnode	*lh_chain;	/* vnode chain for this bucket */
44 	uint_t		lh_count;	/* Number of vnodes in chain */
45 	/* Pad up to 64-byte boundary to avoid false sharing */
46 #ifdef _LP64
47 	char		_pad[44];
48 #else
49 	char		_pad[48];
50 #endif
51 };
52 
53 struct lo_retired_ht {
54 	struct lo_retired_ht	*lrh_next;
55 	struct lobucket		*lrh_table;
56 	uint_t			lrh_size;
57 };
58 
59 struct loinfo {
60 	struct vfs	*li_realvfs;	/* real vfs of mount */
61 	struct vfs	*li_mountvfs;	/* loopback vfs */
62 	struct vnode	*li_rootvp;	/* root vnode of this vfs */
63 	int		 li_mflag;	/* mount flags to inherit */
64 	int		 li_dflag;	/* mount flags to not inherit */
65 	uint_t		 li_refct;	/* # outstanding vnodes */
66 	volatile uint_t	 li_htsize;	/* # buckets in hashtable */
67 	struct lobucket *volatile li_hashtable; /* table of per-mount vnodes */
68 	struct lfsnode	*li_lfs;	/* list of other vfss */
69 	kmutex_t	 li_lfslock;	/* lock protecting li_lfs */
70 	kmutex_t	 li_htlock;	/* protect hashtable, htsize, retired */
71 	struct lo_retired_ht *li_retired; /* list of retired hashtables */
72 	int		 li_flag;	/* filesystem behavior flags */
73 };
74 
75 /* inheritable mount flags - propagated from real vfs to loopback */
76 #define	INHERIT_VFS_FLAG	\
77 	(VFS_RDONLY|VFS_NOSETUID|VFS_NODEVICES|VFS_XATTR|VFS_NBMAND|VFS_NOEXEC)
78 
79 /*
80  * "nosub" is used to provide NFS server-like semantics for lo_lookup(): never
81  * traverse mount points for sub-mounts.  The lookup will instead look under
82  * the mount point.
83  */
84 #define	MNTOPT_LOFS_NOSUB	"nosub"
85 #define	MNTOPT_LOFS_SUB		"sub"
86 
87 /*
88  * Flag values (for li_flag)
89  */
90 #define	LO_NOSUB	0x02	/* don't traverse sub-mounts */
91 
92 /*
93  * lfsnodes are allocated as new real vfs's are encountered
94  * when looking up things in a loopback name space
95  * It contains a new vfs which is paired with the real vfs
96  * so that vfs ops (fsstat) can get to the correct real vfs
97  * given just a loopback vfs
98  */
99 struct lfsnode {
100 	struct lfsnode	*lfs_next;	/* next in loinfo list */
101 	struct vfs	*lfs_realvfs;	/* real vfs */
102 	struct vnode    *lfs_realrootvp; /* real root vp */
103 	struct vfs	 lfs_vfs;	/* new loopback vfs */
104 };
105 
106 #define	vtoli(VFSP)	((struct loinfo *)((VFSP)->vfs_data))
107 
108 #ifdef _KERNEL
109 extern struct vfs *lo_realvfs(struct vfs *, struct vnode **);
110 extern void lofs_subrinit(void);
111 extern void lofs_subrfini(void);
112 
113 extern void lsetup(struct loinfo *, uint_t);
114 extern void ldestroy(struct loinfo *);
115 
116 extern const struct fs_operation_def lo_vnodeops_template[];
117 
118 extern struct vnodeops *lo_vnodeops;
119 extern vfsops_t *lo_vfsops;
120 extern struct mod_ops mod_fsops;
121 
122 #endif /* _KERNEL */
123 
124 
125 #ifdef	__cplusplus
126 }
127 #endif
128 
129 #endif	/* _SYS_FS_LOFS_INFO_H */
130