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
This commit is contained in:
Ryan Libby 2024-05-21 10:21:50 -07:00
parent b92cd6b294
commit bd56aad33c
2 changed files with 9 additions and 2 deletions

View file

@ -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++;

View file

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