xref: /titanic_52/usr/src/uts/common/nfs/nfs4_idmap_impl.h (revision fcf3ce441efd61da9bb2884968af01cb7c1452cc)
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 #ifndef _NFS4_IDMAP_IMPL_H
28 #define	_NFS4_IDMAP_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/list.h>
33 #include <sys/door.h>
34 
35 /*
36  * This is a private header file.  Applications should not directly include
37  * this file.
38  */
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * Cache Entry Definitions
46  */
47 #define	NFSID_CACHE_ANCHORS	256
48 
49 typedef struct nfsidmap {
50 	struct nfsidmap *id_chain[2];	/* must be first */
51 	time_t		 id_time;	/* time stamp */
52 	uid_t		 id_no;		/* uid/gid */
53 	utf8string	 id_str;	/* user@domain string */
54 } nfsidmap_t;
55 
56 #define	id_forw			id_chain[0]
57 #define	id_back			id_chain[1]
58 #define	id_len			id_str.utf8string_len
59 #define	id_val			id_str.utf8string_val
60 
61 typedef struct nfsidhq {
62 	union {
63 		struct nfsidhq	*hq_head[2];	/* for empty queue */
64 		struct nfsidmap *hq_chain[2];	/* for LRU list */
65 	} hq_link;
66 	kmutex_t	hq_lock;		/* protects hash queue */
67 } nfsidhq_t;
68 
69 #define	hq_que_forw		hq_link.hq_head[0]
70 #define	hq_que_back		hq_link.hq_head[1]
71 #define	hq_lru_forw		hq_link.hq_chain[0]
72 #define	hq_lru_back		hq_link.hq_chain[1]
73 
74 typedef struct {
75 	const char	*name;		/* cache name */
76 	nfsidhq_t	*table;		/* hash table */
77 	/*
78 	 * Since we need to know the status of nfsmapid from random functions
79 	 * that deal with idmap caches, we keep a pointer to the relevant fields
80 	 * in the zone's globals so we don't have to keep passing them around.
81 	 */
82 	door_handle_t		*nfsidmap_daemon_dh;
83 } idmap_cache_info_t;
84 
85 typedef enum hash_stat { HQ_HASH_HINT, HQ_HASH_FIND } hash_stat;
86 
87 /*
88  * Per-zone modular globals
89  */
90 struct nfsidmap_globals {
91 	list_node_t		nig_link; /* linkage into global list */
92 	enum clnt_stat		nig_last_stat;	/* status of last RPC call */
93 	int			nig_msg_done;	/* have we printed a message? */
94 	idmap_cache_info_t	u2s_ci;	/* table mapping uid-to-string */
95 	idmap_cache_info_t	s2u_ci;	/* table mapping string-to-uid */
96 	idmap_cache_info_t	g2s_ci;	/* table mapping groupid-to-string */
97 	idmap_cache_info_t	s2g_ci;	/* table mapping string-to-groupid */
98 	pid_t			nfsidmap_pid;
99 	kmutex_t		nfsidmap_daemon_lock;
100 	/*
101 	 * nfsidmap_daemon_lock protects the following:
102 	 * 	nfsidmap_daemon_dh
103 	 */
104 	door_handle_t		nfsidmap_daemon_dh;
105 };
106 
107 #ifdef	__cplusplus
108 }
109 #endif
110 
111 #endif /* _NFS4_IDMAP_IMPL_H */
112