Move fstrans_start()/fstrans_done() into genfs_insane_rename() to protect

the complete rename operation like we do for all other vnode operations.
This commit is contained in:
hannken 2014-02-06 10:57:12 +00:00
parent 83d796ca12
commit 59e42c388a
3 changed files with 13 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: genfs_rename.c,v 1.1 2012/05/08 23:53:26 riastradh Exp $ */
/* $NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.1 2012/05/08 23:53:26 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $");
#include <sys/param.h>
#include <sys/kauth.h>
@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.1 2012/05/08 23:53:26 riastradh E
#include <sys/namei.h>
#include <sys/stat.h>
#include <sys/vnode.h>
#include <sys/fstrans.h>
#include <sys/types.h>
#include <miscfs/genfs/genfs.h>
@ -176,6 +177,7 @@ genfs_insane_rename(void *v,
struct componentname *fcnp = ap->a_fcnp;
struct vnode *tdvp = ap->a_tdvp;
struct vnode *tvp = ap->a_tvp;
struct mount *mp = fdvp->v_mount;
struct componentname *tcnp = ap->a_tcnp;
kauth_cred_t cred;
int error;
@ -194,6 +196,8 @@ genfs_insane_rename(void *v,
KASSERT(fdvp->v_type == VDIR);
KASSERT(tdvp->v_type == VDIR);
fstrans_start(mp, FSTRANS_SHARED);
cred = fcnp->cn_cred;
/*
@ -228,6 +232,8 @@ genfs_insane_rename(void *v,
vrele(fdvp);
vrele(tdvp);
fstrans_done(mp);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: lfs_rename.c,v 1.5 2014/01/28 13:12:22 martin Exp $ */
/* $NetBSD: lfs_rename.c,v 1.6 2014/02/06 10:57:12 hannken Exp $ */
/* from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp */
/*-
@ -89,7 +89,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.5 2014/01/28 13:12:22 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.6 2014/02/06 10:57:12 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -108,7 +108,6 @@ __KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.5 2014/01/28 13:12:22 martin Exp $"
#include <sys/signalvar.h>
#include <sys/kauth.h>
#include <sys/syslog.h>
#include <sys/fstrans.h>
#include <uvm/uvm.h>
#include <uvm/uvm_pmap.h>
@ -518,8 +517,6 @@ ulfs_gro_remove(struct mount *mp, kauth_cred_t cred,
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
KASSERT(cnp->cn_nameiop == DELETE);
fstrans_start(mp, FSTRANS_SHARED);
/* XXX ulfs_dirremove decrements vp's link count for us. */
error = ulfs_dirremove(dvp, ulr, VTOI(vp), cnp->cn_flags, 0);
if (error)
@ -529,7 +526,6 @@ ulfs_gro_remove(struct mount *mp, kauth_cred_t cred,
VN_KNOTE(vp, (VTOI(vp)->i_nlink? NOTE_LINK : NOTE_DELETE));
out1:
fstrans_done(mp);
return error;
}
@ -831,7 +827,6 @@ ulfs_gro_rename(struct mount *mp, kauth_cred_t cred,
* Commence hacking of the data on disk.
*/
fstrans_start(mp, FSTRANS_SHARED);
error = 0;
/*
@ -1046,7 +1041,6 @@ whymustithurtsomuch:
arghmybrainhurts:
/*ihateyou:*/
fstrans_done(mp);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs_rename.c,v 1.9 2013/11/04 19:58:02 christos Exp $ */
/* $NetBSD: ufs_rename.c,v 1.10 2014/02/06 10:57:12 hannken Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@ -34,12 +34,11 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ufs_rename.c,v 1.9 2013/11/04 19:58:02 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ufs_rename.c,v 1.10 2014/02/06 10:57:12 hannken Exp $");
#include <sys/param.h>
#include <sys/buf.h>
#include <sys/errno.h>
#include <sys/fstrans.h>
#include <sys/kauth.h>
#include <sys/mount.h>
#include <sys/namei.h>
@ -334,7 +333,6 @@ ufs_gro_rename(struct mount *mp, kauth_cred_t cred,
* Commence hacking of the data on disk.
*/
fstrans_start(mp, FSTRANS_SHARED);
error = UFS_WAPBL_BEGIN(mp);
if (error)
goto ihateyou;
@ -555,7 +553,6 @@ arghmybrainhurts:
UFS_WAPBL_END(mp);
ihateyou:
fstrans_done(mp);
return error;
}
@ -786,7 +783,6 @@ ufs_gro_remove(struct mount *mp, kauth_cred_t cred,
KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
KASSERT(cnp->cn_nameiop == DELETE);
fstrans_start(mp, FSTRANS_SHARED);
error = UFS_WAPBL_BEGIN(mp);
if (error)
goto out0;
@ -800,7 +796,7 @@ ufs_gro_remove(struct mount *mp, kauth_cred_t cred,
VN_KNOTE(vp, (VTOI(vp)->i_nlink? NOTE_LINK : NOTE_DELETE));
out1: UFS_WAPBL_END(mp);
out0: fstrans_done(mp);
out0:
return error;
}