git: b9283ea323b2 - stable/13 - Make locking assertions for VOP_FSYNC() and VOP_FDATASYNC() more correct
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 19 Nov 2021 04:36:51 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b9283ea323b202579ce9e59c811672bcfc2eda53 commit b9283ea323b202579ce9e59c811672bcfc2eda53 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-11-03 22:28:32 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-11-19 04:25:29 +0000 Make locking assertions for VOP_FSYNC() and VOP_FDATASYNC() more correct (cherry picked from commit 47b248ac651683650f7852485c594e76ca375573) --- sys/kern/vfs_subr.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ sys/kern/vnode_if.src | 8 ++++++-- sys/sys/vnode.h | 8 ++++++++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index ce1f4ed6126e..ff208926be16 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -5580,6 +5580,54 @@ vop_fplookup_symlink_debugpost(void *ap __unused, int rc __unused) VFS_SMR_ASSERT_ENTERED(); } + +static void +vop_fsync_debugprepost(struct vnode *vp, const char *name) +{ + if (vp->v_type == VCHR) + ; + else if (MNT_EXTENDED_SHARED(vp->v_mount)) + ASSERT_VOP_LOCKED(vp, name); + else + ASSERT_VOP_ELOCKED(vp, name); +} + +void +vop_fsync_debugpre(void *a) +{ + struct vop_fsync_args *ap; + + ap = a; + vop_fsync_debugprepost(ap->a_vp, "fsync"); +} + +void +vop_fsync_debugpost(void *a, int rc __unused) +{ + struct vop_fsync_args *ap; + + ap = a; + vop_fsync_debugprepost(ap->a_vp, "fsync"); +} + +void +vop_fdatasync_debugpre(void *a) +{ + struct vop_fdatasync_args *ap; + + ap = a; + vop_fsync_debugprepost(ap->a_vp, "fsync"); +} + +void +vop_fdatasync_debugpost(void *a, int rc __unused) +{ + struct vop_fdatasync_args *ap; + + ap = a; + vop_fsync_debugprepost(ap->a_vp, "fsync"); +} + void vop_strategy_debugpre(void *ap) { diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src index b506237f385d..ef4eef7f55f3 100644 --- a/sys/kern/vnode_if.src +++ b/sys/kern/vnode_if.src @@ -296,7 +296,9 @@ vop_revoke { }; -%% fsync vp L L L +%% fsync vp - - - +%! fsync pre vop_fsync_debugpre +%! fsync post vop_fsync_debugpost vop_fsync { IN struct vnode *vp; @@ -768,7 +770,9 @@ vop_add_writecount { }; -%% fdatasync vp L L L +%% fdatasync vp - - - +%! fdatasync pre vop_fdatasync_debugpre +%! fdatasync post vop_fdatasync_debugpost vop_fdatasync { IN struct vnode *vp; diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index ebd9577004fc..ba5eafc80d4b 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -920,10 +920,14 @@ void vop_symlink_post(void *a, int rc); int vop_sigdefer(struct vop_vector *vop, struct vop_generic_args *a); #ifdef DEBUG_VFS_LOCKS +void vop_fdatasync_debugpre(void *a); +void vop_fdatasync_debugpost(void *a, int rc); void vop_fplookup_vexec_debugpre(void *a); void vop_fplookup_vexec_debugpost(void *a, int rc); void vop_fplookup_symlink_debugpre(void *a); void vop_fplookup_symlink_debugpost(void *a, int rc); +void vop_fsync_debugpre(void *a); +void vop_fsync_debugpost(void *a, int rc); void vop_strategy_debugpre(void *a); void vop_lock_debugpre(void *a); void vop_lock_debugpost(void *a, int rc); @@ -932,10 +936,14 @@ void vop_need_inactive_debugpre(void *a); void vop_need_inactive_debugpost(void *a, int rc); void vop_mkdir_debugpost(void *a, int rc); #else +#define vop_fdatasync_debugpre(x) do { } while (0) +#define vop_fdatasync_debugpost(x, y) do { } while (0) #define vop_fplookup_vexec_debugpre(x) do { } while (0) #define vop_fplookup_vexec_debugpost(x, y) do { } while (0) #define vop_fplookup_symlink_debugpre(x) do { } while (0) #define vop_fplookup_symlink_debugpost(x, y) do { } while (0) +#define vop_fsync_debugpre(x) do { } while (0) +#define vop_fsync_debugpost(x, y) do { } while (0) #define vop_strategy_debugpre(x) do { } while (0) #define vop_lock_debugpre(x) do { } while (0) #define vop_lock_debugpost(x, y) do { } while (0)