Commit 03963793 authored by Chuck Lever's avatar Chuck Lever
Browse files

NFSD: Simplify struct knfsd_fh



Compilers are allowed to insert padding and reorder the
fields in a struct, so using a union of an array and a
struct in struct knfsd_fh is not reliable.

The position of elements in an array is more reliable.

Suggested-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent edf7b905
Loading
Loading
Loading
Loading
+6 −9
Original line number Diff line number Diff line
@@ -49,17 +49,14 @@ struct knfsd_fh {
					 * Points to the current size while
					 * building a new file handle.
					 */
	union {
		char			fh_raw[NFS4_FHSIZE];
		struct {
			u8		fh_version;	/* == 1 */
			u8		fh_auth_type;	/* deprecated */
			u8		fh_fsid_type;
			u8		fh_fileid_type;
		};
	};
	u8		fh_raw[NFS4_FHSIZE];
};

#define fh_version		fh_raw[0]
#define fh_auth_type		fh_raw[1]
#define fh_fsid_type		fh_raw[2]
#define fh_fileid_type		fh_raw[3]

static inline u32 *fh_fsid(const struct knfsd_fh *fh)
{
	return (u32 *)&fh->fh_raw[4];