keep track of whether the union node is cached or not.
[unix-history] / usr / src / sys / miscfs / union / union_vnops.c
index 9a2e248..d6115ce 100644 (file)
@@ -8,7 +8,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)union_vnops.c       2.1 (Berkeley) %G%
+ *     @(#)union_vnops.c       8.7 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
 #include <sys/namei.h>
 #include <sys/malloc.h>
 #include <sys/buf.h>
 #include <sys/namei.h>
 #include <sys/malloc.h>
 #include <sys/buf.h>
-#include "union.h"
+#include <sys/queue.h>
+#include <miscfs/union/union.h>
+
+#define FIXUP(un) { \
+       if (((un)->un_flags & UN_ULOCK) == 0) { \
+               union_fixup(un); \
+       } \
+}
+
+static void
+union_fixup(un)
+       struct union_node *un;
+{
+
+       VOP_LOCK(un->un_uppervp);
+       un->un_flags |= UN_ULOCK;
+}
 
 static int
 
 static int
-union_lookup1(udvp, dvp, vpp, cnp)
+union_lookup1(udvp, dvpp, vpp, cnp)
        struct vnode *udvp;
        struct vnode *udvp;
-       struct vnode *dvp;
+       struct vnode **dvpp;
        struct vnode **vpp;
        struct componentname *cnp;
 {
        int error;
        struct vnode *tdvp;
        struct vnode **vpp;
        struct componentname *cnp;
 {
        int error;
        struct vnode *tdvp;
+       struct vnode *dvp;
        struct mount *mp;
 
        struct mount *mp;
 
+       dvp = *dvpp;
+
        /*
         * If stepping up the directory tree, check for going
         * back across the mount point, in which case do what
        /*
         * If stepping up the directory tree, check for going
         * back across the mount point, in which case do what
@@ -42,18 +61,15 @@ union_lookup1(udvp, dvp, vpp, cnp)
         * hierarchy.
         */
        if (cnp->cn_flags & ISDOTDOT) {
         * hierarchy.
         */
        if (cnp->cn_flags & ISDOTDOT) {
-               for (;;) {
+               while ((dvp != udvp) && (dvp->v_flag & VROOT)) {
                        /*
                         * Don't do the NOCROSSMOUNT check
                         * at this level.  By definition,
                         * union fs deals with namespaces, not
                         * filesystems.
                         */
                        /*
                         * Don't do the NOCROSSMOUNT check
                         * at this level.  By definition,
                         * union fs deals with namespaces, not
                         * filesystems.
                         */
-                       if ((dvp->v_flag & VROOT) == 0)
-                               break;
-
                        tdvp = dvp;
                        tdvp = dvp;
-                       dvp = dvp->v_mount->mnt_vnodecovered;
+                       *dvpp = dvp = dvp->v_mount->mnt_vnodecovered;
                        vput(tdvp);
                        VREF(dvp);
                        VOP_LOCK(dvp);
                        vput(tdvp);
                        VREF(dvp);
                        VOP_LOCK(dvp);
@@ -120,6 +136,7 @@ union_lookup(ap)
        int lockparent = cnp->cn_flags & LOCKPARENT;
        int rdonly = cnp->cn_flags & RDONLY;
        struct union_mount *um = MOUNTTOUNIONMOUNT(dvp->v_mount);
        int lockparent = cnp->cn_flags & LOCKPARENT;
        int rdonly = cnp->cn_flags & RDONLY;
        struct union_mount *um = MOUNTTOUNIONMOUNT(dvp->v_mount);
+       struct ucred *saved_cred;
 
        cnp->cn_flags |= LOCKPARENT;
 
 
        cnp->cn_flags |= LOCKPARENT;
 
@@ -135,7 +152,8 @@ union_lookup(ap)
         * on and just return that vnode.
         */
        if (upperdvp) {
         * on and just return that vnode.
         */
        if (upperdvp) {
-               uerror = union_lookup1(um->um_uppervp, upperdvp,
+               FIXUP(dun);
+               uerror = union_lookup1(um->um_uppervp, &upperdvp,
                                        &uppervp, cnp);
                /*if (uppervp == upperdvp)
                        dun->un_flags |= UN_KLOCK;*/
                                        &uppervp, cnp);
                /*if (uppervp == upperdvp)
                        dun->un_flags |= UN_KLOCK;*/
@@ -168,8 +186,14 @@ union_lookup(ap)
                 */
                nameiop = cnp->cn_nameiop;
                cnp->cn_nameiop = LOOKUP;
                 */
                nameiop = cnp->cn_nameiop;
                cnp->cn_nameiop = LOOKUP;
-               lerror = union_lookup1(um->um_lowervp, lowerdvp,
+               if (um->um_op == UNMNT_BELOW) {
+                       saved_cred = cnp->cn_cred;
+                       cnp->cn_cred = um->um_cred;
+               }
+               lerror = union_lookup1(um->um_lowervp, &lowerdvp,
                                &lowervp, cnp);
                                &lowervp, cnp);
+               if (um->um_op == UNMNT_BELOW)
+                       cnp->cn_cred = saved_cred;
                cnp->cn_nameiop = nameiop;
 
                if (lowervp != lowerdvp)
                cnp->cn_nameiop = nameiop;
 
                if (lowervp != lowerdvp)
@@ -281,6 +305,8 @@ union_create(ap)
                int error;
                struct vnode *vp;
 
                int error;
                struct vnode *vp;
 
+               FIXUP(un);
+
                VREF(dvp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
                VREF(dvp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
@@ -321,6 +347,8 @@ union_mknod(ap)
                int error;
                struct vnode *vp;
 
                int error;
                struct vnode *vp;
 
+               FIXUP(un);
+
                VREF(dvp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
                VREF(dvp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
@@ -394,7 +422,7 @@ union_open(ap)
                                return (error);
 
                        /* at this point, uppervp is locked */
                                return (error);
 
                        /* at this point, uppervp is locked */
-                       un->un_uppervp = vp;    /* XXX */
+                       union_newupper(un, vp);
                        un->un_flags |= UN_ULOCK;
 
                        /*
                        un->un_flags |= UN_ULOCK;
 
                        /*
@@ -420,17 +448,19 @@ union_open(ap)
                                        VOP_UNLOCK(tvp);
                                }
 
                                        VOP_UNLOCK(tvp);
                                }
 
-                               un->un_flags &= ~UN_ULOCK;
-                               VOP_UNLOCK(un->un_uppervp);
-                               union_vn_close(un->un_uppervp, FWRITE, cred, p);
-                               VOP_LOCK(un->un_uppervp);
-                               un->un_flags |= UN_ULOCK;
-
+#ifdef UNION_DIAGNOSTIC
                                if (!error)
                                        uprintf("union: copied up %s\n",
                                                                un->un_path);
                                if (!error)
                                        uprintf("union: copied up %s\n",
                                                                un->un_path);
+#endif
                        }
 
                        }
 
+                       un->un_flags &= ~UN_ULOCK;
+                       VOP_UNLOCK(un->un_uppervp);
+                       union_vn_close(un->un_uppervp, FWRITE, cred, p);
+                       VOP_LOCK(un->un_uppervp);
+                       un->un_flags |= UN_ULOCK;
+
                        /*
                         * Subsequent IOs will go to the top layer, so
                         * call close on the lower vnode and open on the
                        /*
                         * Subsequent IOs will go to the top layer, so
                         * call close on the lower vnode and open on the
@@ -461,6 +491,8 @@ union_open(ap)
                return (error);
        }
 
                return (error);
        }
 
+       FIXUP(un);
+
        error = VOP_OPEN(tvp, mode, cred, p);
 
        return (error);
        error = VOP_OPEN(tvp, mode, cred, p);
 
        return (error);
@@ -511,20 +543,29 @@ union_access(ap)
        } */ *ap;
 {
        struct union_node *un = VTOUNION(ap->a_vp);
        } */ *ap;
 {
        struct union_node *un = VTOUNION(ap->a_vp);
-       int error = 0;
+       int error = EACCES;
        struct vnode *vp;
 
        struct vnode *vp;
 
+       if (vp = un->un_uppervp) {
+               FIXUP(un);
+               return (VOP_ACCESS(vp, ap->a_mode, ap->a_cred, ap->a_p));
+       }
+
        if (vp = un->un_lowervp) {
                VOP_LOCK(vp);
                error = VOP_ACCESS(vp, ap->a_mode, ap->a_cred, ap->a_p);
        if (vp = un->un_lowervp) {
                VOP_LOCK(vp);
                error = VOP_ACCESS(vp, ap->a_mode, ap->a_cred, ap->a_p);
+               if (error == 0) {
+                       struct union_mount *um = MOUNTTOUNIONMOUNT(vp->v_mount);
+
+                       if (um->um_op == UNMNT_BELOW)
+                               error = VOP_ACCESS(vp, ap->a_mode,
+                                               um->um_cred, ap->a_p);
+               }
                VOP_UNLOCK(vp);
                if (error)
                        return (error);
        }
 
                VOP_UNLOCK(vp);
                if (error)
                        return (error);
        }
 
-       if (vp = un->un_uppervp)
-               error = VOP_ACCESS(vp, ap->a_mode, ap->a_cred, ap->a_p);
-
        return (error);
 }
 
        return (error);
 }
 
@@ -541,17 +582,52 @@ union_getattr(ap)
        } */ *ap;
 {
        int error;
        } */ *ap;
 {
        int error;
-       struct vnode *vp = OTHERVP(ap->a_vp);
-       int dolock = (vp == LOWERVP(ap->a_vp));
+       struct union_node *un = VTOUNION(ap->a_vp);
+       struct vnode *vp = un->un_uppervp;
+       struct vattr *vap;
+       struct vattr va;
 
 
-       if (dolock)
+
+       /*
+        * Some programs walk the filesystem hierarchy by counting
+        * links to directories to avoid stat'ing all the time.
+        * This means the link count on directories needs to be "correct".
+        * The only way to do that is to call getattr on both layers
+        * and fix up the link count.  The link count will not necessarily
+        * be accurate but will be large enough to defeat the tree walkers.
+        */
+
+       vap = ap->a_vap;
+
+       vp = un->un_uppervp;
+       if (vp != NULLVP) {
+               FIXUP(un);
+               error = VOP_GETATTR(vp, vap, ap->a_cred, ap->a_p);
+               if (error)
+                       return (error);
+       }
+
+       if (vp == NULLVP) {
+               vp = un->un_lowervp;
+       } else if (vp->v_type == VDIR) {
+               vp = un->un_lowervp;
+               vap = &va;
+       } else {
+               vp = NULLVP;
+       }
+
+       if (vp != NULLVP) {
                VOP_LOCK(vp);
                VOP_LOCK(vp);
-       error = VOP_GETATTR(vp, ap->a_vap, ap->a_cred, ap->a_p);
-       if (dolock)
+               error = VOP_GETATTR(vp, vap, ap->a_cred, ap->a_p);
                VOP_UNLOCK(vp);
                VOP_UNLOCK(vp);
+               if (error)
+                       return (error);
+       }
 
 
-       /* Requires that arguments be restored. */
-       ap->a_vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
+       if ((vap != ap->a_vap) && (vap->va_type == VDIR))
+               ap->a_vap->va_nlink += vap->va_nlink;
+
+       vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0];
        return (0);
 }
 
        return (0);
 }
 
@@ -567,15 +643,39 @@ union_setattr(ap)
        struct union_node *un = VTOUNION(ap->a_vp);
        int error;
 
        struct union_node *un = VTOUNION(ap->a_vp);
        int error;
 
-       if (un->un_uppervp) {
+       /*
+        * Handle case of truncating lower object to zero size,
+        * by creating a zero length upper object.  This is to
+        * handle the case of open with O_TRUNC and O_CREAT.
+        */
+       if ((un->un_uppervp == NULLVP) &&
+           /* assert(un->un_lowervp != NULLVP) */
+           (un->un_lowervp->v_type == VREG) &&
+           (ap->a_vap->va_size == 0)) {
+               struct vnode *vp;
+
+               error = union_vn_create(&vp, un, ap->a_p);
+               if (error)
+                       return (error);
+
+               /* at this point, uppervp is locked */
+               union_newupper(un, vp);
+
+               VOP_UNLOCK(vp);
+               union_vn_close(un->un_uppervp, FWRITE, ap->a_cred, ap->a_p);
+               VOP_LOCK(vp);
+               un->un_flags |= UN_ULOCK;
+       }
+
+       /*
+        * Try to set attributes in upper layer,
+        * otherwise return read-only filesystem error.
+        */
+       if (un->un_uppervp != NULLVP) {
+               FIXUP(un);
                error = VOP_SETATTR(un->un_uppervp, ap->a_vap,
                                        ap->a_cred, ap->a_p);
        } else {
                error = VOP_SETATTR(un->un_uppervp, ap->a_vap,
                                        ap->a_cred, ap->a_p);
        } else {
-               /*
-                * XXX should do a copyfile (perhaps only if
-                * the file permission change, which would not
-                * track va_ctime correctly).
-                */
                error = EROFS;
        }
 
                error = EROFS;
        }
 
@@ -597,6 +697,8 @@ union_read(ap)
 
        if (dolock)
                VOP_LOCK(vp);
 
        if (dolock)
                VOP_LOCK(vp);
+       else
+               FIXUP(VTOUNION(ap->a_vp));
        error = VOP_READ(vp, ap->a_uio, ap->a_ioflag, ap->a_cred);
        if (dolock)
                VOP_UNLOCK(vp);
        error = VOP_READ(vp, ap->a_uio, ap->a_ioflag, ap->a_cred);
        if (dolock)
                VOP_UNLOCK(vp);
@@ -619,6 +721,8 @@ union_write(ap)
 
        if (dolock)
                VOP_LOCK(vp);
 
        if (dolock)
                VOP_LOCK(vp);
+       else
+               FIXUP(VTOUNION(ap->a_vp));
        error = VOP_WRITE(vp, ap->a_uio, ap->a_ioflag, ap->a_cred);
        if (dolock)
                VOP_UNLOCK(vp);
        error = VOP_WRITE(vp, ap->a_uio, ap->a_ioflag, ap->a_cred);
        if (dolock)
                VOP_UNLOCK(vp);
@@ -688,6 +792,8 @@ union_fsync(ap)
 
                if (dolock)
                        VOP_LOCK(targetvp);
 
                if (dolock)
                        VOP_LOCK(targetvp);
+               else
+                       FIXUP(VTOUNION(ap->a_vp));
                error = VOP_FSYNC(targetvp, ap->a_cred,
                                        ap->a_waitfor, ap->a_p);
                if (dolock)
                error = VOP_FSYNC(targetvp, ap->a_cred,
                                        ap->a_waitfor, ap->a_p);
                if (dolock)
@@ -726,9 +832,11 @@ union_remove(ap)
                struct vnode *dvp = dun->un_uppervp;
                struct vnode *vp = un->un_uppervp;
 
                struct vnode *dvp = dun->un_uppervp;
                struct vnode *vp = un->un_uppervp;
 
+               FIXUP(dun);
                VREF(dvp);
                dun->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
                VREF(dvp);
                dun->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
+               FIXUP(un);
                VREF(vp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_vp);
                VREF(vp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_vp);
@@ -768,9 +876,11 @@ union_link(ap)
                struct vnode *dvp = dun->un_uppervp;
                struct vnode *vp = un->un_uppervp;
 
                struct vnode *dvp = dun->un_uppervp;
                struct vnode *vp = un->un_uppervp;
 
+               FIXUP(dun);
                VREF(dvp);
                dun->un_flags |= UN_KLOCK;
                vput(ap->a_vp);
                VREF(dvp);
                dun->un_flags |= UN_KLOCK;
                vput(ap->a_vp);
+               FIXUP(un);
                VREF(vp);
                vrele(ap->a_tdvp);
 
                VREF(vp);
                vrele(ap->a_tdvp);
 
@@ -813,6 +923,7 @@ union_rename(ap)
                        goto bad;
                }
 
                        goto bad;
                }
 
+               FIXUP(un);
                fdvp = un->un_uppervp;
                VREF(fdvp);
                vrele(ap->a_fdvp);
                fdvp = un->un_uppervp;
                VREF(fdvp);
                vrele(ap->a_fdvp);
@@ -825,6 +936,7 @@ union_rename(ap)
                        goto bad;
                }
 
                        goto bad;
                }
 
+               FIXUP(un);
                fvp = un->un_uppervp;
                VREF(fvp);
                vrele(ap->a_fvp);
                fvp = un->un_uppervp;
                VREF(fvp);
                vrele(ap->a_fvp);
@@ -884,6 +996,7 @@ union_mkdir(ap)
                int error;
                struct vnode *vp;
 
                int error;
                struct vnode *vp;
 
+               FIXUP(un);
                VREF(dvp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
                VREF(dvp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
@@ -924,9 +1037,11 @@ union_rmdir(ap)
                struct vnode *dvp = dun->un_uppervp;
                struct vnode *vp = un->un_uppervp;
 
                struct vnode *dvp = dun->un_uppervp;
                struct vnode *vp = un->un_uppervp;
 
+               FIXUP(dun);
                VREF(dvp);
                dun->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
                VREF(dvp);
                dun->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
+               FIXUP(un);
                VREF(vp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_vp);
                VREF(vp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_vp);
@@ -968,6 +1083,7 @@ union_symlink(ap)
                struct vnode *vp;
                struct mount *mp = ap->a_dvp->v_mount;
 
                struct vnode *vp;
                struct mount *mp = ap->a_dvp->v_mount;
 
+               FIXUP(un);
                VREF(dvp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
                VREF(dvp);
                un->un_flags |= UN_KLOCK;
                vput(ap->a_dvp);
@@ -1000,8 +1116,10 @@ union_readdir(ap)
        int error = 0;
        struct union_node *un = VTOUNION(ap->a_vp);
 
        int error = 0;
        struct union_node *un = VTOUNION(ap->a_vp);
 
-       if (un->un_uppervp)
+       if (un->un_uppervp) {
+               FIXUP(un);
                error = VOP_READDIR(un->un_uppervp, ap->a_uio, ap->a_cred);
                error = VOP_READDIR(un->un_uppervp, ap->a_uio, ap->a_cred);
+       }
 
        return (error);
 }
 
        return (error);
 }
@@ -1020,6 +1138,8 @@ union_readlink(ap)
 
        if (dolock)
                VOP_LOCK(vp);
 
        if (dolock)
                VOP_LOCK(vp);
+       else
+               FIXUP(VTOUNION(ap->a_vp));
        error = VOP_READLINK(vp, ap->a_uio, ap->a_cred);
        if (dolock)
                VOP_UNLOCK(vp);
        error = VOP_READLINK(vp, ap->a_uio, ap->a_cred);
        if (dolock)
                VOP_UNLOCK(vp);
@@ -1040,8 +1160,12 @@ union_abortop(ap)
        int islocked = un->un_flags & UN_LOCKED;
        int dolock = (vp == LOWERVP(ap->a_dvp));
 
        int islocked = un->un_flags & UN_LOCKED;
        int dolock = (vp == LOWERVP(ap->a_dvp));
 
-       if (islocked && dolock)
-               VOP_LOCK(vp);
+       if (islocked) {
+               if (dolock)
+                       VOP_LOCK(vp);
+               else
+                       FIXUP(VTOUNION(ap->a_dvp));
+       }
        error = VOP_ABORTOP(vp, ap->a_cnp);
        if (islocked && dolock)
                VOP_UNLOCK(vp);
        error = VOP_ABORTOP(vp, ap->a_cnp);
        if (islocked && dolock)
                VOP_UNLOCK(vp);
@@ -1085,31 +1209,9 @@ union_reclaim(ap)
                struct vnode *a_vp;
        } */ *ap;
 {
                struct vnode *a_vp;
        } */ *ap;
 {
-       struct vnode *vp = ap->a_vp;
-       struct union_node *un = VTOUNION(vp);
-       struct vnode *uppervp = un->un_uppervp;
-       struct vnode *lowervp = un->un_lowervp;
-       struct vnode *dirvp = un->un_dirvp;
-       char *path = un->un_path;
 
 
-       /*
-        * Note: in vop_reclaim, vp->v_op == dead_vnodeop_p,
-        * so we can't call VOPs on ourself.
-        */
-       /* After this assignment, this node will not be re-used. */
-       un->un_uppervp = NULLVP;
-       un->un_lowervp = NULLVP;
-       un->un_dirvp = NULLVP;
-       un->un_path = NULL;
-       union_freevp(vp);
-       if (uppervp)
-               vrele(uppervp);
-       if (lowervp)
-               vrele(lowervp);
-       if (dirvp)
-               vrele(dirvp);
-       if (path)
-               free(path, M_TEMP);
+       union_freevp(ap->a_vp);
+
        return (0);
 }
 
        return (0);
 }
 
@@ -1117,12 +1219,21 @@ int
 union_lock(ap)
        struct vop_lock_args *ap;
 {
 union_lock(ap)
        struct vop_lock_args *ap;
 {
-       struct union_node *un = VTOUNION(ap->a_vp);
+       struct vnode *vp = ap->a_vp;
+       struct union_node *un;
+
+start:
+       while (vp->v_flag & VXLOCK) {
+               vp->v_flag |= VXWANT;
+               sleep((caddr_t)vp, PINOD);
+       }
+
+       un = VTOUNION(vp);
 
        if (un->un_uppervp) {
                if ((un->un_flags & UN_ULOCK) == 0) {
 
        if (un->un_uppervp) {
                if ((un->un_flags & UN_ULOCK) == 0) {
-                       VOP_LOCK(un->un_uppervp);
                        un->un_flags |= UN_ULOCK;
                        un->un_flags |= UN_ULOCK;
+                       VOP_LOCK(un->un_uppervp);
                }
 #ifdef DIAGNOSTIC
                if (un->un_flags & UN_KLOCK)
                }
 #ifdef DIAGNOSTIC
                if (un->un_flags & UN_KLOCK)
@@ -1130,7 +1241,7 @@ union_lock(ap)
 #endif
        }
 
 #endif
        }
 
-       while (un->un_flags & UN_LOCKED) {
+       if (un->un_flags & UN_LOCKED) {
 #ifdef DIAGNOSTIC
                if (curproc && un->un_pid == curproc->p_pid &&
                            un->un_pid > -1 && curproc->p_pid > -1)
 #ifdef DIAGNOSTIC
                if (curproc && un->un_pid == curproc->p_pid &&
                            un->un_pid > -1 && curproc->p_pid > -1)
@@ -1138,8 +1249,8 @@ union_lock(ap)
 #endif
                un->un_flags |= UN_WANT;
                sleep((caddr_t) &un->un_flags, PINOD);
 #endif
                un->un_flags |= UN_WANT;
                sleep((caddr_t) &un->un_flags, PINOD);
+               goto start;
        }
        }
-       un->un_flags |= UN_LOCKED;
 
 #ifdef DIAGNOSTIC
        if (curproc)
 
 #ifdef DIAGNOSTIC
        if (curproc)
@@ -1148,6 +1259,7 @@ union_lock(ap)
                un->un_pid = -1;
 #endif
 
                un->un_pid = -1;
 #endif
 
+       un->un_flags |= UN_LOCKED;
        return (0);
 }
 
        return (0);
 }
 
@@ -1200,6 +1312,8 @@ union_bmap(ap)
 
        if (dolock)
                VOP_LOCK(vp);
 
        if (dolock)
                VOP_LOCK(vp);
+       else
+               FIXUP(VTOUNION(ap->a_vp));
        error = VOP_BMAP(vp, ap->a_bn, ap->a_vpp, ap->a_bnp, ap->a_runp);
        if (dolock)
                VOP_UNLOCK(vp);
        error = VOP_BMAP(vp, ap->a_bn, ap->a_vpp, ap->a_bnp, ap->a_runp);
        if (dolock)
                VOP_UNLOCK(vp);
@@ -1244,6 +1358,8 @@ union_pathconf(ap)
 
        if (dolock)
                VOP_LOCK(vp);
 
        if (dolock)
                VOP_LOCK(vp);
+       else
+               FIXUP(VTOUNION(ap->a_vp));
        error = VOP_PATHCONF(vp, ap->a_name, ap->a_retval);
        if (dolock)
                VOP_UNLOCK(vp);
        error = VOP_PATHCONF(vp, ap->a_name, ap->a_retval);
        if (dolock)
                VOP_UNLOCK(vp);