Skip to content

Commit 7eaca00

Browse files
asjbwhacks
authored andcommitted
btrfs: prop: fix vanished compression property after failed set
commit 272e532 upstream. The compression property resets to NULL, instead of the old value if we fail to set the new compression parameter. $ btrfs prop get /btrfs compression compression=lzo $ btrfs prop set /btrfs compression zli ERROR: failed to set compression for /btrfs: Invalid argument $ btrfs prop get /btrfs compression This is because the compression property ->validate() is successful for 'zli' as the strncmp() used the length passed from the userspace. Fix it by using the expected string length in strncmp(). Fixes: 6354192 ("Btrfs: add support for inode properties") Fixes: 5c1aab1 ("btrfs: Add zstd support") Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]> [bwh: Backported to 3.16: "zstd" is not supported] Signed-off-by: Ben Hutchings <[email protected]>
1 parent bc05cf8 commit 7eaca00

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/props.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,9 @@ int btrfs_subvol_inherit_props(struct btrfs_trans_handle *trans,
378378

379379
static int prop_compression_validate(const char *value, size_t len)
380380
{
381-
if (!strncmp("lzo", value, len))
381+
if (!strncmp("lzo", value, 3))
382382
return 0;
383-
else if (!strncmp("zlib", value, len))
383+
else if (!strncmp("zlib", value, 4))
384384
return 0;
385385

386386
return -EINVAL;

0 commit comments

Comments
 (0)