[PATCH v2] btrfs: emit BTRFS_SEND_C_FILEATTR during full send

From: Mateusz Poliwczak

Date: Wed Jun 17 2026 - 03:01:49 EST


Currently BTRFS_SEND_C_FILEATTR is only emitted during incremental
send when fileattr change between snapshots. This change makes sure
we also emit BTRFS_SEND_C_FILEATTR when sending the full snapshot.

Without this there is no way to gain access to the fileattr of a file
e.g. the FS_NOCOW_FL flag without doing a separate FS_IOC_GETFLAGS
syscall, which might not be even possible if the stream is send over
network or such.

Signed-off-by: Mateusz Poliwczak <mpoliwczak34@xxxxxxxxx>
---
fs/btrfs/send.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 3ae480c7474b..effbe7ac1a81 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -6575,8 +6575,10 @@ static int finish_inode_if_needed(struct send_ctx *sctx, bool at_end)

if (!sctx->parent_root || sctx->cur_inode_new) {
need_chown = true;
- if (!S_ISLNK(sctx->cur_inode_mode))
+ if (!S_ISLNK(sctx->cur_inode_mode)) {
need_chmod = true;
+ need_fileattr = true;
+ }
if (sctx->cur_inode_next_write_offset == sctx->cur_inode_size)
need_truncate = false;
} else {
--
2.54.0