Skip to content

Instantly share code, notes, and snippets.

@coypoop
Created May 16, 2016 08:42
Show Gist options
  • Save coypoop/6d748ab392aa538b6ed2b65e20d25b64 to your computer and use it in GitHub Desktop.
Save coypoop/6d748ab392aa538b6ed2b65e20d25b64 to your computer and use it in GitHub Desktop.
More questionable change, as UFS_WAPBL_END1 is used a few more times.
From a790bb7b448209758abac889eaeb76316419f86a Mon Sep 17 00:00:00 2001
From: coypu <coypu@sdf.org>
Date: Mon, 16 May 2016 11:39:41 +0300
Subject: [PATCH 1/1] Simplify ufs_wapbl_end2
Similar to ufs_wapbl_begin2, this function is rarely called with vnodes,
and when it does - it's only with one parameter.
The only thing we do with the vnode when it's rarely used, is decrement
the usecount. do this explicitly instead.
Allows us to get rid of the two vnode parameters in ufs_wapbl_end2.
---
sys/ufs/ufs/ufs_vnops.c | 12 ++++++++----
sys/ufs/ufs/ufs_wapbl.h | 10 ++--------
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index c054410..eb65ce8 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -160,7 +160,8 @@ ufs_create(void *v)
fstrans_done(dvp->v_mount);
return (error);
}
- UFS_WAPBL_END1(dvp->v_mount, dvp);
+ UFS_WAPBL_END(dvp->v_mount);
+ vrele(dvp);
fstrans_done(dvp->v_mount);
VN_KNOTE(dvp, NOTE_WRITE);
VOP_UNLOCK(*ap->a_vpp);
@@ -204,7 +205,8 @@ ufs_mknod(void *v)
ip = VTOI(*vpp);
ip->i_flag |= IN_ACCESS | IN_CHANGE | IN_UPDATE;
UFS_WAPBL_UPDATE(*vpp, NULL, NULL, 0);
- UFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp);
+ UFS_WAPBL_END(ap->a_dvp->v_mount);
+ vrele(ap->a_dvp);
VOP_UNLOCK(*vpp);
out:
fstrans_done(ap->a_dvp->v_mount);
@@ -1232,7 +1234,8 @@ ufs_symlink(void *v)
error = ufs_bufio(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
IO_NODELOCKED | IO_JOURNALLOCKED, ap->a_cnp->cn_cred, NULL,
NULL);
- UFS_WAPBL_END1(ap->a_dvp->v_mount, ap->a_dvp);
+ UFS_WAPBL_END(ap->a_dvp->v_mount);
+ vrele(ap->a_dvp);
VOP_UNLOCK(vp);
if (error)
vrele(vp);
@@ -1833,7 +1836,8 @@ ufs_makeinode(struct vattr *vap, struct vnode *dvp,
DIP_ASSIGN(ip, nlink, 0);
ip->i_flag |= IN_CHANGE;
UFS_WAPBL_UPDATE(tvp, NULL, NULL, 0);
- UFS_WAPBL_END1(dvp->v_mount, dvp);
+ UFS_WAPBL_END(dvp->v_mount);
+ vrele(dvp);
vput(tvp);
return (error);
}
diff --git a/sys/ufs/ufs/ufs_wapbl.h b/sys/ufs/ufs/ufs_wapbl.h
index 025d3ba..8d0c7f0 100644
--- a/sys/ufs/ufs/ufs_wapbl.h
+++ b/sys/ufs/ufs/ufs_wapbl.h
@@ -112,7 +112,7 @@ ufs_wapbl_begin2(struct mount *mp, const char *file, int line)
}
static __inline void
-ufs_wapbl_end2(struct mount *mp, struct vnode *vp1, struct vnode *vp2)
+ufs_wapbl_end2(struct mount *mp)
{
if (mp->mnt_wapbl) {
#ifdef WAPBL_DEBUG_INODES
@@ -120,16 +120,11 @@ ufs_wapbl_end2(struct mount *mp, struct vnode *vp1, struct vnode *vp2)
ufs_wapbl_verify_inodes(mp, "wapbl_end");
#endif
wapbl_end(mp->mnt_wapbl);
- if (vp2)
- vrele(vp2);
- if (vp1)
- vrele(vp1);
}
}
#define UFS_WAPBL_BEGIN(mp) ufs_wapbl_begin2(mp, __FUNCTION__, __LINE__)
-#define UFS_WAPBL_END(mp) ufs_wapbl_end2(mp, NULL, NULL)
-#define UFS_WAPBL_END1(mp, v1) ufs_wapbl_end2(mp, v1, NULL)
+#define UFS_WAPBL_END(mp) ufs_wapbl_end2(mp)
#define UFS_WAPBL_UPDATE(vp, access, modify, flags) \
if ((vp)->v_mount->mnt_wapbl) { \
@@ -157,7 +152,6 @@ ufs_wapbl_end2(struct mount *mp, struct vnode *vp1, struct vnode *vp2)
#else /* ! WAPBL */
#define UFS_WAPBL_BEGIN(mp) (__USE(mp))
#define UFS_WAPBL_END(mp) do { } while (0)
-#define UFS_WAPBL_END1(mp, v1)
#define UFS_WAPBL_UPDATE(vp, access, modify, flags) do { } while (0)
#define UFS_WAPBL_JLOCK_ASSERT(mp)
#define UFS_WAPBL_JUNLOCK_ASSERT(mp)
--
2.8.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment