The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/nfs4client/nfs4_vfs_subs.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $FreeBSD$ */
    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_flags = nmp->nm_flag;
  128         sbp->f_iosize = nfs_iosize(nmp);
  129         sbp->f_bsize = NFS_FABLKSIZE;
  130 
  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;
  134         }
  135 
  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;
  144 
  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);
  149         }
  150 }

Cache object: 895b001815bc1492e8585c91f7665ec9


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.