mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
btrfs: send: make use of -fms-extensions for defining struct fs_path
The newly introduced -fms-extensions compiler flag allows defining
struct fs_path in such a way that inline_buf becomes a proper array
with a size known to the compiler.
This also makes the problem fixed by commit 8aec9dbf2d ("btrfs: send:
fix -Wflex-array-member-not-at-end warning in struct send_ctx") go away.
Whether cur_inode_path should be put back to its original place in
struct send_ctx I don't know, but at least the comment no longer
applies.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: David Sterba <dsterba@suse.com>
Link: https://patch.msgid.link/20251020142228.1819871-3-linux@rasmusvillemoes.dk
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nicolas Schier <nsc@kernel.org>
This commit is contained in:
committed by
Nicolas Schier
parent
9716818d61
commit
d599f571b3
@@ -47,28 +47,30 @@
|
||||
* It allows fast adding of path elements on the right side (normal path) and
|
||||
* fast adding to the left side (reversed path). A reversed path can also be
|
||||
* unreversed if needed.
|
||||
*
|
||||
* The definition of struct fs_path relies on -fms-extensions to allow
|
||||
* including a tagged struct as an anonymous member.
|
||||
*/
|
||||
struct fs_path {
|
||||
union {
|
||||
struct {
|
||||
char *start;
|
||||
char *end;
|
||||
struct __fs_path {
|
||||
char *start;
|
||||
char *end;
|
||||
|
||||
char *buf;
|
||||
unsigned short buf_len:15;
|
||||
unsigned short reversed:1;
|
||||
char inline_buf[];
|
||||
};
|
||||
/*
|
||||
* Average path length does not exceed 200 bytes, we'll have
|
||||
* better packing in the slab and higher chance to satisfy
|
||||
* an allocation later during send.
|
||||
*/
|
||||
char pad[256];
|
||||
};
|
||||
char *buf;
|
||||
unsigned short buf_len:15;
|
||||
unsigned short reversed:1;
|
||||
};
|
||||
static_assert(sizeof(struct __fs_path) < 256);
|
||||
struct fs_path {
|
||||
struct __fs_path;
|
||||
/*
|
||||
* Average path length does not exceed 200 bytes, we'll have
|
||||
* better packing in the slab and higher chance to satisfy
|
||||
* an allocation later during send.
|
||||
*/
|
||||
char inline_buf[256 - sizeof(struct __fs_path)];
|
||||
};
|
||||
#define FS_PATH_INLINE_SIZE \
|
||||
(sizeof(struct fs_path) - offsetof(struct fs_path, inline_buf))
|
||||
sizeof_field(struct fs_path, inline_buf)
|
||||
|
||||
|
||||
/* reused for each extent */
|
||||
@@ -305,7 +307,6 @@ struct send_ctx {
|
||||
struct btrfs_lru_cache dir_created_cache;
|
||||
struct btrfs_lru_cache dir_utimes_cache;
|
||||
|
||||
/* Must be last as it ends in a flexible-array member. */
|
||||
struct fs_path cur_inode_path;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user