1 /* $FreeBSD: releng/6.3/sys/nfs4client/nfs4_vfs_subs.c 139823 2005-01-07 01:45:51Z imp $ */
2 /* $Id: nfs4_vfs_subs.c,v 1.5 2003/11/05 14:59:00 rees Exp $ */
3
4 /*-
5 * copyright (c) 2003
6 * the regents of the university of michigan
7 * all rights reserved
8 *
9 * permission is granted to use, copy, create derivative works and redistribute
10 * this software and such derivative works for any purpose, so long as the name
11 * of the university of michigan is not used in any advertising or publicity
12 * pertaining to the use or distribution of this software without specific,
13 * written prior authorization. if the above copyright notice or any other
14 * identification of the university of michigan is included in any copy of any
15 * portion of this software, then the disclaimer below must also be included.
16 *
17 * this software is provided as is, without representation from the university
18 * of michigan as to its fitness for any purpose, and without warranty by the
19 * university of michigan of any kind, either express or implied, including
20 * without limitation the implied warranties of merchantability and fitness for
21 * a particular purpose. the regents of the university of michigan shall not be
22 * liable for any damages, including special, indirect, incidental, or
23 * consequential damages, with respect to any claim arising out of or in
24 * connection with the use of the software, even if it has been or is hereafter
25 * advised of the possibility of such damages.
26 */
27
28 #include <sys/param.h>
29 #include <sys/systm.h>
30 #include <sys/kernel.h>
31 #include <sys/limits.h>
32 #include <sys/lock.h>
33 #include <sys/malloc.h>
34 #include <sys/mbuf.h>
35 #include <sys/module.h>
36 #include <sys/mount.h>
37 #include <sys/proc.h>
38 #include <sys/socket.h>
39 #include <sys/socketvar.h>
40 #include <sys/sockio.h>
41 #include <sys/vnode.h>
42
43 #include <vm/vm.h>
44 #include <vm/vm_extern.h>
45 #include <vm/uma.h>
46
47 #include <net/if.h>
48 #include <net/route.h>
49 #include <netinet/in.h>
50
51 #include <rpc/rpcclnt.h>
52
53 #include <nfs/rpcv2.h>
54 #include <nfs/nfsproto.h>
55 #include <nfsclient/nfs.h>
56 #include <nfsclient/nfsmount.h>
57 #include <nfs/xdr_subs.h>
58 #include <nfsclient/nfsm_subs.h>
59 #include <nfsclient/nfsdiskless.h>
60
61 /* NFSv4 */
62 #include <nfs4client/nfs4.h>
63 #include <nfs4client/nfs4m_subs.h>
64 #include <nfs4client/nfs4_vfs.h>
65
66 #include <nfsclient/nfsnode.h>
67
68 static int nfs_iosize(struct nfsmount *nmp);
69
70 static int
71 nfs_iosize(struct nfsmount *nmp)
72 {
73 int iosize;
74
75 /*
76 * Calculate the size used for io buffers. Use the larger
77 * of the two sizes to minimise nfs requests but make sure
78 * that it is at least one VM page to avoid wasting buffer
79 * space.
80 */
81 iosize = max(nmp->nm_rsize, nmp->nm_wsize);
82 if (iosize < PAGE_SIZE) iosize = PAGE_SIZE;
83 return iosize;
84 }
85
86 void
87 nfs4_vfsop_fsinfo(struct nfsv4_fattr *fap, struct nfsmount *nmp)
88 {
89 uint32_t max;
90
91 if (fap->fa4_valid & FA4V_FSID) {
92 nmp->nm_fsid.val[0] = fap->fa4_fsid_major;
93 nmp->nm_fsid.val[1] = fap->fa4_fsid_minor;
94 }
95 if (fap->fa4_valid & FA4V_MAXREAD) {
96 max = fap->fa4_maxread;
97 if (max < nmp->nm_rsize) {
98 nmp->nm_rsize = max & ~(NFS_FABLKSIZE - 1);
99 if (nmp->nm_rsize == 0)
100 nmp->nm_rsize = max;
101 }
102 if (max < nmp->nm_readdirsize) {
103 nmp->nm_readdirsize = max & ~(NFS_DIRBLKSIZ - 1);
104 if (nmp->nm_readdirsize == 0)
105 nmp->nm_readdirsize = max;
106 }
107 }
108 if (fap->fa4_valid & FA4V_MAXWRITE) {
109 max = fap->fa4_maxwrite;
110 if (max < nmp->nm_wsize) {
111 nmp->nm_wsize = max & ~(NFS_FABLKSIZE - 1);
112 if (nmp->nm_wsize == 0)
113 nmp->nm_wsize = max;
114 }
115 }
116 if (fap->fa4_valid & FA4V_LEASE_TIME)
117 nmp->nm_lease_time = fap->fa4_lease_time;
118
119 /* nmp->nm_flag |= NFSMNT_GOTFSINFO; */
120 }
121
122 void
123 nfs4_vfsop_statfs(struct nfsv4_fattr *fap, struct statfs *sbp, struct mount *mp)
124 {
125 struct nfsmount *nmp = VFSTONFS(mp);
126
127 sbp->f_iosize = nfs_iosize(nmp);
128 sbp->f_bsize = NFS_FABLKSIZE;
129
130 if (fap->fa4_valid & FA4V_FSID) {
131 sbp->f_fsid.val[0] = fap->fa4_fsid_major;
132 sbp->f_fsid.val[1] = fap->fa4_fsid_minor;
133 }
134
135 sbp->f_ffree = fap->fa4_valid & FA4V_FFREE ? fap->fa4_ffree : 0;
136 /* sbp->f_ftotal = fa->fa4_valid & FA4_FTOTAL ? fa->fa4_ftotal : 0; */
137 sbp->f_bavail = fap->fa4_valid & FA4V_SAVAIL ?
138 fap->fa4_savail / NFS_FABLKSIZE : 500000;
139 sbp->f_bfree = fap->fa4_valid & FA4V_SFREE ?
140 fap->fa4_sfree / NFS_FABLKSIZE : 500000;
141 sbp->f_blocks = fap->fa4_valid & FA4V_STOTAL ?
142 fap->fa4_stotal / NFS_FABLKSIZE : 1000000;
143 }
Cache object: c86242d9eff21f4e43f09ab597ac1ab6
|