xref: /titanic_52/usr/src/uts/common/sys/fs/lofs_info.h (revision 1a4cea1bca45d5775aeb88646a63db027947246f)
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|\
80 	VFS_NOEXEC|VFS_NOFOLLOW)
81 
82 /*
83  * "nosub" is used to provide NFS server-like semantics for lo_lookup(): never
84  * traverse mount points for sub-mounts.  The lookup will instead look under
85  * the mount point.
86  */
87 #define	MNTOPT_LOFS_NOSUB	"nosub"
88 #define	MNTOPT_LOFS_SUB		"sub"
89 
90 /*
91  * Flag values (for li_flag)
92  */
93 #define	LO_NOSUB	0x02	/* don't traverse sub-mounts */
94 
95 /*
96  * lfsnodes are allocated as new real vfs's are encountered
97  * when looking up things in a loopback name space
98  * It contains a new vfs which is paired with the real vfs
99  * so that vfs ops (fsstat) can get to the correct real vfs
100  * given just a loopback vfs
101  */
102 struct lfsnode {
103 	struct lfsnode	*lfs_next;	/* next in loinfo list */
104 	struct vfs	*lfs_realvfs;	/* real vfs */
105 	struct vnode    *lfs_realrootvp; /* real root vp */
106 	struct vfs	 lfs_vfs;	/* new loopback vfs */
107 };
108 
109 #define	vtoli(VFSP)	((struct loinfo *)((VFSP)->vfs_data))
110 
111 #ifdef _KERNEL
112 extern struct vfs *lo_realvfs(struct vfs *, struct vnode **);
113 extern void lofs_subrinit(void);
114 extern void lofs_subrfini(void);
115 
116 extern void lsetup(struct loinfo *, uint_t);
117 extern void ldestroy(struct loinfo *);
118 
119 extern const struct fs_operation_def lo_vnodeops_template[];
120 
121 extern struct vnodeops *lo_vnodeops;
122 extern vfsops_t *lo_vfsops;
123 extern struct mod_ops mod_fsops;
124 
125 #endif /* _KERNEL */
126 
127 
128 #ifdef	__cplusplus
129 }
130 #endif
131 
132 #endif	/* _SYS_FS_LOFS_INFO_H */
133