From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: <linux-nfs@vger.kernel.org>
Subject: [PATCH v1 2/4] xdrgen: Key the width tables by type name only
Date: Sat, 24 Oct 2026 21:46:14 -0400 [thread overview]
Message-ID: <20261025014616.22236-3-cel@kernel.org> (raw)
In-Reply-To: <20261025014616.22236-1-cel@kernel.org>
Every declaration class registers its width in max_widths and
symbolic_widths under its own name, and a declaration's name is the
field name when it appears inside a struct or a union. Those tables
are otherwise keyed by type name, so a field named after a type
overwrites that type's entry. In nfs_acl2.x, "unsigned int uid" in
struct fattr replaces the entry for the "uid" typedef, and the
generated NFS_ACL2_aclent_sz sizes the aclent id as XDR_unsigned_int
rather than NFS_ACL2_uid_sz. In nfs3.x, the "time_how set_it"
discriminant of set_atime replaces the entry a "bool set_it"
discriminant registered, so the generated set_mode3, set_uid3,
set_gid3, and set_size3 size macros count a time_how in place of a
bool. The macros evaluate to the right value only because the
colliding types happen to share a width.
Register a declaration's width under its name only when the
declaration is a typedef, where the name is the new type's name, and
compute a union discriminant's width from the discriminant itself
rather than looking it up by name. Regenerate the affected headers;
only size macros change.
Signed-off-by: Chuck Lever <cel@kernel.org>
---
include/linux/sunrpc/xdrgen/nfs3.h | 8 +++----
include/linux/sunrpc/xdrgen/nfs_acl2.h | 2 +-
tools/net/sunrpc/xdrgen/xdr_ast.py | 32 +++-----------------------
3 files changed, 8 insertions(+), 34 deletions(-)
diff --git a/include/linux/sunrpc/xdrgen/nfs3.h b/include/linux/sunrpc/xdrgen/nfs3.h
index 734f60f502c6..4e0b0afe8227 100644
--- a/include/linux/sunrpc/xdrgen/nfs3.h
+++ b/include/linux/sunrpc/xdrgen/nfs3.h
@@ -885,13 +885,13 @@ enum {
(XDR_bool + NFS3_nfs_fh3_sz)
#define NFS3_time_how_sz (XDR_int)
#define NFS3_set_mode3_sz \
- (NFS3_time_how_sz + NFS3_mode3_sz)
+ (XDR_bool + NFS3_mode3_sz)
#define NFS3_set_uid3_sz \
- (NFS3_time_how_sz + NFS3_uid3_sz)
+ (XDR_bool + NFS3_uid3_sz)
#define NFS3_set_gid3_sz \
- (NFS3_time_how_sz + NFS3_gid3_sz)
+ (XDR_bool + NFS3_gid3_sz)
#define NFS3_set_size3_sz \
- (NFS3_time_how_sz + NFS3_size3_sz)
+ (XDR_bool + NFS3_size3_sz)
#define NFS3_set_atime_sz \
(NFS3_time_how_sz + NFS3_nfstime3_sz)
#define NFS3_set_mtime_sz \
diff --git a/include/linux/sunrpc/xdrgen/nfs_acl2.h b/include/linux/sunrpc/xdrgen/nfs_acl2.h
index cc0b0db4c738..98dcada4786c 100644
--- a/include/linux/sunrpc/xdrgen/nfs_acl2.h
+++ b/include/linux/sunrpc/xdrgen/nfs_acl2.h
@@ -232,7 +232,7 @@ enum {
#define NFS_ACL2_o_mode_sz \
(XDR_unsigned_short)
#define NFS_ACL2_aclent_sz \
- (XDR_int + XDR_unsigned_int + NFS_ACL2_o_mode_sz)
+ (XDR_int + NFS_ACL2_uid_sz + NFS_ACL2_o_mode_sz)
#define NFS_ACL2_secattr_sz \
(XDR_unsigned_int + XDR_int + XDR_unsigned_int + (NFS_ACL_MAX_ENTRIES * (NFS_ACL2_aclent_sz)) + XDR_int + XDR_unsigned_int + (NFS_ACL_MAX_ENTRIES * (NFS_ACL2_aclent_sz)))
#define NFS_ACL2_ftype_sz (XDR_int)
diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py
index 537f056a0c27..a3595aa40a57 100644
--- a/tools/net/sunrpc/xdrgen/xdr_ast.py
+++ b/tools/net/sunrpc/xdrgen/xdr_ast.py
@@ -186,10 +186,6 @@ class _XdrFixedLengthOpaque(_XdrDeclaration):
"""Return list containing XDR width of type's components"""
return ["XDR_QUADLEN(" + self.size + ")"]
- def __post_init__(self):
- max_widths[self.name] = self.max_width()
- symbolic_widths[self.name] = self.symbolic_width()
-
@dataclass
class _XdrVariableLengthOpaque(_XdrDeclaration):
@@ -210,10 +206,6 @@ class _XdrVariableLengthOpaque(_XdrDeclaration):
widths.append("XDR_QUADLEN(" + self.maxsize + ")")
return widths
- def __post_init__(self):
- max_widths[self.name] = self.max_width()
- symbolic_widths[self.name] = self.symbolic_width()
-
@dataclass
class _XdrString(_XdrDeclaration):
@@ -234,10 +226,6 @@ class _XdrString(_XdrDeclaration):
widths.append("XDR_QUADLEN(" + self.maxsize + ")")
return widths
- def __post_init__(self):
- max_widths[self.name] = self.max_width()
- symbolic_widths[self.name] = self.symbolic_width()
-
@dataclass
class _XdrFixedLengthArray(_XdrDeclaration):
@@ -257,10 +245,6 @@ class _XdrFixedLengthArray(_XdrDeclaration):
item_width = " + ".join(symbolic_widths[self.spec.type_name])
return ["(" + self.size + " * (" + item_width + "))"]
- def __post_init__(self):
- max_widths[self.name] = self.max_width()
- symbolic_widths[self.name] = self.symbolic_width()
-
@dataclass
class _XdrVariableLengthArray(_XdrDeclaration):
@@ -283,10 +267,6 @@ class _XdrVariableLengthArray(_XdrDeclaration):
widths.append("(" + self.maxsize + " * (" + item_width + "))")
return widths
- def __post_init__(self):
- max_widths[self.name] = self.max_width()
- symbolic_widths[self.name] = self.symbolic_width()
-
@dataclass
class _XdrOptionalData(_XdrDeclaration):
@@ -307,8 +287,6 @@ class _XdrOptionalData(_XdrDeclaration):
def __post_init__(self):
structs.add(self.name)
pass_by_reference.add(self.name)
- max_widths[self.name] = self.max_width()
- symbolic_widths[self.name] = self.symbolic_width()
@dataclass
@@ -327,10 +305,6 @@ class _XdrBasic(_XdrDeclaration):
"""Return list containing XDR width of type's components"""
return symbolic_widths[self.spec.type_name]
- def __post_init__(self):
- max_widths[self.name] = self.max_width()
- symbolic_widths[self.name] = self.symbolic_width()
-
@dataclass
class _XdrVoid(_XdrDeclaration):
@@ -475,8 +449,8 @@ class _XdrTypedef(_XdrAst):
varlen_object_typedefs[new_type.name] = varlen_object_typedefs[
new_type.spec.type_name
]
- max_widths[new_type.name] = self.max_width()
- symbolic_widths[new_type.name] = self.symbolic_width()
+ max_widths[self.declaration.name] = self.max_width()
+ symbolic_widths[self.declaration.name] = self.symbolic_width()
def pages_member_maxsize(field: _XdrDeclaration):
@@ -555,7 +529,7 @@ class _XdrUnion(_XdrAst):
if self.default.arm.max_width() > max_width:
max_width = self.default.arm.max_width()
width = self.default.arm.symbolic_width()
- return symbolic_widths[self.discriminant.name] + width
+ return self.discriminant.symbolic_width() + width
def __post_init__(self):
structs.add(self.name)
--
2.56.0
next prev parent reply other threads:[~2026-10-25 16:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 1:46 [PATCH v1 0/4] xdrgen fixes Chuck Lever
2026-10-25 1:46 ` [PATCH v1 1/4] xdrgen: Handle a union whose arms are all void Chuck Lever
2026-10-25 1:46 ` Chuck Lever [this message]
2026-10-25 1:46 ` [PATCH v1 3/4] xdrgen: Register optional-data names only for typedefs Chuck Lever
2026-10-25 1:46 ` [PATCH v1 4/4] xdrgen: Take a union's numeric discriminant width from the declaration Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261025014616.22236-3-cel@kernel.org \
--to=cel@kernel.org \
--cc=dai.ngo@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.