]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/nfs/nfs_vnops.c
xnu-792.10.96.tar.gz
[apple/xnu.git] / bsd / nfs / nfs_vnops.c
index 2d5526ef7742df282383709717d111e0c0e0ad02..b44eb45f24b9d5643c0fa661e3a51eff22386089 100644 (file)
@@ -3,20 +3,19 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License").  You may not use this file except in compliance with the
+ * License.  Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
  * 
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -1032,8 +1031,10 @@ nfs_setattr(ap)
 {
        vnode_t vp = ap->a_vp;
        struct nfsnode *np = VTONFS(vp);
+       struct nfsmount *nmp;
        struct vnode_attr *vap = ap->a_vap;
        int error = 0;
+       int biosize;
        u_quad_t tsize;
        kauth_cred_t cred;
        proc_t p;
@@ -1041,6 +1042,10 @@ nfs_setattr(ap)
 #ifndef nolint
        tsize = (u_quad_t)0;
 #endif
+       nmp = VFSTONFS(vnode_mount(vp));
+       if (!nmp)
+               return (ENXIO);
+       biosize = nmp->nm_biosize;
 
        /* Setting of flags is not supported. */
        if (VATTR_IS_ACTIVE(vap, va_flags))
@@ -1102,10 +1107,9 @@ nfs_setattr(ap)
                                }
                        } else if (np->n_size > vap->va_data_size) { /* shrinking? */
                                daddr64_t obn, bn;
-                               int biosize, neweofoff, mustwrite;
+                               int neweofoff, mustwrite;
                                struct nfsbuf *bp;
 
-                               biosize = vfs_statfs(vnode_mount(vp))->f_iosize;
                                obn = (np->n_size - 1) / biosize;
                                bn = vap->va_data_size / biosize; 
                                for ( ; obn >= bn; obn--) {
@@ -4146,12 +4150,12 @@ again:
                goto again;
        }
 
-       if ((waitfor == MNT_WAIT) && !LIST_EMPTY(&np->n_dirtyblkhd)) {
-               goto again;
-       }
-       /* if we have no dirty blocks, we can clear the modified flag */
-       if (LIST_EMPTY(&np->n_dirtyblkhd))
+       if (waitfor == MNT_WAIT) {
+               if (!LIST_EMPTY(&np->n_dirtyblkhd))
+                       goto again;
+               /* if we have no dirty blocks, we can clear the modified flag */
                np->n_flag &= ~NMODIFIED;
+       }
 
        FSDBG(526, np->n_flag, np->n_error, 0, 0);
        if (!ignore_writeerr && (np->n_flag & NWRITEERR)) {
@@ -4745,9 +4749,9 @@ nfs_pagein(ap)
                                UPL_ABORT_ERROR | UPL_ABORT_FREE_ON_EMPTY);
                return (ENXIO);
        }
+       biosize = nmp->nm_biosize;
        if ((nmp->nm_flag & NFSMNT_NFSV3) && !(nmp->nm_state & NFSSTA_GOTFSINFO))
-               (void)nfs_fsinfo(nmp, vp, cred, p);
-       biosize = vfs_statfs(vnode_mount(vp))->f_iosize;
+               nfs_fsinfo(nmp, vp, cred, p);
 
        plinfo = ubc_upl_pageinfo(pl);
        ubc_upl_map(pl, &ioaddr);
@@ -4884,7 +4888,7 @@ nfs_pageout(ap)
                        ubc_upl_abort(pl, UPL_ABORT_DUMP_PAGES|UPL_ABORT_FREE_ON_EMPTY);
                return (ENXIO);
        }
-       biosize = vfs_statfs(vnode_mount(vp))->f_iosize;
+       biosize = nmp->nm_biosize;
 
        /*
         * Check to see whether the buffer is incore.
@@ -5141,12 +5145,11 @@ nfs_blktooff(ap)
 {
        int biosize;
        vnode_t vp = ap->a_vp;
-       mount_t mp = vnode_mount(vp);
+       struct nfsmount *nmp = VFSTONFS(vnode_mount(vp));
 
-       if (!mp)
+       if (!nmp)
                return (ENXIO);
-
-       biosize = vfs_statfs(mp)->f_iosize;
+       biosize = nmp->nm_biosize;
 
        *ap->a_offset = (off_t)(ap->a_lblkno * biosize);
 
@@ -5164,12 +5167,11 @@ nfs_offtoblk(ap)
 {
        int biosize;
        vnode_t vp = ap->a_vp;
-       mount_t mp = vnode_mount(vp);
+       struct nfsmount *nmp = VFSTONFS(vnode_mount(vp));
 
-       if (!mp)
+       if (!nmp)
                return (ENXIO);
-
-       biosize = vfs_statfs(mp)->f_iosize;
+       biosize = nmp->nm_biosize;
 
        *ap->a_lblkno = (daddr64_t)(ap->a_offset / biosize);