Skip to content

Commit 272e532

Browse files
asjkdave
authored andcommitted
btrfs: prop: fix vanished compression property after failed set
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") CC: [email protected] # 4.14+ 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]>
1 parent 50398fd commit 272e532

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/btrfs/props.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,11 @@ int btrfs_subvol_inherit_props(struct btrfs_trans_handle *trans,
366366

367367
static int prop_compression_validate(const char *value, size_t len)
368368
{
369-
if (!strncmp("lzo", value, len))
369+
if (!strncmp("lzo", value, 3))
370370
return 0;
371-
else if (!strncmp("zlib", value, len))
371+
else if (!strncmp("zlib", value, 4))
372372
return 0;
373-
else if (!strncmp("zstd", value, len))
373+
else if (!strncmp("zstd", value, 4))
374374
return 0;
375375

376376
return -EINVAL;

0 commit comments

Comments
 (0)