git: c02780b78c7f - main - Add GB_NOWITNESS flag

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 01 Feb 2022 04:55:09 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=c02780b78c7f1df3e682e1a88b380820c288ec04

commit c02780b78c7f1df3e682e1a88b380820c288ec04
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-01-28 04:37:23 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-02-01 04:54:50 +0000

    Add GB_NOWITNESS flag
    
    It prevents WITNESS from recording the lock order for the buffer lock
    acquired by getblkx().
    
    Reviewed by:    mckusick
    Discussed with: markj
    Tested by:      pho
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D34073
---
 sys/kern/vfs_bio.c | 5 ++++-
 sys/sys/buf.h      | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index cdb080688874..af89f11a30f0 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -4003,7 +4003,10 @@ loop:
 		 * it must be on a queue.
 		 */
 		lockflags = LK_EXCLUSIVE | LK_INTERLOCK |
-		    ((flags & GB_LOCK_NOWAIT) ? LK_NOWAIT : LK_SLEEPFAIL);
+		    ((flags & GB_LOCK_NOWAIT) != 0 ? LK_NOWAIT : LK_SLEEPFAIL);
+#ifdef WITNESS
+		lockflags |= (flags & GB_NOWITNESS) != 0 ? LK_NOWITNESS : 0;
+#endif
 
 		error = BUF_TIMELOCK(bp, lockflags,
 		    BO_LOCKPTR(bo), "getblk", slpflag, slptimeo);
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index 8fb49fb1e7d1..fa930487235f 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -508,6 +508,7 @@ buf_track(struct buf *bp __unused, const char *location __unused)
 #define	GB_CKHASH	0x0020		/* If reading, calc checksum hash */
 #define	GB_NOSPARSE	0x0040		/* Do not instantiate holes */
 #define	GB_CVTENXIO	0x0080		/* Convert errors to ENXIO */
+#define	GB_NOWITNESS	0x0100		/* Do not record for WITNESS */
 
 #ifdef _KERNEL
 extern int	nbuf;			/* The number of buffer headers */