Unverified Commit d599f571 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Nicolas Schier
Browse files

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 8aec9dbf ("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: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Acked-by: default avatarDavid Sterba <dsterba@suse.com>
Link: https://patch.msgid.link/20251020142228.1819871-3-linux@rasmusvillemoes.dk


Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
Signed-off-by: default avatarNicolas Schier <nsc@kernel.org>
parent 9716818d
Loading
Loading
Loading
Loading
+20 −19
Original line number Diff line number Diff line
@@ -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 {
struct __fs_path {
	char *start;
	char *end;

	char *buf;
	unsigned short buf_len:15;
	unsigned short reversed:1;
			char inline_buf[];
};
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 pad[256];
	};
	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;
};