There is no WAPBL in LFS.

This commit is contained in:
dholland 2013-06-08 22:05:15 +00:00
parent 15c1f6b300
commit 9416340bc0
9 changed files with 34 additions and 399 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_inode.c,v 1.6 2013/06/08 21:40:27 dholland Exp $ */
/* $NetBSD: ulfs_inode.c,v 1.7 2013/06/08 22:05:15 dholland Exp $ */
/* from NetBSD: ufs_inode.c,v 1.89 2013/01/22 09:39:18 dholland Exp */
/*
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_inode.c,v 1.6 2013/06/08 21:40:27 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_inode.c,v 1.7 2013/06/08 22:05:15 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@ -61,7 +61,6 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_inode.c,v 1.6 2013/06/08 21:40:27 dholland Exp
#include <ufs/lfs/ulfs_inode.h>
#include <ufs/lfs/ulfsmount.h>
#include <ufs/lfs/ulfs_extern.h>
#include <ufs/lfs/ulfs_wapbl.h>
#ifdef LFS_DIRHASH
#include <ufs/lfs/ulfs_dirhash.h>
#endif
@ -88,9 +87,6 @@ ulfs_inactive(void *v)
struct mount *transmp;
mode_t mode;
int error = 0;
int logged = 0;
ULFS_WAPBL_JUNLOCK_ASSERT(vp->v_mount);
transmp = vp->v_mount;
fstrans_start(transmp, FSTRANS_LAZY);
@ -103,13 +99,8 @@ ulfs_inactive(void *v)
#ifdef LFS_EXTATTR
ulfs_extattr_vnode_inactive(vp, curlwp);
#endif
error = ULFS_WAPBL_BEGIN(vp->v_mount);
if (error)
goto out;
logged = 1;
if (ip->i_size != 0) {
if (!error)
error = ULFS_TRUNCATE(vp, (off_t)0, 0, NOCRED);
error = ULFS_TRUNCATE(vp, (off_t)0, 0, NOCRED);
}
#if defined(LFS_QUOTA) || defined(LFS_QUOTA2)
(void)lfs_chkiq(ip, -1, NOCRED, 0);
@ -126,16 +117,9 @@ ulfs_inactive(void *v)
}
if (ip->i_flag & (IN_CHANGE | IN_UPDATE | IN_MODIFIED)) {
if (!logged++) {
int err;
err = ULFS_WAPBL_BEGIN(vp->v_mount);
if (err)
goto out;
}
ULFS_UPDATE(vp, NULL, NULL, 0);
}
if (logged)
ULFS_WAPBL_END(vp->v_mount);
out:
/*
* If we are done with the inode, reclaim it
@ -158,10 +142,9 @@ ulfs_reclaim(struct vnode *vp)
if (prtactive && vp->v_usecount > 1)
vprint("ulfs_reclaim: pushing active", vp);
if (!ULFS_WAPBL_BEGIN(vp->v_mount)) {
ULFS_UPDATE(vp, NULL, NULL, UPDATE_CLOSE);
ULFS_WAPBL_END(vp->v_mount);
}
/* XXX: do we really need two of these? */
/* note: originally the first was inside a wapbl txn */
ULFS_UPDATE(vp, NULL, NULL, UPDATE_CLOSE);
ULFS_UPDATE(vp, NULL, NULL, UPDATE_CLOSE);
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_lookup.c,v 1.9 2013/06/08 02:14:46 dholland Exp $ */
/* $NetBSD: ulfs_lookup.c,v 1.10 2013/06/08 22:05:15 dholland Exp $ */
/* from NetBSD: ufs_lookup.c,v 1.122 2013/01/22 09:39:18 dholland Exp */
/*
@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.9 2013/06/08 02:14:46 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.10 2013/06/08 22:05:15 dholland Exp $");
#ifdef _KERNEL_OPT
#include "opt_lfs.h"
@ -67,7 +67,6 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.9 2013/06/08 02:14:46 dholland Exp
#include <ufs/lfs/ulfsmount.h>
#include <ufs/lfs/ulfs_extern.h>
#include <ufs/lfs/ulfs_bswap.h>
#include <ufs/lfs/ulfs_wapbl.h>
#include <miscfs/genfs/genfs.h>
@ -535,7 +534,6 @@ found:
results->ulr_offset + LFS_DIRSIZ(FSFMT(vdp), ep, needswap);
DIP_ASSIGN(dp, size, dp->i_size);
dp->i_flag |= IN_CHANGE | IN_UPDATE;
ULFS_WAPBL_UPDATE(vdp, NULL, NULL, UPDATE_DIROP);
}
brelse(bp, 0);
@ -827,8 +825,6 @@ ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
const int needswap = ULFS_MPNEEDSWAP(ump);
int dirblksiz = ump->um_dirblksiz;
ULFS_WAPBL_JLOCK_ASSERT(dvp->v_mount);
error = 0;
cr = cnp->cn_cred;
l = curlwp;
@ -908,7 +904,6 @@ ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
dp->i_size = ulr->ulr_offset + ulr->ulr_count;
DIP_ASSIGN(dp, size, dp->i_size);
dp->i_flag |= IN_CHANGE | IN_UPDATE;
ULFS_WAPBL_UPDATE(dvp, NULL, NULL, UPDATE_DIROP);
}
/*
* Get the block containing the space for the new directory entry.
@ -1024,7 +1019,6 @@ ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
#endif
(void) ULFS_TRUNCATE(dvp, (off_t)ulr->ulr_endoff, IO_SYNC, cr);
}
ULFS_WAPBL_UPDATE(dvp, NULL, NULL, UPDATE_DIROP);
return (error);
}
@ -1075,8 +1069,6 @@ ulfs_dirremove(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
const int needswap = ULFS_MPNEEDSWAP(dp->i_ump);
#endif
ULFS_WAPBL_JLOCK_ASSERT(dvp->v_mount);
if (flags & DOWHITEOUT) {
/*
* Whiteout entry: set d_ino to ULFS_WINO.
@ -1133,7 +1125,6 @@ out:
ip->i_nlink--;
DIP_ASSIGN(ip, nlink, ip->i_nlink);
ip->i_flag |= IN_CHANGE;
ULFS_WAPBL_UPDATE(ITOV(ip), NULL, NULL, 0);
}
/*
* XXX did it ever occur to anyone that it might be a good
@ -1152,7 +1143,6 @@ out:
if (ip != 0 && (ip->i_flags & SF_SNAPSHOT) != 0 &&
ip->i_nlink == 0)
ulfs_snapgone(ip);
ULFS_WAPBL_UPDATE(dvp, NULL, NULL, 0);
return (error);
}
@ -1191,7 +1181,6 @@ ulfs_dirrewrite(struct inode *dp, off_t offset,
oip->i_nlink--;
DIP_ASSIGN(oip, nlink, oip->i_nlink);
oip->i_flag |= IN_CHANGE;
ULFS_WAPBL_UPDATE(ITOV(oip), NULL, NULL, UPDATE_DIROP);
error = VOP_BWRITE(bp->b_vp, bp);
dp->i_flag |= iflags;
/*
@ -1201,7 +1190,6 @@ ulfs_dirrewrite(struct inode *dp, off_t offset,
*/
if ((oip->i_flags & SF_SNAPSHOT) != 0 && oip->i_nlink == 0)
ulfs_snapgone(oip);
ULFS_WAPBL_UPDATE(vdp, NULL, NULL, UPDATE_DIROP);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_quota2.c,v 1.5 2013/06/06 00:49:28 dholland Exp $ */
/* $NetBSD: ulfs_quota2.c,v 1.6 2013/06/08 22:05:15 dholland Exp $ */
/* from NetBSD: ufs_quota2.c,v 1.35 2012/09/27 07:47:56 bouyer Exp */
/*-
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.5 2013/06/06 00:49:28 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.6 2013/06/08 22:05:15 dholland Exp $");
#include <sys/buf.h>
#include <sys/param.h>
@ -51,7 +51,6 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.5 2013/06/06 00:49:28 dholland Exp
#include <ufs/lfs/ulfs_bswap.h>
#include <ufs/lfs/ulfs_extern.h>
#include <ufs/lfs/ulfs_quota.h>
#include <ufs/lfs/ulfs_wapbl.h>
/*
* LOCKING:
@ -380,9 +379,6 @@ getinoquota2(struct inode *ip, bool alloc, bool modify, struct buf **bpp,
if (error)
return error;
if (alloc) {
ULFS_WAPBL_JLOCK_ASSERT(ump->um_mountp);
}
ino_ids[ULFS_USRQUOTA] = ip->i_uid;
ino_ids[ULFS_GRPQUOTA] = ip->i_gid;
/* first get the interlock for all dquot */
@ -594,9 +590,6 @@ lfsquota2_handle_cmd_put(struct ulfsmount *ump, const struct quotakey *key,
if (ump->um_quotas[key->qk_idtype] == NULLVP)
return ENODEV;
error = ULFS_WAPBL_BEGIN(ump->um_mountp);
if (error)
return error;
if (key->qk_id == QUOTA_DEFAULTID) {
mutex_enter(&lfs_dqlock);
@ -641,7 +634,6 @@ out_il:
mutex_exit(&dq->dq_interlock);
lfs_dqrele(NULLVP, dq);
out_wapbl:
ULFS_WAPBL_END(ump->um_mountp);
return error;
}
@ -720,10 +712,7 @@ lfsquota2_handle_cmd_delete(struct ulfsmount *ump, const struct quotakey *qk)
error = ENOENT;
goto out_il;
}
error = ULFS_WAPBL_BEGIN(ump->um_mountp);
if (error)
goto out_dq;
error = getq2e(ump, idtype, dq->dq2_lblkno, dq->dq2_blkoff,
&bp, &q2ep, B_MODIFY);
if (error)
@ -782,10 +771,8 @@ lfsquota2_handle_cmd_delete(struct ulfsmount *ump, const struct quotakey *qk)
out_dqlock:
mutex_exit(&lfs_dqlock);
out_wapbl:
ULFS_WAPBL_END(ump->um_mountp);
out_il:
mutex_exit(&dq->dq_interlock);
out_dq:
lfs_dqrele(NULLVP, dq);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_readwrite.c,v 1.2 2013/06/06 00:48:04 dholland Exp $ */
/* $NetBSD: ulfs_readwrite.c,v 1.3 2013/06/08 22:05:15 dholland Exp $ */
/* from NetBSD: ufs_readwrite.c,v 1.105 2013/01/22 09:39:18 dholland Exp */
/*-
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.2 2013/06/06 00:48:04 dholland Exp $");
__KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.3 2013/06/08 22:05:15 dholland Exp $");
#ifdef LFS_READWRITE
#define FS struct lfs
@ -44,9 +44,6 @@ __KERNEL_RCSID(1, "$NetBSD: ulfs_readwrite.c,v 1.2 2013/06/06 00:48:04 dholland
#define WRITE_S "lfs_write"
#define fs_bsize lfs_bsize
#define fs_bmask lfs_bmask
#define ULFS_WAPBL_BEGIN(mp) 0
#define ULFS_WAPBL_END(mp) do { } while (0)
#define ULFS_WAPBL_UPDATE(vp, access, modify, flags) do { } while (0)
#else
#define FS struct fs
#define I_FS i_fs
@ -186,13 +183,7 @@ READ(void *v)
if (!(vp->v_mount->mnt_flag & MNT_NOATIME)) {
ip->i_flag |= IN_ACCESS;
if ((ap->a_ioflag & IO_SYNC) == IO_SYNC) {
error = ULFS_WAPBL_BEGIN(vp->v_mount);
if (error) {
fstrans_done(vp->v_mount);
return error;
}
error = ULFS_UPDATE(vp, NULL, NULL, UPDATE_WAIT);
ULFS_WAPBL_END(vp->v_mount);
}
}
@ -285,14 +276,6 @@ WRITE(void *v)
usepc = vp->v_type == VREG;
if ((ioflag & IO_JOURNALLOCKED) == 0) {
error = ULFS_WAPBL_BEGIN(vp->v_mount);
if (error) {
fstrans_done(vp->v_mount);
return error;
}
}
#ifdef LFS_READWRITE
async = true;
lfs_availwait(fs, btofsb(fs, uio->uio_resid));
@ -534,13 +517,12 @@ out:
(void) ULFS_TRUNCATE(vp, osize, ioflag & IO_SYNC, ap->a_cred);
uio->uio_offset -= resid - uio->uio_resid;
uio->uio_resid = resid;
} else if (resid > uio->uio_resid && (ioflag & IO_SYNC) == IO_SYNC)
} else if (resid > uio->uio_resid && (ioflag & IO_SYNC) == IO_SYNC) {
error = ULFS_UPDATE(vp, NULL, NULL, UPDATE_WAIT);
else
ULFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
} else {
/* nothing */
}
KASSERT(vp->v_size == ip->i_size);
if ((ioflag & IO_JOURNALLOCKED) == 0)
ULFS_WAPBL_END(vp->v_mount);
fstrans_done(vp->v_mount);
return (error);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_rename.c,v 1.6 2013/06/08 02:14:46 dholland Exp $ */
/* $NetBSD: ulfs_rename.c,v 1.7 2013/06/08 22:05:15 dholland Exp $ */
/* from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp */
/*-
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_rename.c,v 1.6 2013/06/08 02:14:46 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_rename.c,v 1.7 2013/06/08 22:05:15 dholland Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@ -55,7 +55,6 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_rename.c,v 1.6 2013/06/08 02:14:46 dholland Exp
#include <ufs/lfs/ulfs_inode.h>
#include <ufs/lfs/ulfs_bswap.h>
#include <ufs/lfs/ulfs_extern.h>
#include <ufs/lfs/ulfs_wapbl.h>
#include <ufs/lfs/ulfsmount.h>
/*
@ -336,9 +335,7 @@ ulfs_gro_rename(struct mount *mp, kauth_cred_t cred,
*/
fstrans_start(mp, FSTRANS_SHARED);
error = ULFS_WAPBL_BEGIN(mp);
if (error)
goto ihateyou;
error = 0;
/*
* 1) Bump link count while we're moving stuff
@ -449,7 +446,6 @@ ulfs_gro_rename(struct mount *mp, kauth_cred_t cred,
VTOI(tdvp)->i_nlink--;
DIP_ASSIGN(VTOI(tdvp), nlink, VTOI(tdvp)->i_nlink);
VTOI(tdvp)->i_flag |= IN_CHANGE;
ULFS_WAPBL_UPDATE(tdvp, NULL, NULL, 0);
}
if (directory_p) {
@ -550,12 +546,9 @@ whymustithurtsomuch:
VTOI(fvp)->i_nlink--;
DIP_ASSIGN(VTOI(fvp), nlink, VTOI(fvp)->i_nlink);
VTOI(fvp)->i_flag |= IN_CHANGE;
ULFS_WAPBL_UPDATE(fvp, NULL, NULL, 0);
arghmybrainhurts:
ULFS_WAPBL_END(mp);
ihateyou:
/*ihateyou:*/
fstrans_done(mp);
return error;
}
@ -788,9 +781,6 @@ ulfs_gro_remove(struct mount *mp, kauth_cred_t cred,
KASSERT(cnp->cn_nameiop == DELETE);
fstrans_start(mp, FSTRANS_SHARED);
error = ULFS_WAPBL_BEGIN(mp);
if (error)
goto out0;
/* XXX ulfs_dirremove decrements vp's link count for us. */
error = ulfs_dirremove(dvp, ulr, VTOI(vp), cnp->cn_flags, 0);
@ -800,8 +790,8 @@ ulfs_gro_remove(struct mount *mp, kauth_cred_t cred,
VN_KNOTE(dvp, NOTE_WRITE);
VN_KNOTE(vp, (VTOI(vp)->i_nlink? NOTE_LINK : NOTE_DELETE));
out1: ULFS_WAPBL_END(mp);
out0: fstrans_done(mp);
out1:
fstrans_done(mp);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_snapshot.c,v 1.1 2013/06/06 00:50:51 dholland Exp $ */
/* $NetBSD: ulfs_snapshot.c,v 1.2 2013/06/08 22:05:15 dholland Exp $ */
/* from ffs_snapshot.c,v 1.122 2013/05/07 09:40:54 hannken Exp */
/*
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_snapshot.c,v 1.1 2013/06/06 00:50:51 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_snapshot.c,v 1.2 2013/06/08 22:05:15 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@ -70,7 +70,6 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_snapshot.c,v 1.1 2013/06/06 00:50:51 dholland E
#include <ufs/lfs/ulfs_inode.h>
#include <ufs/lfs/ulfs_extern.h>
#include <ufs/lfs/ulfs_bswap.h>
#include <ufs/lfs/ulfs_wapbl.h>
#include <ufs/lfs/lfs.h>
#include <ufs/lfs/lfs_extern.h>

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_vnops.c,v 1.11 2013/06/08 21:40:27 dholland Exp $ */
/* $NetBSD: ulfs_vnops.c,v 1.12 2013/06/08 22:05:15 dholland Exp $ */
/* from NetBSD: ufs_vnops.c,v 1.213 2013/06/08 05:47:02 kardel Exp */
/*-
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.11 2013/06/08 21:40:27 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.12 2013/06/08 22:05:15 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@ -102,7 +102,6 @@ __KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.11 2013/06/08 21:40:27 dholland Exp
#include <ufs/lfs/ulfsmount.h>
#include <ufs/lfs/ulfs_bswap.h>
#include <ufs/lfs/ulfs_extern.h>
#include <ufs/lfs/ulfs_wapbl.h>
#ifdef LFS_DIRHASH
#include <ufs/lfs/ulfs_dirhash.h>
#endif
@ -143,10 +142,6 @@ ulfs_create(void *v)
ulr = &VTOI(dvp)->i_crap;
ULFS_CHECK_CRAPCOUNTER(VTOI(dvp));
/*
* ULFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful
* ulfs_makeinode
*/
fstrans_start(dvp->v_mount, FSTRANS_SHARED);
error =
ulfs_makeinode(MAKEIMODE(ap->a_vap->va_type, ap->a_vap->va_mode),
@ -155,7 +150,6 @@ ulfs_create(void *v)
fstrans_done(dvp->v_mount);
return (error);
}
ULFS_WAPBL_END1(dvp->v_mount, dvp);
fstrans_done(dvp->v_mount);
VN_KNOTE(dvp, NOTE_WRITE);
return (0);
@ -189,10 +183,6 @@ ulfs_mknod(void *v)
ulr = &VTOI(ap->a_dvp)->i_crap;
ULFS_CHECK_CRAPCOUNTER(VTOI(ap->a_dvp));
/*
* ULFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful
* ulfs_makeinode
*/
fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED);
if ((error =
ulfs_makeinode(MAKEIMODE(vap->va_type, vap->va_mode),
@ -216,8 +206,6 @@ ulfs_mknod(void *v)
ip->i_ffs2_rdev = ulfs_rw64(vap->va_rdev,
ULFS_MPNEEDSWAP(ump));
}
ULFS_WAPBL_UPDATE(*vpp, NULL, NULL, 0);
ULFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp);
/*
* Remove inode so that it will be reloaded by VFS_VGET and
* checked to see if it is an alias of an existing entry in
@ -510,22 +498,14 @@ ulfs_setattr(void *v)
goto out;
if (changing_sysflags) {
error = ULFS_WAPBL_BEGIN(vp->v_mount);
if (error)
goto out;
ip->i_flags = vap->va_flags;
DIP_ASSIGN(ip, flags, ip->i_flags);
} else {
error = ULFS_WAPBL_BEGIN(vp->v_mount);
if (error)
goto out;
ip->i_flags &= SF_SETTABLE;
ip->i_flags |= (vap->va_flags & UF_SETTABLE);
DIP_ASSIGN(ip, flags, ip->i_flags);
}
ip->i_flag |= IN_CHANGE;
ULFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
ULFS_WAPBL_END(vp->v_mount);
if (vap->va_flags & (IMMUTABLE | APPEND)) {
error = 0;
goto out;
@ -543,11 +523,7 @@ ulfs_setattr(void *v)
error = EROFS;
goto out;
}
error = ULFS_WAPBL_BEGIN(vp->v_mount);
if (error)
goto out;
error = ulfs_chown(vp, vap->va_uid, vap->va_gid, cred, l);
ULFS_WAPBL_END(vp->v_mount);
if (error)
goto out;
}
@ -574,12 +550,7 @@ ulfs_setattr(void *v)
error = EPERM;
goto out;
}
error = ULFS_WAPBL_BEGIN(vp->v_mount);
if (error)
goto out;
if (!error)
error = ULFS_TRUNCATE(vp, vap->va_size, 0, cred);
ULFS_WAPBL_END(vp->v_mount);
error = ULFS_TRUNCATE(vp, vap->va_size, 0, cred);
if (error)
goto out;
break;
@ -601,9 +572,6 @@ ulfs_setattr(void *v)
}
error = kauth_authorize_vnode(cred, KAUTH_VNODE_WRITE_TIMES, vp,
NULL, genfs_can_chtimes(vp, vap->va_vaflags, ip->i_uid, cred));
if (error)
goto out;
error = ULFS_WAPBL_BEGIN(vp->v_mount);
if (error)
goto out;
if (vap->va_atime.tv_sec != VNOVAL)
@ -620,7 +588,6 @@ ulfs_setattr(void *v)
ip->i_ffs2_birthnsec = vap->va_birthtime.tv_nsec;
}
error = ULFS_UPDATE(vp, &vap->va_atime, &vap->va_mtime, 0);
ULFS_WAPBL_END(vp->v_mount);
if (error)
goto out;
}
@ -636,11 +603,7 @@ ulfs_setattr(void *v)
error = EPERM;
goto out;
}
error = ULFS_WAPBL_BEGIN(vp->v_mount);
if (error)
goto out;
error = ulfs_chmod(vp, (int)vap->va_mode, cred, l);
ULFS_WAPBL_END(vp->v_mount);
}
VN_KNOTE(vp, NOTE_ATTRIB);
out:
@ -658,8 +621,6 @@ ulfs_chmod(struct vnode *vp, int mode, kauth_cred_t cred, struct lwp *l)
struct inode *ip;
int error;
ULFS_WAPBL_JLOCK_ASSERT(vp->v_mount);
ip = VTOI(vp);
error = kauth_authorize_vnode(cred, KAUTH_VNODE_WRITE_SECURITY, vp,
@ -672,7 +633,6 @@ ulfs_chmod(struct vnode *vp, int mode, kauth_cred_t cred, struct lwp *l)
ip->i_mode |= (mode & ALLPERMS);
ip->i_flag |= IN_CHANGE;
DIP_ASSIGN(ip, mode, ip->i_mode);
ULFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
fstrans_done(vp->v_mount);
return (0);
}
@ -735,7 +695,6 @@ ulfs_chown(struct vnode *vp, uid_t uid, gid_t gid, kauth_cred_t cred,
good:
#endif /* LFS_QUOTA || LFS_QUOTA2 */
ip->i_flag |= IN_CHANGE;
ULFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
fstrans_done(vp->v_mount);
return (0);
}
@ -766,12 +725,8 @@ ulfs_remove(void *v)
(VTOI(dvp)->i_flags & APPEND))
error = EPERM;
else {
error = ULFS_WAPBL_BEGIN(dvp->v_mount);
if (error == 0) {
error = ulfs_dirremove(dvp, ulr,
ip, ap->a_cnp->cn_flags, 0);
ULFS_WAPBL_END(dvp->v_mount);
}
error = ulfs_dirremove(dvp, ulr,
ip, ap->a_cnp->cn_flags, 0);
}
VN_KNOTE(vp, NOTE_DELETE);
VN_KNOTE(dvp, NOTE_WRITE);
@ -828,11 +783,6 @@ ulfs_link(void *v)
error = EPERM;
goto out1;
}
error = ULFS_WAPBL_BEGIN(vp->v_mount);
if (error) {
VOP_ABORTOP(dvp, cnp);
goto out1;
}
ip->i_nlink++;
DIP_ASSIGN(ip, nlink, ip->i_nlink);
ip->i_flag |= IN_CHANGE;
@ -847,9 +797,7 @@ ulfs_link(void *v)
ip->i_nlink--;
DIP_ASSIGN(ip, nlink, ip->i_nlink);
ip->i_flag |= IN_CHANGE;
ULFS_WAPBL_UPDATE(vp, NULL, NULL, UPDATE_DIROP);
}
ULFS_WAPBL_END(vp->v_mount);
out1:
VOP_UNLOCK(vp);
out2:
@ -893,9 +841,6 @@ ulfs_whiteout(void *v)
case CREATE:
/* create a new directory whiteout */
fstrans_start(dvp->v_mount, FSTRANS_SHARED);
error = ULFS_WAPBL_BEGIN(dvp->v_mount);
if (error)
break;
#ifdef DIAGNOSTIC
if (ump->um_maxsymlinklen <= 0)
panic("ulfs_whiteout: old format filesystem");
@ -915,9 +860,6 @@ ulfs_whiteout(void *v)
case DELETE:
/* remove an existing directory whiteout */
fstrans_start(dvp->v_mount, FSTRANS_SHARED);
error = ULFS_WAPBL_BEGIN(dvp->v_mount);
if (error)
break;
#ifdef DIAGNOSTIC
if (ump->um_maxsymlinklen <= 0)
panic("ulfs_whiteout: old format filesystem");
@ -930,7 +872,6 @@ ulfs_whiteout(void *v)
panic("ulfs_whiteout: unknown op");
/* NOTREACHED */
}
ULFS_WAPBL_END(dvp->v_mount);
fstrans_done(dvp->v_mount);
return (error);
}
@ -979,12 +920,6 @@ ulfs_mkdir(void *v)
tvp = *ap->a_vpp;
ip = VTOI(tvp);
error = ULFS_WAPBL_BEGIN(ap->a_dvp->v_mount);
if (error) {
ULFS_VFREE(tvp, ip->i_number, dmode);
vput(tvp);
goto out;
}
ip->i_uid = kauth_cred_geteuid(cnp->cn_cred);
DIP_ASSIGN(ip, uid, ip->i_uid);
ip->i_gid = dp->i_gid;
@ -992,7 +927,6 @@ ulfs_mkdir(void *v)
#if defined(LFS_QUOTA) || defined(LFS_QUOTA2)
if ((error = lfs_chkiq(ip, 1, cnp->cn_cred, 0))) {
ULFS_VFREE(tvp, ip->i_number, dmode);
ULFS_WAPBL_END(dvp->v_mount);
fstrans_done(dvp->v_mount);
vput(tvp);
vput(dvp);
@ -1071,12 +1005,10 @@ ulfs_mkdir(void *v)
bad:
if (error == 0) {
VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
ULFS_WAPBL_END(dvp->v_mount);
} else {
dp->i_nlink--;
DIP_ASSIGN(dp, nlink, dp->i_nlink);
dp->i_flag |= IN_CHANGE;
ULFS_WAPBL_UPDATE(dvp, NULL, NULL, UPDATE_DIROP);
/*
* No need to do an explicit ULFS_TRUNCATE here, vrele will
* do this for us because we set the link count to 0.
@ -1086,8 +1018,6 @@ ulfs_mkdir(void *v)
ip->i_flag |= IN_CHANGE;
/* If IN_ADIROP, account for it */
ULFS_UNMARK_VNODE(tvp);
ULFS_WAPBL_UPDATE(tvp, NULL, NULL, UPDATE_DIROP);
ULFS_WAPBL_END(dvp->v_mount);
vput(tvp);
}
out:
@ -1151,9 +1081,6 @@ ulfs_rmdir(void *v)
error = EPERM;
goto out;
}
error = ULFS_WAPBL_BEGIN(dvp->v_mount);
if (error)
goto out;
/*
* Delete reference to directory before purging
* inode. If we crash in between, the directory
@ -1161,7 +1088,6 @@ ulfs_rmdir(void *v)
*/
error = ulfs_dirremove(dvp, ulr, ip, cnp->cn_flags, 1);
if (error) {
ULFS_WAPBL_END(dvp->v_mount);
goto out;
}
VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
@ -1174,17 +1100,11 @@ ulfs_rmdir(void *v)
dp->i_nlink--;
DIP_ASSIGN(dp, nlink, dp->i_nlink);
dp->i_flag |= IN_CHANGE;
ULFS_WAPBL_UPDATE(dvp, NULL, NULL, UPDATE_DIROP);
ip->i_nlink--;
DIP_ASSIGN(ip, nlink, ip->i_nlink);
ip->i_flag |= IN_CHANGE;
error = ULFS_TRUNCATE(vp, (off_t)0, IO_SYNC, cnp->cn_cred);
cache_purge(vp);
/*
* Unlock the log while we still have reference to unlinked
* directory vp so that it will not get locked for recycling
*/
ULFS_WAPBL_END(dvp->v_mount);
#ifdef LFS_DIRHASH
if (ip->i_dirhash != NULL)
ulfsdirhash_free(ip);
@ -1221,10 +1141,6 @@ ulfs_symlink(void *v)
ulr = &VTOI(ap->a_dvp)->i_crap;
ULFS_CHECK_CRAPCOUNTER(VTOI(ap->a_dvp));
/*
* ULFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful
* ulfs_makeinode
*/
fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED);
error = ulfs_makeinode(LFS_IFLNK | ap->a_vap->va_mode, ap->a_dvp, ulr,
vpp, ap->a_cnp);
@ -1242,12 +1158,10 @@ ulfs_symlink(void *v)
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (vp->v_mount->mnt_flag & MNT_RELATIME)
ip->i_flag |= IN_ACCESS;
ULFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
} else
error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED | IO_JOURNALLOCKED,
ap->a_cnp->cn_cred, NULL, NULL);
ULFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp);
if (error)
vput(vp);
out:
@ -1763,8 +1677,6 @@ ulfs_makeinode(int mode, struct vnode *dvp, const struct ulfs_lookup_results *ul
struct vnode *tvp;
int error;
ULFS_WAPBL_JUNLOCK_ASSERT(dvp->v_mount);
pdir = VTOI(dvp);
if ((mode & LFS_IFMT) == 0)
@ -1780,21 +1692,9 @@ ulfs_makeinode(int mode, struct vnode *dvp, const struct ulfs_lookup_results *ul
DIP_ASSIGN(ip, gid, ip->i_gid);
ip->i_uid = kauth_cred_geteuid(cnp->cn_cred);
DIP_ASSIGN(ip, uid, ip->i_uid);
error = ULFS_WAPBL_BEGIN1(dvp->v_mount, dvp);
if (error) {
/*
* Note, we can't VOP_VFREE(tvp) here like we should
* because we can't write to the disk. Instead, we leave
* the vnode dangling from the journal.
*/
vput(tvp);
vput(dvp);
return (error);
}
#if defined(LFS_QUOTA) || defined(LFS_QUOTA2)
if ((error = lfs_chkiq(ip, 1, cnp->cn_cred, 0))) {
ULFS_VFREE(tvp, ip->i_number, mode);
ULFS_WAPBL_END1(dvp->v_mount, dvp);
vput(tvp);
vput(dvp);
return (error);
@ -1848,9 +1748,7 @@ ulfs_makeinode(int mode, struct vnode *dvp, const struct ulfs_lookup_results *ul
ip->i_flag |= IN_CHANGE;
/* If IN_ADIROP, account for it */
ULFS_UNMARK_VNODE(tvp);
ULFS_WAPBL_UPDATE(tvp, NULL, NULL, 0);
tvp->v_type = VNON; /* explodes later if VBLK */
ULFS_WAPBL_END1(dvp->v_mount, dvp);
vput(tvp);
vput(dvp);
return (error);
@ -1900,7 +1798,6 @@ ulfs_gop_alloc(struct vnode *vp, off_t off, off_t len, int flags,
}
out:
ULFS_WAPBL_UPDATE(vp, NULL, NULL, 0);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_wapbl.c,v 1.4 2013/06/06 00:51:25 dholland Exp $ */
/* $NetBSD: ulfs_wapbl.c,v 1.5 2013/06/08 22:05:15 dholland Exp $ */
/* from NetBSD: ufs_wapbl.c,v 1.23 2012/01/27 19:22:50 para Exp */
/*-
@ -67,99 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ulfs_wapbl.c,v 1.4 2013/06/06 00:51:25 dholland Exp $");
__KERNEL_RCSID(0, "$NetBSD: ulfs_wapbl.c,v 1.5 2013/06/08 22:05:15 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/namei.h>
#include <sys/resourcevar.h>
#include <sys/kernel.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/buf.h>
#include <sys/proc.h>
#include <sys/mount.h>
#include <sys/vnode.h>
#include <sys/dirent.h>
#include <sys/lockf.h>
#include <sys/kauth.h>
#include <sys/wapbl.h>
#include <sys/fstrans.h>
#include <miscfs/specfs/specdev.h>
#include <miscfs/fifofs/fifo.h>
#include <ufs/lfs/ulfs_quotacommon.h>
#include <ufs/lfs/ulfs_inode.h>
#include <ufs/lfs/ulfs_dir.h>
#include <ufs/lfs/ulfsmount.h>
#include <ufs/lfs/ulfs_bswap.h>
#include <ufs/lfs/ulfs_extern.h>
#include <ufs/lfs/ulfs_wapbl.h>
#include <ufs/lfs/lfs_extern.h>
#include <uvm/uvm.h>
#ifdef WAPBL_DEBUG_INODES
#error WAPBL_DEBUG_INODES: not functional before ulfs_wapbl.c is updated
void
ulfs_wapbl_verify_inodes(struct mount *mp, const char *str)
{
struct vnode *vp, *nvp;
struct inode *ip;
struct buf *bp, *nbp;
mutex_enter(&mntvnode_lock);
loop:
TAILQ_FOREACH_REVERSE(vp, &mp->mnt_vnodelist, vnodelst, v_mntvnodes) {
/*
* If the vnode that we are about to sync is no longer
* associated with this mount point, start over.
*/
if (vp->v_mount != mp)
goto loop;
mutex_enter(&vp->v_interlock);
nvp = TAILQ_NEXT(vp, v_mntvnodes);
ip = VTOI(vp);
if (vp->v_type == VNON) {
mutex_exit(&vp->v_interlock);
continue;
}
/* verify that update has been called on all inodes */
if (ip->i_flag & (IN_CHANGE | IN_UPDATE)) {
panic("wapbl_verify: mp %p: dirty vnode %p (inode %p): 0x%x\n",
mp, vp, ip, ip->i_flag);
}
mutex_exit(&mntvnode_lock);
mutex_enter(&bufcache_lock);
for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
nbp = LIST_NEXT(bp, b_vnbufs);
if ((bp->b_cflags & BC_BUSY)) {
continue;
}
KASSERT((bp->b_oflags & BO_DELWRI) != 0);
KASSERT((bp->b_flags & B_LOCKED) != 0);
}
mutex_exit(&bufcache_lock);
mutex_exit(&vp->v_interlock);
mutex_enter(&mntvnode_lock);
}
mutex_exit(&mntvnode_lock);
vp = VFSTOULFS(mp)->um_devvp;
mutex_enter(&vp->v_interlock);
mutex_enter(&bufcache_lock);
for (bp = LIST_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
nbp = LIST_NEXT(bp, b_vnbufs);
if ((bp->b_cflags & BC_BUSY)) {
continue;
}
KASSERT((bp->b_oflags & BO_DELWRI) != 0);
KASSERT((bp->b_flags & B_LOCKED) != 0);
}
mutex_exit(&bufcache_lock);
mutex_exit(&vp->v_interlock);
}
#endif /* WAPBL_DEBUG_INODES */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_wapbl.h,v 1.3 2013/06/08 21:40:27 dholland Exp $ */
/* $NetBSD: ulfs_wapbl.h,v 1.4 2013/06/08 22:05:15 dholland Exp $ */
/* from NetBSD: ufs_wapbl.h,v 1.7 2011/09/19 11:18:01 gdt Exp */
/*-
@ -34,103 +34,4 @@
#ifndef _UFS_LFS_ULFS_WAPBL_H_
#define _UFS_LFS_ULFS_WAPBL_H_
#if defined(_KERNEL_OPT)
#include "opt_wapbl.h"
#endif
/*
* Information for the journal location stored in the superblock.
* We store the journal version, some flags, the journal location
* type, and some location specific "locators" that identify where
* the log itself is located.
*/
/* fs->fs_journal_version */
#define ULFS_WAPBL_VERSION 1
/* fs->fs_journal_location */
#define ULFS_WAPBL_JOURNALLOC_NONE 0
#define ULFS_WAPBL_JOURNALLOC_END_PARTITION 1
#define ULFS_WAPBL_EPART_ADDR 0 /* locator slots */
#define ULFS_WAPBL_EPART_COUNT 1
#define ULFS_WAPBL_EPART_BLKSZ 2
#define ULFS_WAPBL_EPART_UNUSED 3
#define ULFS_WAPBL_JOURNALLOC_IN_FILESYSTEM 2
#define ULFS_WAPBL_INFS_ADDR 0 /* locator slots */
#define ULFS_WAPBL_INFS_COUNT 1
#define ULFS_WAPBL_INFS_BLKSZ 2
#define ULFS_WAPBL_INFS_INO 3
/* fs->fs_journal_flags */
#define ULFS_WAPBL_FLAGS_CREATE_LOG 0x1
#define ULFS_WAPBL_FLAGS_CLEAR_LOG 0x2
/*
* The journal size is limited to between 1MB and 64MB.
* The default journal size is the filesystem size divided by
* the scale factor - this is 1M of journal per 1GB of filesystem
* space.
*
* XXX: Is 64MB too limiting? If user explicitly asks for more, allow it?
*/
#define ULFS_WAPBL_JOURNAL_SCALE 1024
#define ULFS_WAPBL_MIN_JOURNAL_SIZE (1024 * 1024)
#define ULFS_WAPBL_MAX_JOURNAL_SIZE (64 * 1024 * 1024)
#if defined(WAPBL)
#if defined(WAPBL_DEBUG)
#define WAPBL_DEBUG_INODES
#endif
#ifdef WAPBL_DEBUG_INODES
#error Undefine WAPBL_DEBUG_INODES or update the code. Have a nice day.
#endif
#ifdef WAPBL_DEBUG_INODES
void ulfs_wapbl_verify_inodes(struct mount *, const char *);
#endif
static __inline int
ulfs_wapbl_begin2(struct mount *mp, struct vnode *vp1, struct vnode *vp2,
const char *file, int line)
{
return 0;
}
static __inline void
ulfs_wapbl_end2(struct mount *mp, struct vnode *vp1, struct vnode *vp2)
{
}
#define ULFS_WAPBL_BEGIN(mp) 0
#define ULFS_WAPBL_BEGIN1(mp, v1) 0
#define ULFS_WAPBL_END(mp) do { } while (0)
#define ULFS_WAPBL_END1(mp, v1)
#define ULFS_WAPBL_UPDATE(vp, access, modify, flags) do { } while (0)
#define ULFS_WAPBL_JLOCK_ASSERT(mp)
#define ULFS_WAPBL_JUNLOCK_ASSERT(mp)
#define ULFS_WAPBL_REGISTER_INODE(mp, ino, mode) do { } while (0)
#define ULFS_WAPBL_UNREGISTER_INODE(mp, ino, mode) do { } while (0)
#define ULFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len)
#else /* ! WAPBL */
#define ULFS_WAPBL_BEGIN(mp) 0
#define ULFS_WAPBL_BEGIN1(mp, v1) 0
#define ULFS_WAPBL_END(mp) do { } while (0)
#define ULFS_WAPBL_END1(mp, v1)
#define ULFS_WAPBL_UPDATE(vp, access, modify, flags) do { } while (0)
#define ULFS_WAPBL_JLOCK_ASSERT(mp)
#define ULFS_WAPBL_JUNLOCK_ASSERT(mp)
#define ULFS_WAPBL_REGISTER_INODE(mp, ino, mode) do { } while (0)
#define ULFS_WAPBL_UNREGISTER_INODE(mp, ino, mode) do { } while (0)
#define ULFS_WAPBL_REGISTER_DEALLOCATION(mp, blk, len)
#endif
#endif /* !_UFS_LFS_ULFS_WAPBL_H_ */