git: cf0ede720391 - main - tarfs: 'struct tarfs_fid': Switch 'gen' to 'u_int', avoid packing
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Dec 2024 14:05:59 UTC
The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=cf0ede720391de986e350f23229da21c13bc7e9d commit cf0ede720391de986e350f23229da21c13bc7e9d Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2024-12-06 16:35:08 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2024-12-13 14:04:42 +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 --- 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)