Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add operation fstrans_held(struct mount *), true if the ...



details:   https://anonhg.NetBSD.org/src/rev/04ceb89be59b
branches:  trunk
changeset: 972018:04ceb89be59b
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed May 13 09:21:30 2020 +0000

description:
Add operation fstrans_held(struct mount *), true if the current thread
holds a fstrans lock.

Ride 9.99.61

diffstat:

 sys/kern/vfs_trans.c |  21 +++++++++++++++++++--
 sys/sys/fstrans.h    |   3 ++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diffs (59 lines):

diff -r eee81ba7fd3a -r 04ceb89be59b sys/kern/vfs_trans.c
--- a/sys/kern/vfs_trans.c      Wed May 13 08:43:28 2020 +0000
+++ b/sys/kern/vfs_trans.c      Wed May 13 09:21:30 2020 +0000
@@ -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 @@
 }
 
 /*
+ * 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
diff -r eee81ba7fd3a -r 04ceb89be59b sys/sys/fstrans.h
--- a/sys/sys/fstrans.h Wed May 13 08:43:28 2020 +0000
+++ b/sys/sys/fstrans.h Wed May 13 09:21:30 2020 +0000
@@ -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 @@
 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 *);



Home | Main Index | Thread Index | Old Index