]> git.hungrycats.org Git - linux/commit
btrfs: props: keep compressing inodes with legacy compression property values misc-next/topics/compress-fixes
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Tue, 3 Nov 2026 23:41:31 +0000 (18:41 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Tue, 3 Nov 2026 23:41:31 +0000 (18:41 -0500)
commit464a17c7110ff10889f59c0230001ef8fde4ca92
tree865aefc3531bfd1f87713d25e6d58783902f4862
parenta41f99c734a9d5e3a5344cb2d0371b3cc16ff586
btrfs: props: keep compressing inodes with legacy compression property values

Older kernels matched btrfs.compression values by algorithm name prefix
only, both in the property validator and in prop_compression_apply(),
so values such as "zstd:banana", "zstd:", "zstd:3x", "zstdgarbage", or
anything longer than BTRFS_COMPRESS_PROP_MAX_LEN were accepted, stored
verbatim, and compressed with the named algorithm.  Such values are
still found on existing filesystems.

Since per-inode compression levels were added, prop_compression_apply()
parses the value strictly and rejects these with -EINVAL.  The property is
loaded with the inode, and inode_prop_iterator() only warns about a
failed apply, so these inodes silently stop compressing, with a warning
every time the inode is loaded.

Keep compressing them as older kernels did:  in prop_compression_apply(),
match the algorithm by name prefix again, and treat a level suffix that
does not parse, or a value too long to hold a valid level, as an
unspecified level (prop_compress_level = 0).  The compression paths then
pick the level as for a value with no level at all:  the mount option's
level if the mount option uses the same algorithm, otherwise the
algorithm's default level.

setxattr still goes through prop_compression_validate(), which keeps
rejecting these values, so only values that are already stored take this
path.

Assisted-by: Claude:claude-opus-5-5
fs/btrfs/props.c