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 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T.
27 * All rights reserved.
28 */
29
30 #pragma ident "@(#)nfs_client.c 1.194 05/12/08 SMI"
31
32 #include <sys/param.h>
33 #include <sys/types.h>
34 #include <sys/systm.h>
35 #include <sys/thread.h>
36 #include <sys/t_lock.h>
37 #include <sys/time.h>
38 #include <sys/vnode.h>
39 #include <sys/vfs.h>
40 #include <sys/errno.h>
41 #include <sys/buf.h>
42 #include <sys/stat.h>
43 #include <sys/cred.h>
44 #include <sys/kmem.h>
45 #include <sys/debug.h>
46 #include <sys/dnlc.h>
47 #include <sys/vmsystm.h>
48 #include <sys/flock.h>
49 #include <sys/share.h>
50 #include <sys/cmn_err.h>
51 #include <sys/tiuser.h>
77 #include <vm/seg_map.h>
78 #include <vm/seg_vn.h>
79
80 static void nfs3_attr_cache(vnode_t *, vattr_t *, vattr_t *, hrtime_t,
81 cred_t *);
82 static int nfs_getattr_cache(vnode_t *, struct vattr *);
83 static int nfs_remove_locking_id(vnode_t *, int, char *, char *, int *);
84
85 struct mi_globals {
86 kmutex_t mig_lock; /* lock protecting mig_list */
87 list_t mig_list; /* list of NFS v2 or v3 mounts in zone */
88 boolean_t mig_destructor_called;
89 };
90
91 static zone_key_t mi_list_key;
92
93 /* Debugging flag for PC file shares. */
94 extern int share_debug;
95
96 /*
97 * Attributes caching:
98 *
99 * Attributes are cached in the rnode in struct vattr form.
100 * There is a time associated with the cached attributes (r_attrtime)
101 * which tells whether the attributes are valid. The time is initialized
102 * to the difference between current time and the modify time of the vnode
103 * when new attributes are cached. This allows the attributes for
104 * files that have changed recently to be timed out sooner than for files
105 * that have not changed for a long time. There are minimum and maximum
106 * timeout values that can be set per mount point.
107 */
108
109 int
110 nfs_waitfor_purge_complete(vnode_t *vp)
111 {
112 rnode_t *rp;
113 k_sigset_t smask;
114
115 rp = VTOR(vp);
116 if (rp->r_serial != NULL && rp->r_serial != curthread) {
2651
2652 #ifdef DEBUG
2653 ASSERT(nfs_clntup == B_FALSE);
2654 #endif
2655
2656 error = nfs_subrinit();
2657 if (error)
2658 return (error);
2659
2660 error = nfs_vfsinit();
2661 if (error) {
2662 /*
2663 * Cleanup nfs_subrinit() work
2664 */
2665 nfs_subrfini();
2666 return (error);
2667 }
2668 zone_key_create(&mi_list_key, nfs_mi_init, nfs_mi_shutdown,
2669 nfs_mi_destroy);
2670
2671 nfs4_clnt_init();
2672
2673 #ifdef DEBUG
2674 nfs_clntup = B_TRUE;
2675 #endif
2676
2677 return (0);
2678 }
2679
2680 /*
2681 * This routine is only called if the NFS Client has been initialized but
2682 * the module failed to be installed. This routine will cleanup the previously
2683 * allocated/initialized work.
2684 */
2685 void
2686 nfs_clntfini(void)
2687 {
2688 (void) zone_key_delete(mi_list_key);
2689 nfs_subrfini();
2690 nfs_vfsfini();
|
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 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 *
26 * Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T.
27 * All rights reserved.
28 */
29
30 /* Copyright (c) 2006, The Ohio State University. All rights reserved.
31 *
32 * Portions of this source code is developed by the team members of
33 * The Ohio State University's Network-Based Computing Laboratory (NBCL),
34 * headed by Professor Dhabaleswar K. (DK) Panda.
35 *
36 * Acknowledgements to contributions from developors:
37 * Ranjit Noronha: noronha@cse.ohio-state.edu
38 * Lei Chai : chail@cse.ohio-state.edu
39 * Weikuan Yu : yuw@cse.ohio-state.edu
40 *
41 */
42
43 #pragma ident "@(#)nfs_client.c 1.193 05/10/11 SMI"
44
45 #include <sys/param.h>
46 #include <sys/types.h>
47 #include <sys/systm.h>
48 #include <sys/thread.h>
49 #include <sys/t_lock.h>
50 #include <sys/time.h>
51 #include <sys/vnode.h>
52 #include <sys/vfs.h>
53 #include <sys/errno.h>
54 #include <sys/buf.h>
55 #include <sys/stat.h>
56 #include <sys/cred.h>
57 #include <sys/kmem.h>
58 #include <sys/debug.h>
59 #include <sys/dnlc.h>
60 #include <sys/vmsystm.h>
61 #include <sys/flock.h>
62 #include <sys/share.h>
63 #include <sys/cmn_err.h>
64 #include <sys/tiuser.h>
90 #include <vm/seg_map.h>
91 #include <vm/seg_vn.h>
92
93 static void nfs3_attr_cache(vnode_t *, vattr_t *, vattr_t *, hrtime_t,
94 cred_t *);
95 static int nfs_getattr_cache(vnode_t *, struct vattr *);
96 static int nfs_remove_locking_id(vnode_t *, int, char *, char *, int *);
97
98 struct mi_globals {
99 kmutex_t mig_lock; /* lock protecting mig_list */
100 list_t mig_list; /* list of NFS v2 or v3 mounts in zone */
101 boolean_t mig_destructor_called;
102 };
103
104 static zone_key_t mi_list_key;
105
106 /* Debugging flag for PC file shares. */
107 extern int share_debug;
108
109 /*
110 * used by RDMA transport to easily recognize READ3 call/reply
111 * (FTDO -- for the demo only. Better design needed for NFS4 or ON10 putback)
112 */
113
114 extern xdrproc_t x_READ3args;
115 extern xdrproc_t x_READ3res;
116 extern xdrproc_t x_READ3uiores;
117 extern xdrproc_t x_READ3vres;
118
119 /*
120 * Attributes caching:
121 *
122 * Attributes are cached in the rnode in struct vattr form.
123 * There is a time associated with the cached attributes (r_attrtime)
124 * which tells whether the attributes are valid. The time is initialized
125 * to the difference between current time and the modify time of the vnode
126 * when new attributes are cached. This allows the attributes for
127 * files that have changed recently to be timed out sooner than for files
128 * that have not changed for a long time. There are minimum and maximum
129 * timeout values that can be set per mount point.
130 */
131
132 int
133 nfs_waitfor_purge_complete(vnode_t *vp)
134 {
135 rnode_t *rp;
136 k_sigset_t smask;
137
138 rp = VTOR(vp);
139 if (rp->r_serial != NULL && rp->r_serial != curthread) {
2674
2675 #ifdef DEBUG
2676 ASSERT(nfs_clntup == B_FALSE);
2677 #endif
2678
2679 error = nfs_subrinit();
2680 if (error)
2681 return (error);
2682
2683 error = nfs_vfsinit();
2684 if (error) {
2685 /*
2686 * Cleanup nfs_subrinit() work
2687 */
2688 nfs_subrfini();
2689 return (error);
2690 }
2691 zone_key_create(&mi_list_key, nfs_mi_init, nfs_mi_shutdown,
2692 nfs_mi_destroy);
2693
2694 x_READ3args = xdr_READ3args;
2695 x_READ3res = xdr_READ3res;
2696 x_READ3vres = xdr_READ3vres;
2697 x_READ3uiores = xdr_READ3uiores;
2698
2699 nfs4_clnt_init();
2700
2701 #ifdef DEBUG
2702 nfs_clntup = B_TRUE;
2703 #endif
2704
2705 return (0);
2706 }
2707
2708 /*
2709 * This routine is only called if the NFS Client has been initialized but
2710 * the module failed to be installed. This routine will cleanup the previously
2711 * allocated/initialized work.
2712 */
2713 void
2714 nfs_clntfini(void)
2715 {
2716 (void) zone_key_delete(mi_list_key);
2717 nfs_subrfini();
2718 nfs_vfsfini();
|