Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/puffs Send VOP_ABORTOP() in case attempting cross-dev...



details:   https://anonhg.NetBSD.org/src/rev/7a9c2e339985
branches:  trunk
changeset: 749157:7a9c2e339985
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Nov 19 16:21:04 2009 +0000

description:
Send VOP_ABORTOP() in case attempting cross-dev rename, part of
PR kern/42210.  Also, fix a memory management error in said case.

diffstat:

 sys/fs/puffs/puffs_vnops.c |  41 +++++++++++++++++++++++++----------------
 1 files changed, 25 insertions(+), 16 deletions(-)

diffs (85 lines):

diff -r 098a133378c6 -r 7a9c2e339985 sys/fs/puffs/puffs_vnops.c
--- a/sys/fs/puffs/puffs_vnops.c        Thu Nov 19 15:50:49 2009 +0000
+++ b/sys/fs/puffs/puffs_vnops.c        Thu Nov 19 16:21:04 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_vnops.c,v 1.139 2009/11/19 15:50:49 pooka Exp $  */
+/*     $NetBSD: puffs_vnops.c,v 1.140 2009/11/19 16:21:04 pooka Exp $  */
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.139 2009/11/19 15:50:49 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.140 2009/11/19 16:21:04 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -1708,19 +1708,23 @@
                struct componentname *a_tcnp;
        } */ *ap = v;
        PUFFS_MSG_VARS(vn, rename);
-       struct vnode *fdvp = ap->a_fdvp;
+       struct vnode *fdvp = ap->a_fdvp, *fvp = ap->a_fvp;
+       struct vnode *tdvp = ap->a_tdvp, *tvp = ap->a_tvp;
        struct puffs_node *fpn = ap->a_fvp->v_data;
        struct puffs_mount *pmp = MPTOPUFFSMP(fdvp->v_mount);
        int error;
+       bool doabort = true;
 
-       if (ap->a_fvp->v_mount != ap->a_tdvp->v_mount)
+       if ((fvp->v_mount != tdvp->v_mount) ||
+           (tvp && (fvp->v_mount != tvp->v_mount))) {
                ERROUT(EXDEV);
+       }
 
        PUFFS_MSG_ALLOC(vn, rename);
-       rename_msg->pvnr_cookie_src = VPTOPNC(ap->a_fvp);
-       rename_msg->pvnr_cookie_targdir = VPTOPNC(ap->a_tdvp);
-       if (ap->a_tvp)
-               rename_msg->pvnr_cookie_targ = VPTOPNC(ap->a_tvp);
+       rename_msg->pvnr_cookie_src = VPTOPNC(fvp);
+       rename_msg->pvnr_cookie_targdir = VPTOPNC(tdvp);
+       if (tvp)
+               rename_msg->pvnr_cookie_targ = VPTOPNC(tvp);
        else
                rename_msg->pvnr_cookie_targ = NULL;
        puffs_makecn(&rename_msg->pvnr_cn_src, &rename_msg->pvnr_cn_src_cred,
@@ -1731,6 +1735,8 @@
            PUFFS_VN_RENAME, VPTOPNC(fdvp));
 
        PUFFS_MSG_ENQUEUEWAIT2(pmp, park_rename, fdvp->v_data, NULL, error);
+       doabort = false;
+       PUFFS_MSG_RELEASE(rename);
        error = checkerr(pmp, error, __func__);
 
        /*
@@ -1741,16 +1747,19 @@
                puffs_updatenode(fpn, PUFFS_UPDATECTIME, 0);
 
  out:
-       PUFFS_MSG_RELEASE(rename);
-       if (ap->a_tvp != NULL)
-               vput(ap->a_tvp);
-       if (ap->a_tdvp == ap->a_tvp)
-               vrele(ap->a_tdvp);
+       if (doabort)
+               VOP_ABORTOP(tdvp, ap->a_tcnp);
+       if (tvp != NULL)
+               vput(tvp);
+       if (tdvp == tvp)
+               vrele(tdvp);
        else
-               vput(ap->a_tdvp);
+               vput(tdvp);
 
-       vrele(ap->a_fdvp);
-       vrele(ap->a_fvp);
+       if (doabort)
+               VOP_ABORTOP(fdvp, ap->a_fcnp);
+       vrele(fdvp);
+       vrele(fvp);
 
        return error;
 }



Home | Main Index | Thread Index | Old Index