git: 4634282f8908 - stable/14 - tarfs: 'struct tarfs_fid': Switch 'gen' to 'u_int', avoid packing
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 17 Jan 2025 13:53:09 UTC
The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=4634282f8908406fa395a2b49a8e4c06c07830e4 commit 4634282f8908406fa395a2b49a8e4c06c07830e4 Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2024-12-06 16:35:08 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2025-01-17 13:51:32 +0000 tarfs: 'struct tarfs_fid': Switch 'gen' to 'u_int', avoid packing As the 'gen' field in 'struct tarfs_node' (and then 'struct tarfs_fid') is filled with arc4random() which returns an unsigned int, change its type in both structures. This allows reordering fields in 'struct tarfs_fid' to reduce its size, finally avoiding the use of '__packed' to ensure it fits into 'struct fid'. While here, remove the 'data0' field which wasn't necessary from the start. Reviewed by: markj, rmacklem, des Approved by: markj (mentor) MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D47954 (cherry picked from commit cf0ede720391de986e350f23229da21c13bc7e9d) Sponsored by: The FreeBSD Foundation --- sys/fs/tarfs/tarfs.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/fs/tarfs/tarfs.h b/sys/fs/tarfs/tarfs.h index ffb95d2c0ac5..46fa8b55b3ad 100644 --- a/sys/fs/tarfs/tarfs.h +++ b/sys/fs/tarfs/tarfs.h @@ -74,7 +74,7 @@ struct tarfs_node { struct timespec mtime; struct timespec ctime; struct timespec birthtime; - unsigned long gen; + uint32_t gen; /* Block map */ size_t nblk; @@ -161,11 +161,10 @@ struct tarfs_zio { }; struct tarfs_fid { - u_short len; /* length of data in bytes */ - u_short data0; /* force alignment */ - ino_t ino; - unsigned long gen; -} __packed; + u_short len; /* length of data in bytes */ + uint32_t gen; + ino_t ino; +}; #define TARFS_NODE_LOCK(tnp) \ mtx_lock(&(tnp)->lock)