summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/fs/lofs_info.h
blob: f06e13774eef16e8b9905af9865e8daac3f30809 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

/*
 * Loopback mount info - one per mount
 */

#ifndef _SYS_FS_LOFS_INFO_H
#define	_SYS_FS_LOFS_INFO_H

#ifdef _KERNEL
#include <sys/vfs_opreg.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif

struct lnode;

struct lobucket {
	kmutex_t	lh_lock;	/* lock protecting bucket contents */
	struct lnode	*lh_chain;	/* vnode chain for this bucket */
	uint_t		lh_count;	/* Number of vnodes in chain */
	/* Pad up to 64-byte boundary to avoid false sharing */
#ifdef _LP64
	char		_pad[44];
#else
	char		_pad[48];
#endif
};

struct lo_retired_ht {
	struct lo_retired_ht	*lrh_next;
	struct lobucket		*lrh_table;
	uint_t			lrh_size;
};

struct loinfo {
	struct vfs	*li_realvfs;	/* real vfs of mount */
	struct vfs	*li_mountvfs;	/* loopback vfs */
	struct vnode	*li_rootvp;	/* root vnode of this vfs */
	int		 li_mflag;	/* mount flags to inherit */
	int		 li_dflag;	/* mount flags to not inherit */
	uint_t		 li_refct;	/* # outstanding vnodes */
	volatile uint_t	 li_htsize;	/* # buckets in hashtable */
	struct lobucket *volatile li_hashtable; /* table of per-mount vnodes */
	struct lfsnode	*li_lfs;	/* list of other vfss */
	kmutex_t	 li_lfslock;	/* lock protecting li_lfs */
	kmutex_t	 li_htlock;	/* protect hashtable, htsize, retired */
	struct lo_retired_ht *li_retired; /* list of retired hashtables */
	int		 li_flag;	/* filesystem behavior flags */
};

/* inheritable mount flags - propagated from real vfs to loopback */
#define	INHERIT_VFS_FLAG	\
	(VFS_RDONLY|VFS_NOSETUID|VFS_NODEVICES|VFS_XATTR|VFS_NBMAND|VFS_NOEXEC)

/*
 * "nosub" is used to provide NFS server-like semantics for lo_lookup(): never
 * traverse mount points for sub-mounts.  The lookup will instead look under
 * the mount point.
 */
#define	MNTOPT_LOFS_NOSUB	"nosub"
#define	MNTOPT_LOFS_SUB		"sub"

/*
 * Flag values (for li_flag)
 */
#define	LO_NOSUB	0x02	/* don't traverse sub-mounts */

/*
 * lfsnodes are allocated as new real vfs's are encountered
 * when looking up things in a loopback name space
 * It contains a new vfs which is paired with the real vfs
 * so that vfs ops (fsstat) can get to the correct real vfs
 * given just a loopback vfs
 */
struct lfsnode {
	struct lfsnode	*lfs_next;	/* next in loinfo list */
	struct vfs	*lfs_realvfs;	/* real vfs */
	struct vnode    *lfs_realrootvp; /* real root vp */
	struct vfs	 lfs_vfs;	/* new loopback vfs */
};

#define	vtoli(VFSP)	((struct loinfo *)((VFSP)->vfs_data))

#ifdef _KERNEL
extern struct vfs *lo_realvfs(struct vfs *, struct vnode **);
extern void lofs_subrinit(void);
extern void lofs_subrfini(void);

extern void lsetup(struct loinfo *, uint_t);
extern void ldestroy(struct loinfo *);

extern const struct fs_operation_def lo_vnodeops_template[];

extern struct vnodeops *lo_vnodeops;
extern vfsops_t *lo_vfsops;
extern struct mod_ops mod_fsops;

#endif /* _KERNEL */


#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_FS_LOFS_INFO_H */