Complete patch with a sweep which converts direct reads of v_holdcnt/v_uscount to vn_ref_read can be found here: https://people.freebsd.org/~mjg/vfs-refcnt.2.diff ; posted below is the non-mechanical part of the patch
This deduplicates all cases of hand-rolled sanity checks.
The switch away from refcount(9) also eliminates several runtime checks from non-debug kernels.
Note that since everything is touched this perhaps is an opportunity to rename holdcnt to holdcount for consistency with usecount.
For example this shortens vget_prep (148 -> 127 bytes), vget_finish (270 -> 218 bytes). This also converts vrefact from:
0xffffffff80726870 <+0>: push %rbp 0xffffffff80726871 <+1>: mov %rsp,%rbp 0xffffffff80726874 <+4>: mov $0x1,%eax 0xffffffff80726879 <+9>: lock xadd %eax,0x1d0(%rdi) 0xffffffff80726881 <+17>: test $0x40000000,%eax 0xffffffff80726886 <+22>: jne 0xffffffff8072688a <vrefact+26> 0xffffffff80726888 <+24>: pop %rbp 0xffffffff80726889 <+25>: retq 0xffffffff8072688a <+26>: movl $0x60000000,0x1d0(%rdi) 0xffffffff80726894 <+36>: pop %rbp 0xffffffff80726895 <+37>: retq
to:
0xffffffff80725740 <+0>: push %rbp 0xffffffff80725741 <+1>: mov %rsp,%rbp 0xffffffff80725744 <+4>: lock addl $0x1,0x1d0(%rdi) 0xffffffff8072574c <+12>: pop %rbp 0xffffffff8072574d <+13>: retq
Meaning we should probably make it inline (along with vrefactn).