git: bd56aad33c25 - main - buf: define and use BUF_DISOWNED
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 21 May 2024 18:16:46 UTC
The branch main has been updated by rlibby:
URL: https://cgit.FreeBSD.org/src/commit/?id=bd56aad33c2533615f76c17795f0aa70b7686309
commit bd56aad33c2533615f76c17795f0aa70b7686309
Author: Ryan Libby <rlibby@FreeBSD.org>
AuthorDate: 2024-05-21 17:21:50 +0000
Commit: Ryan Libby <rlibby@FreeBSD.org>
CommitDate: 2024-05-21 17:21:50 +0000
buf: define and use BUF_DISOWNED
Implement an API where previously code was directly reaching into the
buf's internal lock.
Reviewed by: mckusick, imp, kib, markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D45249
---
sys/geom/geom_vfs.c | 4 ++--
sys/sys/buf.h | 7 +++++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/sys/geom/geom_vfs.c b/sys/geom/geom_vfs.c
index 893c8dfffa6f..87b2fea21baa 100644
--- a/sys/geom/geom_vfs.c
+++ b/sys/geom/geom_vfs.c
@@ -124,12 +124,12 @@ g_vfs_done(struct bio *bip)
mp = cdevp->si_mountpt;
if (mp != NULL) {
if (bp->b_iocmd == BIO_READ) {
- if (LK_HOLDER(bp->b_lock.lk_lock) == LK_KERNPROC)
+ if (BUF_DISOWNED(bp))
mp->mnt_stat.f_asyncreads++;
else
mp->mnt_stat.f_syncreads++;
} else if (bp->b_iocmd == BIO_WRITE) {
- if (LK_HOLDER(bp->b_lock.lk_lock) == LK_KERNPROC)
+ if (BUF_DISOWNED(bp))
mp->mnt_stat.f_asyncwrites++;
else
mp->mnt_stat.f_syncwrites++;
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index 70fb2812c3ba..cee9547912a6 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -341,6 +341,13 @@ struct buf {
*/
#define BUF_ISLOCKED(bp) \
lockstatus(&(bp)->b_lock)
+
+/*
+ * Check if a buffer lock is currently held by LK_KERNPROC.
+ */
+#define BUF_DISOWNED(bp) \
+ lockmgr_disowned(&(bp)->b_lock)
+
/*
* Free a buffer lock.
*/