Commit fa4d885a authored by Adam Borowski's avatar Adam Borowski Committed by David Sterba

btrfs: allow setting zlib compression level via :9

This is bikeshedding, but it seems people are drastically more likely to
understand "zlib:9" as compression level rather than an algorithm
version compared to "zlib9".

Based on feedback on the mailinglist, the ":9" will be the only accepted
syntax. The level must be a single digit. Unrecognized format will
result to the default, for forward compatibility in a similar way the
compression algorithm specifier was relaxed in commit
a7164fa4 ("btrfs: prepare for extensions in compression
options").
Signed-off-by: default avatarAdam Borowski <kilobyte@angband.pl>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ tighten the accepted format ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent f51d2b59
...@@ -1111,8 +1111,9 @@ unsigned int btrfs_compress_str2level(const char *str) ...@@ -1111,8 +1111,9 @@ unsigned int btrfs_compress_str2level(const char *str)
if (strncmp(str, "zlib", 4) != 0) if (strncmp(str, "zlib", 4) != 0)
return 0; return 0;
if ('1' <= str[4] && str[4] <= '9' ) /* Accepted form: zlib:1 up to zlib:9 and nothing left after the number */
return str[4] - '0'; if (str[4] == ':' && '1' <= str[5] && str[5] <= '9' && str[6] == 0)
return str[5] - '0';
return 0; return 0;
} }
...@@ -1261,7 +1261,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) ...@@ -1261,7 +1261,7 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
else else
seq_printf(seq, ",compress=%s", compress_type); seq_printf(seq, ",compress=%s", compress_type);
if (info->compress_level) if (info->compress_level)
seq_printf(seq, "%d", info->compress_level); seq_printf(seq, ":%d", info->compress_level);
} }
if (btrfs_test_opt(info, NOSSD)) if (btrfs_test_opt(info, NOSSD))
seq_puts(seq, ",nossd"); seq_puts(seq, ",nossd");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment