git: 9d43654d8c56 - stable/15 - struct vnode: assign v_rl.resv1 as v_type and v_rl.resv2 as v_state

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 21 Jun 2026 10:16:06 UTC
The branch stable/15 has been updated by kib:

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

commit 9d43654d8c5612c5f8529bcae45c0c20c181d2af
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-04-26 02:31:50 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-06-21 10:05:32 +0000

    struct vnode: assign v_rl.resv1 as v_type and v_rl.resv2 as v_state
    
    (cherry picked from commit da6aa0648c0265d6f7bcba44a26f13ed0453dd7a)
---
 sys/sys/rangelock.h |  4 ++++
 sys/sys/vnode.h     | 10 ++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/sys/sys/rangelock.h b/sys/sys/rangelock.h
index ea3d0c26cd30..af0a2c3d72b1 100644
--- a/sys/sys/rangelock.h
+++ b/sys/sys/rangelock.h
@@ -46,6 +46,10 @@ struct rl_q_entry;
  * all existing lock owners are compatible with the request. Two lock
  * owners are compatible if their ranges do not overlap, or both
  * owners are for read.
+ *
+ * The resvX fields are there due to padding and explicitly enumerated
+ * so they can be used by consumers.  For instance, struct vnode uses
+ * resv1 as v_type and resv2 as v_state.
  */
 struct rangelock {
 	uintptr_t head;
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index cda188c1dbf5..cf6afe8792b8 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -133,8 +133,7 @@ struct vnode {
 	 * Fields which define the identity of the vnode.  These fields are
 	 * owned by the filesystem (XXX: and vgone() ?)
 	 */
-	__enum_uint8(vtype) v_type;		/* u vnode type */
-	__enum_uint8(vstate) v_state;		/* u vnode state */
+	short	v_v2flag;			/* v frequently read flag */
 	short	v_irflag;			/* i frequently read flags */
 	seqc_t	v_seqc;				/* i modification count */
 	uint32_t v_nchash;			/* u namecache hash */
@@ -203,6 +202,12 @@ struct vnode {
 						   (negative) text users */
 	int	v_seqc_users;			/* i modifications pending */
 };
+/*
+	__enum_uint8(vtype) v_type;
+	__enum_uint8(vstate) v_state;
+*/
+#define	v_type	v_rl.resv1			/* u vnode type */
+#define	v_state	v_rl.resv2			/* u vnode state */
 
 #define VN_ISDEV(vp)		VTYPE_ISDEV((vp)->v_type)
 
@@ -237,6 +242,7 @@ _Static_assert(sizeof(struct vnode) <= 448, "vnode size crosses 448 bytes");
  *	VI flags are protected by interlock and live in v_iflag
  *	VIRF flags are protected by interlock and live in v_irflag
  *	VV flags are protected by the vnode lock and live in v_vflag
+ *	V2 flags are protected by the vnode lock and live in v_v2flag
  *
  *	VIRF_DOOMED is doubly protected by the interlock and vnode lock.  Both
  *	are required for writing but the status may be checked with either.