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 /*
23 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
24 */
25
26 /*
27 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
29 */
30
31 #ifndef _NFS4_H
32 #define _NFS4_H
33
34 #include <sys/types.h>
35 #include <sys/vnode.h>
36 #include <sys/fem.h>
37 #include <rpc/rpc.h>
38 #include <nfs/nfs.h>
39
40 #ifdef _KERNEL
41 #include <nfs/nfs4_kprot.h>
42 #include <sys/nvpair.h>
43 #else
44 #include <rpcsvc/nfs4_prot.h>
45 #endif
46 #include <nfs/nfs4_attr.h>
47 #include <sys/acl.h>
48 #include <sys/list.h>
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 #define NFS4_MAX_SECOID4 65536
55 #define NFS4_MAX_UTF8STRING 65536
56 #define NFS4_MAX_LINKTEXT4 65536
57 #define NFS4_MAX_PATHNAME4 65536
58
59 struct nfs_fsl_info {
60 uint_t netbuf_len;
61 uint_t netnm_len;
102 *
103 * The basic structure at this level is that the server maintains a
104 * global "database" which consists of a set of tables. Each table
105 * contains a set of like data structures. Each table is indexed by
106 * at least one hash function and in most cases two hashes. Each
107 * table's characteristics is set when it is created at run-time via
108 * rfs4_table_create(). All table creation and related functions are
109 * located in nfs4_state.c. The generic database functionality is
110 * located in nfs4_db.c.
111 */
112
113 typedef struct rfs4_dbe rfs4_dbe_t; /* basic opaque db entry */
114 typedef struct rfs4_table rfs4_table_t; /* basic table type */
115 typedef struct rfs4_index rfs4_index_t; /* index */
116 typedef struct rfs4_database rfs4_database_t; /* and database */
117
118 typedef struct { /* opaque entry type for later use */
119 rfs4_dbe_t *dbe;
120 } *rfs4_entry_t;
121
122 extern rfs4_table_t *rfs4_client_tab;
123
124 /* database, table, index creation entry points */
125 extern rfs4_database_t *rfs4_database_create(uint32_t);
126 extern void rfs4_database_shutdown(rfs4_database_t *);
127 extern void rfs4_database_destroy(rfs4_database_t *);
128
129 extern void rfs4_database_destroy(rfs4_database_t *);
130
131 extern rfs4_table_t *rfs4_table_create(rfs4_database_t *, char *,
132 time_t, uint32_t,
133 bool_t (*create)(rfs4_entry_t, void *),
134 void (*destroy)(rfs4_entry_t),
135 bool_t (*expiry)(rfs4_entry_t),
136 uint32_t, uint32_t, uint32_t, id_t);
137 extern void rfs4_table_destroy(rfs4_database_t *, rfs4_table_t *);
138 extern rfs4_index_t *rfs4_index_create(rfs4_table_t *, char *,
139 uint32_t (*hash)(void *),
140 bool_t (compare)(rfs4_entry_t, void *),
141 void *(*mkkey)(rfs4_entry_t), bool_t);
142 extern void rfs4_index_destroy(rfs4_index_t *);
143
144 /* Type used to direct rfs4_dbsearch() in what types of records to inspect */
145 typedef enum {RFS4_DBS_VALID, RFS4_DBS_INVALID} rfs4_dbsearch_type_t;
146 /* search and db entry manipulation entry points */
147 extern rfs4_entry_t rfs4_dbsearch(rfs4_index_t *, void *,
148 bool_t *, void *, rfs4_dbsearch_type_t);
149 extern void rfs4_dbe_lock(rfs4_dbe_t *);
150 extern void rfs4_dbe_unlock(rfs4_dbe_t *);
352 struct rfs4_servinst *next;
353 struct rfs4_servinst *prev;
354 } rfs4_servinst_t;
355
356 /*
357 * DSS: distributed stable storage
358 */
359
360 typedef struct rfs4_dss_path {
361 struct rfs4_dss_path *next; /* for insque/remque */
362 struct rfs4_dss_path *prev; /* for insque/remque */
363 char *path;
364 struct rfs4_servinst *sip;
365 unsigned index; /* offset in servinst's array */
366 } rfs4_dss_path_t;
367
368 /* array of paths passed-in from nfsd command-line; stored in nvlist */
369 char **rfs4_dss_newpaths;
370 uint_t rfs4_dss_numnewpaths;
371
372 /*
373 * Circular doubly-linked list of paths for currently-served RGs.
374 * No locking required: only changed on warmstart. Managed with insque/remque.
375 */
376 rfs4_dss_path_t *rfs4_dss_pathlist;
377
378 /* nvlists of all DSS paths: current, and before last warmstart */
379 nvlist_t *rfs4_dss_paths, *rfs4_dss_oldpaths;
380
381 /*
382 * The server maintains a set of state on a per client basis that
383 * matches that of the protocol requirements. A client's state is
384 * rooted with the rfs4_client_t struct of which there is one per
385 * client and is created when SETCLIENTID/SETCLIENTID_CONFIRM are
386 * received. From there, the server then creates rfs4_openowner_t
387 * structs for each new open owner from that client and are initiated
388 * at OPEN/OPEN_CONFIRM (when the open owner is new to the server).
389 * At OPEN, at least two other structures are created, and potentially a
390 * third. rfs4_state_t is created to track the association between an
391 * open owner and a particular file. An rfs4_file_t struct may be
392 * created (if the file is not already open) at OPEN as well. The
393 * rfs4_file_t struct is the only one that is per server and not per
394 * client. The rfs4_deleg_state_t struct is created in the
395 * instance that the server is going to provide a delegation for the
396 * file being OPENed. Finally, the rfs4_lockowner_t is created at the
397 * first use of a lock owner at the server and is a result of the LOCK
723 * lock may or may not be held for lock/unlock of file_rwlock.
724 * As mentioned above, the file_rwlock is used for serialization
725 * of file removal and more specifically reference to the held
726 * vnode (e.g. vp).
727 */
728 typedef struct rfs4_file {
729 rfs4_dbe_t *rf_dbe;
730 vnode_t *rf_vp;
731 nfs_fh4 rf_filehandle;
732 list_t rf_delegstatelist;
733 rfs4_dinfo_t rf_dinfo;
734 uint32_t rf_share_deny;
735 uint32_t rf_share_access;
736 uint32_t rf_access_read;
737 uint32_t rf_access_write;
738 uint32_t rf_deny_read;
739 uint32_t rf_deny_write;
740 krwlock_t rf_file_rwlock;
741 } rfs4_file_t;
742
743 extern int rfs4_seen_first_compound; /* set first time we see one */
744
745 extern rfs4_servinst_t *rfs4_cur_servinst; /* current server instance */
746 extern kmutex_t rfs4_servinst_lock; /* protects linked list */
747 extern void rfs4_servinst_create(int, int, char **);
748 extern void rfs4_servinst_destroy_all(void);
749 extern void rfs4_servinst_assign(rfs4_client_t *,
750 rfs4_servinst_t *);
751 extern rfs4_servinst_t *rfs4_servinst(rfs4_client_t *);
752 extern int rfs4_clnt_in_grace(rfs4_client_t *);
753 extern int rfs4_servinst_in_grace(rfs4_servinst_t *);
754 extern int rfs4_servinst_grace_new(rfs4_servinst_t *);
755 extern void rfs4_grace_start(rfs4_servinst_t *);
756 extern void rfs4_grace_start_new(void);
757 extern void rfs4_grace_reset_all(void);
758 extern void rfs4_ss_oldstate(rfs4_oldstate_t *, char *, char *);
759 extern void rfs4_dss_readstate(int, char **);
760
761 /*
762 * rfs4_deleg_policy is used to signify the server's global delegation
763 * policy. The default is to NEVER delegate files and the
764 * administrator must configure the server to enable delegations.
765 *
766 * The disable/enable delegation functions are used to eliminate a
767 * race with exclusive creates.
768 */
769 typedef enum {
770 SRV_NEVER_DELEGATE = 0,
771 SRV_NORMAL_DELEGATE = 1
772 } srv_deleg_policy_t;
773
774 extern srv_deleg_policy_t rfs4_deleg_policy;
775 extern kmutex_t rfs4_deleg_lock;
776 extern void rfs4_disable_delegation(void), rfs4_enable_delegation(void);
777
778 /*
779 * Request types for delegation. These correspond with
780 * open_delegation_type4 with the addition of a new value, DELEG_ANY,
781 * to reqequest any delegation.
782 */
783 typedef enum {
784 DELEG_NONE = 0, /* Corresponds to OPEN_DELEG_NONE */
785 DELEG_READ = 1, /* Corresponds to OPEN_DELEG_READ */
786 DELEG_WRITE = 2, /* Corresponds to OPEN_DELEG_WRITE */
787 DELEG_ANY = -1 /* New value to request any delegation type */
788 } delegreq_t;
789
790 #define NFS4_DELEG4TYPE2REQTYPE(x) (delegreq_t)(x)
791
792 /*
793 * Various interfaces to manipulate the state structures introduced
794 * above
795 */
796 extern kmutex_t rfs4_state_lock;
797 extern void rfs4_clean_state_exi(struct exportinfo *exi);
798 extern void rfs4_free_reply(nfs_resop4 *);
799 extern void rfs4_copy_reply(nfs_resop4 *, nfs_resop4 *);
800
801 /* rfs4_client_t handling */
802 extern rfs4_client_t *rfs4_findclient(nfs_client_id4 *,
803 bool_t *, rfs4_client_t *);
804 extern rfs4_client_t *rfs4_findclient_by_id(clientid4, bool_t);
805 extern rfs4_client_t *rfs4_findclient_by_addr(struct sockaddr *);
806 extern void rfs4_client_rele(rfs4_client_t *);
807 extern void rfs4_client_close(rfs4_client_t *);
808 extern void rfs4_client_state_remove(rfs4_client_t *);
809 extern void rfs4_client_scv_next(rfs4_client_t *);
810 extern void rfs4_update_lease(rfs4_client_t *);
811 extern bool_t rfs4_lease_expired(rfs4_client_t *);
812 extern nfsstat4 rfs4_check_clientid(clientid4 *, int);
813
814 /* rfs4_clntip_t handling */
815 extern rfs4_clntip_t *rfs4_find_clntip(struct sockaddr *, bool_t *);
816 extern void rfs4_invalidate_clntip(struct sockaddr *);
929 caller_context_t *);
930 extern int deleg_wr_space(femarg_t *, int, flock64_t *, int, offset_t, cred_t *,
931 caller_context_t *);
932 extern int deleg_rd_setsecattr(femarg_t *, vsecattr_t *, int, cred_t *,
933 caller_context_t *);
934 extern int deleg_wr_setsecattr(femarg_t *, vsecattr_t *, int, cred_t *,
935 caller_context_t *);
936 extern int deleg_rd_vnevent(femarg_t *, vnevent_t, vnode_t *, char *,
937 caller_context_t *);
938 extern int deleg_wr_vnevent(femarg_t *, vnevent_t, vnode_t *, char *,
939 caller_context_t *);
940
941 extern void rfs4_mon_hold(void *);
942 extern void rfs4_mon_rele(void *);
943
944 extern fem_t *deleg_rdops;
945 extern fem_t *deleg_wrops;
946
947 extern int rfs4_share(rfs4_state_t *, uint32_t, uint32_t);
948 extern int rfs4_unshare(rfs4_state_t *);
949 extern void rfs4_set_deleg_policy(srv_deleg_policy_t);
950 #ifdef DEBUG
951 #define NFS4_DEBUG(var, args) if (var) cmn_err args
952
953 extern int rfs4_debug;
954 extern int nfs4_client_attr_debug;
955 extern int nfs4_client_state_debug;
956 extern int nfs4_client_shadow_debug;
957 extern int nfs4_client_lock_debug;
958 extern int nfs4_client_lease_debug;
959 extern int nfs4_seqid_sync;
960 extern int nfs4_client_map_debug;
961 extern int nfs4_client_inactive_debug;
962 extern int nfs4_client_recov_debug;
963 extern int nfs4_client_failover_debug;
964 extern int nfs4_client_call_debug;
965 extern int nfs4_client_foo_debug;
966 extern int nfs4_client_zone_debug;
967 extern int nfs4_lost_rqst_debug;
968 extern int nfs4_open_stream_debug;
969 extern int nfs4_client_open_dg;
1331 extern int vs_ace4_to_acet(vsecattr_t *, vsecattr_t *, uid_t, gid_t,
1332 int);
1333 extern int vs_acet_to_ace4(vsecattr_t *, vsecattr_t *, int);
1334 extern void vs_acet_destroy(vsecattr_t *);
1335 extern void vs_ace4_destroy(vsecattr_t *);
1336 extern void vs_aent_destroy(vsecattr_t *);
1337
1338 extern int vn_find_nfs_record(vnode_t *, nvlist_t **, char **, char **);
1339 extern int vn_is_nfs_reparse(vnode_t *, cred_t *);
1340 extern fs_locations4 *fetch_referral(vnode_t *, cred_t *);
1341 extern char *build_symlink(vnode_t *, cred_t *, size_t *);
1342
1343 extern int stateid4_cmp(stateid4 *, stateid4 *);
1344
1345 extern vtype_t nf4_to_vt[];
1346
1347 extern struct nfs4_ntov_map nfs4_ntov_map[];
1348 extern uint_t nfs4_ntov_map_size;
1349
1350 extern kstat_named_t *rfsproccnt_v4_ptr;
1351 extern struct vfsops *nfs4_vfsops;
1352 extern struct vnodeops *nfs4_vnodeops;
1353 extern const struct fs_operation_def nfs4_vnodeops_template[];
1354 extern vnodeops_t *nfs4_trigger_vnodeops;
1355 extern const struct fs_operation_def nfs4_trigger_vnodeops_template[];
1356
1357 extern uint_t nfs4_tsize(struct knetconfig *);
1358 extern uint_t rfs4_tsize(struct svc_req *);
1359
1360 extern bool_t xdr_inline_decode_nfs_fh4(uint32_t *, nfs_fh4_fmt_t *,
1361 uint32_t);
1362 extern bool_t xdr_inline_encode_nfs_fh4(uint32_t **, uint32_t *,
1363 nfs_fh4_fmt_t *);
1364
1365 #ifdef DEBUG
1366 extern int rfs4_do_pre_op_attr;
1367 extern int rfs4_do_post_op_attr;
1368 #endif
1369
1370 extern stateid4 clnt_special0;
1371 extern stateid4 clnt_special1;
1372 #define CLNT_ISSPECIAL(id) (stateid4_cmp(id, &clnt_special0) || \
1373 stateid4_cmp(id, &clnt_special1))
1374
1375 /*
1376 * The NFS Version 4 service procedures.
1377 */
1378
1379 extern void rfs4_compound(COMPOUND4args *, COMPOUND4res *,
1380 struct exportinfo *, struct svc_req *, cred_t *, int *);
1381 extern void rfs4_compound_free(COMPOUND4res *);
1382 extern void rfs4_compound_flagproc(COMPOUND4args *, int *);
1383
1384 extern int rfs4_srvrinit(void);
1385 extern void rfs4_srvrfini(void);
1386 extern void rfs4_state_init(void);
1387 extern void rfs4_state_fini(void);
1388
1389 #endif
1390 #ifdef __cplusplus
1391 }
1392 #endif
1393
1394 #endif /* _NFS4_H */
|
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 /*
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /*
28 * Copyright 2018 Nexenta Systems, Inc.
29 */
30
31 #ifndef _NFS4_H
32 #define _NFS4_H
33
34 #include <sys/types.h>
35 #include <sys/vnode.h>
36 #include <sys/fem.h>
37 #include <rpc/rpc.h>
38 #include <nfs/nfs.h>
39
40 #ifdef _KERNEL
41 #include <nfs/nfs4_kprot.h>
42 #include <nfs/nfs4_drc.h>
43 #include <sys/nvpair.h>
44 #else
45 #include <rpcsvc/nfs4_prot.h>
46 #endif
47 #include <nfs/nfs4_attr.h>
48 #include <sys/acl.h>
49 #include <sys/list.h>
50
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54
55 #define NFS4_MAX_SECOID4 65536
56 #define NFS4_MAX_UTF8STRING 65536
57 #define NFS4_MAX_LINKTEXT4 65536
58 #define NFS4_MAX_PATHNAME4 65536
59
60 struct nfs_fsl_info {
61 uint_t netbuf_len;
62 uint_t netnm_len;
103 *
104 * The basic structure at this level is that the server maintains a
105 * global "database" which consists of a set of tables. Each table
106 * contains a set of like data structures. Each table is indexed by
107 * at least one hash function and in most cases two hashes. Each
108 * table's characteristics is set when it is created at run-time via
109 * rfs4_table_create(). All table creation and related functions are
110 * located in nfs4_state.c. The generic database functionality is
111 * located in nfs4_db.c.
112 */
113
114 typedef struct rfs4_dbe rfs4_dbe_t; /* basic opaque db entry */
115 typedef struct rfs4_table rfs4_table_t; /* basic table type */
116 typedef struct rfs4_index rfs4_index_t; /* index */
117 typedef struct rfs4_database rfs4_database_t; /* and database */
118
119 typedef struct { /* opaque entry type for later use */
120 rfs4_dbe_t *dbe;
121 } *rfs4_entry_t;
122
123 /*
124 * NFSv4 server state databases
125 *
126 * Initilized when the module is loaded and used by NFSv4 state tables.
127 * These kmem_cache free pools are used globally, the NFSv4 state tables
128 * which make use of these kmem_cache free pools are per zone.
129 */
130 extern kmem_cache_t *rfs4_client_mem_cache;
131 extern kmem_cache_t *rfs4_clntIP_mem_cache;
132 extern kmem_cache_t *rfs4_openown_mem_cache;
133 extern kmem_cache_t *rfs4_openstID_mem_cache;
134 extern kmem_cache_t *rfs4_lockstID_mem_cache;
135 extern kmem_cache_t *rfs4_lockown_mem_cache;
136 extern kmem_cache_t *rfs4_file_mem_cache;
137 extern kmem_cache_t *rfs4_delegstID_mem_cache;
138
139 /* database, table, index creation entry points */
140 extern rfs4_database_t *rfs4_database_create(uint32_t);
141 extern void rfs4_database_shutdown(rfs4_database_t *);
142 extern void rfs4_database_destroy(rfs4_database_t *);
143
144 extern void rfs4_database_destroy(rfs4_database_t *);
145
146 extern kmem_cache_t *nfs4_init_mem_cache(char *, uint32_t, uint32_t,
147 uint32_t);
148 extern rfs4_table_t *rfs4_table_create(rfs4_database_t *, char *,
149 time_t, uint32_t,
150 bool_t (*create)(rfs4_entry_t, void *),
151 void (*destroy)(rfs4_entry_t),
152 bool_t (*expiry)(rfs4_entry_t),
153 uint32_t, uint32_t, uint32_t, id_t);
154 extern void rfs4_table_destroy(rfs4_database_t *, rfs4_table_t *);
155 extern rfs4_index_t *rfs4_index_create(rfs4_table_t *, char *,
156 uint32_t (*hash)(void *),
157 bool_t (compare)(rfs4_entry_t, void *),
158 void *(*mkkey)(rfs4_entry_t), bool_t);
159 extern void rfs4_index_destroy(rfs4_index_t *);
160
161 /* Type used to direct rfs4_dbsearch() in what types of records to inspect */
162 typedef enum {RFS4_DBS_VALID, RFS4_DBS_INVALID} rfs4_dbsearch_type_t;
163 /* search and db entry manipulation entry points */
164 extern rfs4_entry_t rfs4_dbsearch(rfs4_index_t *, void *,
165 bool_t *, void *, rfs4_dbsearch_type_t);
166 extern void rfs4_dbe_lock(rfs4_dbe_t *);
167 extern void rfs4_dbe_unlock(rfs4_dbe_t *);
369 struct rfs4_servinst *next;
370 struct rfs4_servinst *prev;
371 } rfs4_servinst_t;
372
373 /*
374 * DSS: distributed stable storage
375 */
376
377 typedef struct rfs4_dss_path {
378 struct rfs4_dss_path *next; /* for insque/remque */
379 struct rfs4_dss_path *prev; /* for insque/remque */
380 char *path;
381 struct rfs4_servinst *sip;
382 unsigned index; /* offset in servinst's array */
383 } rfs4_dss_path_t;
384
385 /* array of paths passed-in from nfsd command-line; stored in nvlist */
386 char **rfs4_dss_newpaths;
387 uint_t rfs4_dss_numnewpaths;
388
389 /* nvlists of all DSS paths: current, and before last warmstart */
390 nvlist_t *rfs4_dss_paths, *rfs4_dss_oldpaths;
391
392 /*
393 * The server maintains a set of state on a per client basis that
394 * matches that of the protocol requirements. A client's state is
395 * rooted with the rfs4_client_t struct of which there is one per
396 * client and is created when SETCLIENTID/SETCLIENTID_CONFIRM are
397 * received. From there, the server then creates rfs4_openowner_t
398 * structs for each new open owner from that client and are initiated
399 * at OPEN/OPEN_CONFIRM (when the open owner is new to the server).
400 * At OPEN, at least two other structures are created, and potentially a
401 * third. rfs4_state_t is created to track the association between an
402 * open owner and a particular file. An rfs4_file_t struct may be
403 * created (if the file is not already open) at OPEN as well. The
404 * rfs4_file_t struct is the only one that is per server and not per
405 * client. The rfs4_deleg_state_t struct is created in the
406 * instance that the server is going to provide a delegation for the
407 * file being OPENed. Finally, the rfs4_lockowner_t is created at the
408 * first use of a lock owner at the server and is a result of the LOCK
734 * lock may or may not be held for lock/unlock of file_rwlock.
735 * As mentioned above, the file_rwlock is used for serialization
736 * of file removal and more specifically reference to the held
737 * vnode (e.g. vp).
738 */
739 typedef struct rfs4_file {
740 rfs4_dbe_t *rf_dbe;
741 vnode_t *rf_vp;
742 nfs_fh4 rf_filehandle;
743 list_t rf_delegstatelist;
744 rfs4_dinfo_t rf_dinfo;
745 uint32_t rf_share_deny;
746 uint32_t rf_share_access;
747 uint32_t rf_access_read;
748 uint32_t rf_access_write;
749 uint32_t rf_deny_read;
750 uint32_t rf_deny_write;
751 krwlock_t rf_file_rwlock;
752 } rfs4_file_t;
753
754 /*
755 * nfs4_deleg_policy is used to signify the server's global delegation
756 * policy. The default is to NEVER delegate files and the
757 * administrator must configure the server to enable delegations.
758 *
759 * The disable/enable delegation functions are used to eliminate a
760 * race with exclusive creates.
761 */
762 typedef enum {
763 SRV_NEVER_DELEGATE = 0,
764 SRV_NORMAL_DELEGATE = 1
765 } srv_deleg_policy_t;
766
767 extern void rfs4_disable_delegation(void), rfs4_enable_delegation(void);
768
769 /*
770 * Request types for delegation. These correspond with
771 * open_delegation_type4 with the addition of a new value, DELEG_ANY,
772 * to reqequest any delegation.
773 */
774 typedef enum {
775 DELEG_NONE = 0, /* Corresponds to OPEN_DELEG_NONE */
776 DELEG_READ = 1, /* Corresponds to OPEN_DELEG_READ */
777 DELEG_WRITE = 2, /* Corresponds to OPEN_DELEG_WRITE */
778 DELEG_ANY = -1 /* New value to request any delegation type */
779 } delegreq_t;
780
781 #define NFS4_DELEG4TYPE2REQTYPE(x) (delegreq_t)(x)
782
783 /*
784 * Zone global variables of NFSv4 server
785 */
786 typedef struct nfs4_srv {
787 /* Unique write verifier */
788 verifier4 write4verf;
789 /* Delegation lock */
790 kmutex_t deleg_lock;
791 /* Used to serialize create/destroy of nfs4_server_state database */
792 kmutex_t state_lock;
793 rfs4_database_t *nfs4_server_state;
794 /* Used to manage access to server instance linked list */
795 kmutex_t servinst_lock;
796 rfs4_servinst_t *nfs4_cur_servinst;
797 /* Used to manage access to nfs4_deleg_policy */
798 krwlock_t deleg_policy_lock;
799 srv_deleg_policy_t nfs4_deleg_policy;
800 /* Set first time we see one */
801 int seen_first_compound;
802 /*
803 * Circular double-linked list of paths for currently-served RGs.
804 * No locking required -- only changed on warmstart.
805 * Managed with insque/remque.
806 */
807 rfs4_dss_path_t *dss_pathlist;
808 /* Duplicate request cache */
809 rfs4_drc_t *nfs4_drc;
810 /* nfsv4 server start time */
811 time_t rfs4_start_time;
812 /* Used to serialize lookups of clientids */
813 krwlock_t rfs4_findclient_lock;
814
815 /* NFSv4 server state client tables */
816 /* table expiry times */
817 time_t rfs4_client_cache_time;
818 time_t rfs4_openowner_cache_time;
819 time_t rfs4_state_cache_time;
820 time_t rfs4_lo_state_cache_time;
821 time_t rfs4_lockowner_cache_time;
822 time_t rfs4_file_cache_time;
823 time_t rfs4_deleg_state_cache_time;
824 time_t rfs4_clntip_cache_time;
825 /* tables and indexes */
826 /* client table */
827 rfs4_table_t *rfs4_client_tab;
828 rfs4_index_t *rfs4_clientid_idx;
829 rfs4_index_t *rfs4_nfsclnt_idx;
830 /* client IP table */
831 rfs4_table_t *rfs4_clntip_tab;
832 rfs4_index_t *rfs4_clntip_idx;
833 /* Open Owner table */
834 rfs4_table_t *rfs4_openowner_tab;
835 rfs4_index_t *rfs4_openowner_idx;
836 /* Open State ID table */
837 rfs4_table_t *rfs4_state_tab;
838 rfs4_index_t *rfs4_state_idx;
839 rfs4_index_t *rfs4_state_owner_file_idx;
840 rfs4_index_t *rfs4_state_file_idx;
841 /* Lock State ID table */
842 rfs4_table_t *rfs4_lo_state_tab;
843 rfs4_index_t *rfs4_lo_state_idx;
844 rfs4_index_t *rfs4_lo_state_owner_idx;
845 /* Lock owner table */
846 rfs4_table_t *rfs4_lockowner_tab;
847 rfs4_index_t *rfs4_lockowner_idx;
848 rfs4_index_t *rfs4_lockowner_pid_idx;
849 /* File table */
850 rfs4_table_t *rfs4_file_tab;
851 rfs4_index_t *rfs4_file_idx;
852 /* Deleg State table */
853 rfs4_table_t *rfs4_deleg_state_tab;
854 rfs4_index_t *rfs4_deleg_idx;
855 rfs4_index_t *rfs4_deleg_state_idx;
856
857 /* client stable storage */
858 int rfs4_ss_enabled;
859 } nfs4_srv_t;
860
861 /*
862 * max length of the NFSv4 server database name
863 */
864 #define RFS4_MAX_MEM_CACHE_NAME 48
865
866 /*
867 * global NFSv4 server kmem caches
868 * r_db_name - The name of the state database and the table that will use it
869 * These tables are defined in nfs4_srv_t
870 * r_db_mem_cache - The kmem cache associated with the state database name
871 */
872 typedef struct rfs4_db_mem_cache {
873 char r_db_name[RFS4_MAX_MEM_CACHE_NAME];
874 kmem_cache_t *r_db_mem_cache;
875 } rfs4_db_mem_cache_t;
876
877 #define RFS4_DB_MEM_CACHE_NUM 8
878
879 rfs4_db_mem_cache_t rfs4_db_mem_cache_table[RFS4_DB_MEM_CACHE_NUM];
880
881
882 extern srv_deleg_policy_t nfs4_get_deleg_policy();
883
884 extern void rfs4_servinst_create(nfs4_srv_t *, int, int, char **);
885 extern void rfs4_servinst_destroy_all(nfs4_srv_t *);
886 extern void rfs4_servinst_assign(nfs4_srv_t *, rfs4_client_t *,
887 rfs4_servinst_t *);
888 extern rfs4_servinst_t *rfs4_servinst(rfs4_client_t *);
889 extern int rfs4_clnt_in_grace(rfs4_client_t *);
890 extern int rfs4_servinst_in_grace(rfs4_servinst_t *);
891 extern int rfs4_servinst_grace_new(rfs4_servinst_t *);
892 extern void rfs4_grace_start(rfs4_servinst_t *);
893 extern void rfs4_grace_start_new(nfs4_srv_t *);
894 extern void rfs4_grace_reset_all(nfs4_srv_t *);
895 extern void rfs4_ss_oldstate(rfs4_oldstate_t *, char *, char *);
896 extern void rfs4_dss_readstate(nfs4_srv_t *, int, char **);
897
898 /*
899 * Various interfaces to manipulate the state structures introduced
900 * above
901 */
902 extern void rfs4_clean_state_exi(struct exportinfo *exi);
903 extern void rfs4_free_reply(nfs_resop4 *);
904 extern void rfs4_copy_reply(nfs_resop4 *, nfs_resop4 *);
905
906 /* rfs4_client_t handling */
907 extern rfs4_client_t *rfs4_findclient(nfs_client_id4 *,
908 bool_t *, rfs4_client_t *);
909 extern rfs4_client_t *rfs4_findclient_by_id(clientid4, bool_t);
910 extern rfs4_client_t *rfs4_findclient_by_addr(struct sockaddr *);
911 extern void rfs4_client_rele(rfs4_client_t *);
912 extern void rfs4_client_close(rfs4_client_t *);
913 extern void rfs4_client_state_remove(rfs4_client_t *);
914 extern void rfs4_client_scv_next(rfs4_client_t *);
915 extern void rfs4_update_lease(rfs4_client_t *);
916 extern bool_t rfs4_lease_expired(rfs4_client_t *);
917 extern nfsstat4 rfs4_check_clientid(clientid4 *, int);
918
919 /* rfs4_clntip_t handling */
920 extern rfs4_clntip_t *rfs4_find_clntip(struct sockaddr *, bool_t *);
921 extern void rfs4_invalidate_clntip(struct sockaddr *);
1034 caller_context_t *);
1035 extern int deleg_wr_space(femarg_t *, int, flock64_t *, int, offset_t, cred_t *,
1036 caller_context_t *);
1037 extern int deleg_rd_setsecattr(femarg_t *, vsecattr_t *, int, cred_t *,
1038 caller_context_t *);
1039 extern int deleg_wr_setsecattr(femarg_t *, vsecattr_t *, int, cred_t *,
1040 caller_context_t *);
1041 extern int deleg_rd_vnevent(femarg_t *, vnevent_t, vnode_t *, char *,
1042 caller_context_t *);
1043 extern int deleg_wr_vnevent(femarg_t *, vnevent_t, vnode_t *, char *,
1044 caller_context_t *);
1045
1046 extern void rfs4_mon_hold(void *);
1047 extern void rfs4_mon_rele(void *);
1048
1049 extern fem_t *deleg_rdops;
1050 extern fem_t *deleg_wrops;
1051
1052 extern int rfs4_share(rfs4_state_t *, uint32_t, uint32_t);
1053 extern int rfs4_unshare(rfs4_state_t *);
1054 extern void rfs4_set_deleg_policy(nfs4_srv_t *, srv_deleg_policy_t);
1055 extern void rfs4_hold_deleg_policy(nfs4_srv_t *);
1056 extern void rfs4_rele_deleg_policy(nfs4_srv_t *);
1057
1058 #ifdef DEBUG
1059 #define NFS4_DEBUG(var, args) if (var) cmn_err args
1060
1061 extern int rfs4_debug;
1062 extern int nfs4_client_attr_debug;
1063 extern int nfs4_client_state_debug;
1064 extern int nfs4_client_shadow_debug;
1065 extern int nfs4_client_lock_debug;
1066 extern int nfs4_client_lease_debug;
1067 extern int nfs4_seqid_sync;
1068 extern int nfs4_client_map_debug;
1069 extern int nfs4_client_inactive_debug;
1070 extern int nfs4_client_recov_debug;
1071 extern int nfs4_client_failover_debug;
1072 extern int nfs4_client_call_debug;
1073 extern int nfs4_client_foo_debug;
1074 extern int nfs4_client_zone_debug;
1075 extern int nfs4_lost_rqst_debug;
1076 extern int nfs4_open_stream_debug;
1077 extern int nfs4_client_open_dg;
1439 extern int vs_ace4_to_acet(vsecattr_t *, vsecattr_t *, uid_t, gid_t,
1440 int);
1441 extern int vs_acet_to_ace4(vsecattr_t *, vsecattr_t *, int);
1442 extern void vs_acet_destroy(vsecattr_t *);
1443 extern void vs_ace4_destroy(vsecattr_t *);
1444 extern void vs_aent_destroy(vsecattr_t *);
1445
1446 extern int vn_find_nfs_record(vnode_t *, nvlist_t **, char **, char **);
1447 extern int vn_is_nfs_reparse(vnode_t *, cred_t *);
1448 extern fs_locations4 *fetch_referral(vnode_t *, cred_t *);
1449 extern char *build_symlink(vnode_t *, cred_t *, size_t *);
1450
1451 extern int stateid4_cmp(stateid4 *, stateid4 *);
1452
1453 extern vtype_t nf4_to_vt[];
1454
1455 extern struct nfs4_ntov_map nfs4_ntov_map[];
1456 extern uint_t nfs4_ntov_map_size;
1457
1458 extern kstat_named_t *rfsproccnt_v4_ptr;
1459 extern kstat_t **rfsprocio_v4_ptr;
1460 extern struct vfsops *nfs4_vfsops;
1461 extern struct vnodeops *nfs4_vnodeops;
1462 extern const struct fs_operation_def nfs4_vnodeops_template[];
1463 extern vnodeops_t *nfs4_trigger_vnodeops;
1464 extern const struct fs_operation_def nfs4_trigger_vnodeops_template[];
1465
1466 extern uint_t nfs4_tsize(struct knetconfig *);
1467 extern uint_t rfs4_tsize(struct svc_req *);
1468
1469 extern bool_t xdr_inline_decode_nfs_fh4(uint32_t *, nfs_fh4_fmt_t *,
1470 uint32_t);
1471 extern bool_t xdr_inline_encode_nfs_fh4(uint32_t **, uint32_t *,
1472 nfs_fh4_fmt_t *);
1473
1474 #ifdef DEBUG
1475 extern int rfs4_do_pre_op_attr;
1476 extern int rfs4_do_post_op_attr;
1477 #endif
1478
1479 extern stateid4 clnt_special0;
1480 extern stateid4 clnt_special1;
1481 #define CLNT_ISSPECIAL(id) (stateid4_cmp(id, &clnt_special0) || \
1482 stateid4_cmp(id, &clnt_special1))
1483
1484 /*
1485 * The NFS Version 4 service procedures.
1486 */
1487
1488 extern void rfs4_do_server_start(int, int, int);
1489 extern void rfs4_compound(COMPOUND4args *, COMPOUND4res *,
1490 struct exportinfo *, struct svc_req *, cred_t *, int *);
1491 extern void rfs4_compound_free(COMPOUND4res *);
1492 extern void rfs4_compound_flagproc(COMPOUND4args *, int *);
1493 extern void rfs4_compound_kstat_args(COMPOUND4args *);
1494 extern void rfs4_compound_kstat_res(COMPOUND4res *);
1495
1496 extern void rfs4_srvrinit(void);
1497 extern void rfs4_srvrfini(void);
1498 extern void rfs4_state_g_init(void);
1499 extern void rfs4_state_zone_init(nfs4_srv_t *);
1500 extern void rfs4_state_g_fini(void);
1501 extern void rfs4_state_zone_fini(void);
1502
1503 #endif
1504 #ifdef __cplusplus
1505 }
1506 #endif
1507
1508 #endif /* _NFS4_H */
|