summaryrefslogtreecommitdiffstats
path: root/sys/nfs4client/nfs4_vfs_subs.c
blob: 6d667afa9fa00b201a1100da283cd5a55c2ebdef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* $FreeBSD$ */
/* $Id: nfs4_vfs_subs.c,v 1.5 2003/11/05 14:59:00 rees Exp $ */

/*-
 * copyright (c) 2003
 * the regents of the university of michigan
 * all rights reserved
 * 
 * permission is granted to use, copy, create derivative works and redistribute
 * this software and such derivative works for any purpose, so long as the name
 * of the university of michigan is not used in any advertising or publicity
 * pertaining to the use or distribution of this software without specific,
 * written prior authorization.  if the above copyright notice or any other
 * identification of the university of michigan is included in any copy of any
 * portion of this software, then the disclaimer below must also be included.
 * 
 * this software is provided as is, without representation from the university
 * of michigan as to its fitness for any purpose, and without warranty by the
 * university of michigan of any kind, either express or implied, including
 * without limitation the implied warranties of merchantability and fitness for
 * a particular purpose. the regents of the university of michigan shall not be
 * liable for any damages, including special, indirect, incidental, or
 * consequential damages, with respect to any claim arising out of or in
 * connection with the use of the software, even if it has been or is hereafter
 * advised of the possibility of such damages.
 */

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/module.h>
#include <sys/mount.h>
#include <sys/proc.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sockio.h>
#include <sys/vnode.h>

#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/uma.h>

#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>

#include <rpc/rpcclnt.h>

#include <nfs/rpcv2.h>
#include <nfs/nfsproto.h>
#include <nfsclient/nfs.h>
#include <nfsclient/nfsmount.h>
#include <nfs/xdr_subs.h>
#include <nfsclient/nfsm_subs.h>
#include <nfsclient/nfsdiskless.h>

/* NFSv4 */
#include <nfs4client/nfs4.h>
#include <nfs4client/nfs4m_subs.h>
#include <nfs4client/nfs4_vfs.h>

#include <nfsclient/nfsnode.h>

void
nfs4_vfsop_fsinfo(struct nfsv4_fattr *fap, struct nfsmount *nmp)
{
	uint32_t max;

	if (fap->fa4_valid & FA4V_FSID) {
		nmp->nm_fsid.val[0] = fap->fa4_fsid_major;
		nmp->nm_fsid.val[1] = fap->fa4_fsid_minor;
	}
	if (fap->fa4_valid & FA4V_MAXREAD) {
                max = fap->fa4_maxread;
                if (max < nmp->nm_rsize) {
                        nmp->nm_rsize = max & ~(NFS_FABLKSIZE - 1);
                        if (nmp->nm_rsize == 0)
                                nmp->nm_rsize = max;
                }
                if (max < nmp->nm_readdirsize) {
                        nmp->nm_readdirsize = max & ~(NFS_DIRBLKSIZ - 1);
                        if (nmp->nm_readdirsize == 0)
                                nmp->nm_readdirsize = max;
                }
	}
	if (fap->fa4_valid & FA4V_MAXWRITE) {
                max = fap->fa4_maxwrite;
                if (max < nmp->nm_wsize) {
                        nmp->nm_wsize = max & ~(NFS_FABLKSIZE - 1);
                        if (nmp->nm_wsize == 0)
                                nmp->nm_wsize = max;
                }
	}
	if (fap->fa4_valid & FA4V_LEASE_TIME)
		nmp->nm_lease_time = fap->fa4_lease_time;

	/* nmp->nm_flag |= NFSMNT_GOTFSINFO; */
}

void
nfs4_vfsop_statfs(struct nfsv4_fattr *fap, struct statfs *sbp, struct mount *mp)
{
	struct nfsmount *nmp = VFSTONFS(mp);

	sbp->f_iosize = nfs_iosize(nmp);
	sbp->f_bsize = NFS_FABLKSIZE;

	if (fap->fa4_valid & FA4V_FSID) {
		sbp->f_fsid.val[0] = fap->fa4_fsid_major;
		sbp->f_fsid.val[1] = fap->fa4_fsid_minor;
	}

	sbp->f_ffree = fap->fa4_valid & FA4V_FFREE ? fap->fa4_ffree : 0;
	/* sbp->f_ftotal = fa->fa4_valid & FA4_FTOTAL ? fa->fa4_ftotal : 0; */
	sbp->f_bavail = fap->fa4_valid & FA4V_SAVAIL ?
	    fap->fa4_savail / NFS_FABLKSIZE : 500000;
	sbp->f_bfree = fap->fa4_valid & FA4V_SFREE ?
	    fap->fa4_sfree / NFS_FABLKSIZE : 500000;
	sbp->f_blocks = fap->fa4_valid & FA4V_STOTAL ?
	    fap->fa4_stotal / NFS_FABLKSIZE : 1000000;
}
OpenPOWER on IntegriCloud