Skip to content

Instantly share code, notes, and snippets.

@coypoop
Last active May 16, 2016 08:30
Show Gist options
  • Save coypoop/a0b065271149e235440e1a83411f87c6 to your computer and use it in GitHub Desktop.
Save coypoop/a0b065271149e235440e1a83411f87c6 to your computer and use it in GitHub Desktop.
Simplify ufs_wapbl_begin2
From 504e2b217ddf5b8db9f42b2eb6672e3b2d8a1883 Mon Sep 17 00:00:00 2001
From: coypu <coypu@sdf.org>
Date: Mon, 16 May 2016 11:29:58 +0300
Subject: [PATCH 1/1] Simplify ufs_wapbl_begin2
The purpose of the vnode parameters in this function is to increase
usecount (only).
This is only used by ufs_symlink (where it is called UFS_WAPBL_BEGIN1),
otherwise it is called with NULL, NULL as vnodes (UFS_WAPBL_BEGIN).
Get rid of UFS_WAPBL_BEGIN1, replace the one use of it with
explicit calls to vref and UFS_WAPBL_BEGIN.
This allows us to get rid of the vnode parameters of
ufs_wapbl_begin2.
---
sys/ufs/ufs/ufs_vnops.c | 9 +++++----
sys/ufs/ufs/ufs_wapbl.h | 15 +++------------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c
index 8f0edc1..c054410 100644
--- a/sys/ufs/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs/ufs_vnops.c
@@ -151,7 +151,7 @@ ufs_create(void *v)
UFS_CHECK_CRAPCOUNTER(VTOI(dvp));
/*
- * UFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful
+ * UFS_WAPBL_BEGIN(dvp->v_mount, dvp) performed by successful
* ufs_makeinode
*/
fstrans_start(dvp->v_mount, FSTRANS_SHARED);
@@ -194,7 +194,7 @@ ufs_mknod(void *v)
UFS_CHECK_CRAPCOUNTER(VTOI(ap->a_dvp));
/*
- * UFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful
+ * UFS_WAPBL_BEGIN(dvp->v_mount, dvp) performed by successful
* ufs_makeinode
*/
fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED);
@@ -1200,7 +1200,7 @@ ufs_symlink(void *v)
UFS_CHECK_CRAPCOUNTER(VTOI(ap->a_dvp));
/*
- * UFS_WAPBL_BEGIN1(dvp->v_mount, dvp) performed by successful
+ * UFS_WAPBL_BEGIN(dvp->v_mount, dvp) performed by successful
* ufs_makeinode
*/
fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED);
@@ -1784,7 +1784,8 @@ ufs_makeinode(struct vattr *vap, struct vnode *dvp,
}
*vpp = tvp;
ip = VTOI(tvp);
- error = UFS_WAPBL_BEGIN1(dvp->v_mount, dvp);
+ vref(dvp);
+ error = UFS_WAPBL_BEGIN(dvp->v_mount);
if (error) {
vput(tvp);
return (error);
diff --git a/sys/ufs/ufs/ufs_wapbl.h b/sys/ufs/ufs/ufs_wapbl.h
index 1eab045..025d3ba 100644
--- a/sys/ufs/ufs/ufs_wapbl.h
+++ b/sys/ufs/ufs/ufs_wapbl.h
@@ -95,16 +95,11 @@ void ufs_wapbl_verify_inodes(struct mount *, const char *);
#endif
static __inline int
-ufs_wapbl_begin2(struct mount *mp, struct vnode *vp1, struct vnode *vp2,
- const char *file, int line)
+ufs_wapbl_begin2(struct mount *mp, const char *file, int line)
{
if (mp->mnt_wapbl) {
int error;
- if (vp1)
- vref(vp1);
- if (vp2)
- vref(vp2);
error = wapbl_begin(mp->mnt_wapbl, file, line);
if (error)
return error;
@@ -132,10 +127,7 @@ ufs_wapbl_end2(struct mount *mp, struct vnode *vp1, struct vnode *vp2)
}
}
-#define UFS_WAPBL_BEGIN(mp) \
- ufs_wapbl_begin2(mp, NULL, NULL, __FUNCTION__, __LINE__)
-#define UFS_WAPBL_BEGIN1(mp, v1) \
- ufs_wapbl_begin2(mp, v1, NULL, __FUNCTION__, __LINE__)
+#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)
@@ -163,8 +155,7 @@ ufs_wapbl_end2(struct mount *mp, struct vnode *vp1, struct vnode *vp2)
if (mp->mnt_wapbl) wapbl_register_deallocation(mp->mnt_wapbl, blk, len)
#else /* ! WAPBL */
-#define UFS_WAPBL_BEGIN(mp) (__USE(mp), 0)
-#define UFS_WAPBL_BEGIN1(mp, v1) 0
+#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)
--
2.8.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment