Module Name: src Committed By: hannken Date: Wed May 13 09:21:30 UTC 2020
Modified Files: src/sys/kern: vfs_trans.c src/sys/sys: fstrans.h Log Message: Add operation fstrans_held(struct mount *), true if the current thread holds a fstrans lock. Ride 9.99.61 To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sys/kern/vfs_trans.c cvs rdiff -u -r1.13 -r1.14 src/sys/sys/fstrans.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.61 src/sys/kern/vfs_trans.c:1.62 --- src/sys/kern/vfs_trans.c:1.61 Mon Jun 17 08:07:27 2019 +++ src/sys/kern/vfs_trans.c Wed May 13 09:21:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.61 2019/06/17 08:07:27 hannken Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.62 2020/05/13 09:21:30 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.61 2019/06/17 08:07:27 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.62 2020/05/13 09:21:30 hannken Exp $"); /* * File system transaction operations. @@ -569,6 +569,23 @@ fstrans_done(struct mount *mp) } /* + * Check if we hold an lock. + */ +int +fstrans_held(struct mount *mp) +{ + struct fstrans_lwp_info *fli; + struct fstrans_mount_info *fmi; + + KASSERT(mp != dead_rootmount); + + fli = fstrans_get_lwp_info(mp, true); + fmi = fli->fli_mountinfo; + + return (fli->fli_trans_cnt > 0 || fmi->fmi_owner == curlwp); +} + +/* * Check if this thread has an exclusive lock. */ int Index: src/sys/sys/fstrans.h diff -u src/sys/sys/fstrans.h:1.13 src/sys/sys/fstrans.h:1.14 --- src/sys/sys/fstrans.h:1.13 Fri Mar 1 09:02:03 2019 +++ src/sys/sys/fstrans.h Wed May 13 09:21:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fstrans.h,v 1.13 2019/03/01 09:02:03 hannken Exp $ */ +/* $NetBSD: fstrans.h,v 1.14 2020/05/13 09:21:30 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -53,6 +53,7 @@ void fstrans_start(struct mount *); int fstrans_start_nowait(struct mount *); void fstrans_start_lazy(struct mount *); void fstrans_done(struct mount *); +int fstrans_held(struct mount *); int fstrans_is_owner(struct mount *); int fstrans_mount(struct mount *); void fstrans_unmount(struct mount *);