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
This commit is contained in:
Konstantin Belousov 2022-01-28 06:37:23 +02:00
parent e11b2b69c5
commit c02780b78c
2 changed files with 5 additions and 1 deletions

View File

@ -4003,7 +4003,10 @@ getblkx(struct vnode *vp, daddr_t blkno, daddr_t dblkno, int size, int slpflag,
* 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);

View File

@ -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 */