2 /* $Id: nfs4_vfs_subs.c,v 1.5 2003/11/05 14:59:00 rees Exp $ */
6 * the regents of the university of michigan
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.
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.
28 #include <sys/param.h>
29 #include <sys/systm.h>
30 #include <sys/kernel.h>
31 #include <sys/limits.h>
33 #include <sys/malloc.h>
35 #include <sys/module.h>
36 #include <sys/mount.h>
38 #include <sys/socket.h>
39 #include <sys/socketvar.h>
40 #include <sys/sockio.h>
41 #include <sys/vnode.h>
44 #include <vm/vm_extern.h>
48 #include <net/route.h>
49 #include <netinet/in.h>
51 #include <rpc/rpcclnt.h>
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>
62 #include <nfs4client/nfs4.h>
63 #include <nfs4client/nfs4m_subs.h>
64 #include <nfs4client/nfs4_vfs.h>
66 #include <nfsclient/nfsnode.h>
68 static int nfs_iosize(struct nfsmount *nmp);
71 nfs_iosize(struct nfsmount *nmp)
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
81 iosize = max(nmp->nm_rsize, nmp->nm_wsize);
82 if (iosize < PAGE_SIZE) iosize = PAGE_SIZE;
87 nfs4_vfsop_fsinfo(struct nfsv4_fattr *fap, struct nfsmount *nmp)
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;
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)
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;
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)
116 if (fap->fa4_valid & FA4V_LEASE_TIME)
117 nmp->nm_lease_time = fap->fa4_lease_time;
119 /* nmp->nm_flag |= NFSMNT_GOTFSINFO; */
123 nfs4_vfsop_statfs(struct nfsv4_fattr *fap, struct statfs *sbp, struct mount *mp)
125 struct nfsmount *nmp = VFSTONFS(mp);
127 sbp->f_flags = nmp->nm_flag;
128 sbp->f_iosize = nfs_iosize(nmp);
129 sbp->f_bsize = NFS_FABLKSIZE;
131 if (fap->fa4_valid & FA4V_FSID) {
132 sbp->f_fsid.val[0] = fap->fa4_fsid_major;
133 sbp->f_fsid.val[1] = fap->fa4_fsid_minor;
136 sbp->f_ffree = fap->fa4_valid & FA4V_FFREE ? fap->fa4_ffree : 0;
137 /* sbp->f_ftotal = fa->fa4_valid & FA4_FTOTAL ? fa->fa4_ftotal : 0; */
138 sbp->f_bavail = fap->fa4_valid & FA4V_SAVAIL ?
139 fap->fa4_savail / NFS_FABLKSIZE : 500000;
140 sbp->f_bfree = fap->fa4_valid & FA4V_SFREE ?
141 fap->fa4_sfree / NFS_FABLKSIZE : 500000;
142 sbp->f_blocks = fap->fa4_valid & FA4V_STOTAL ?
143 fap->fa4_stotal / NFS_FABLKSIZE : 1000000;
145 if (sbp != &mp->mnt_stat) {
146 sbp->f_type = mp->mnt_vfc->vfc_typenum;
147 bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN);
148 bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN);