diff options
author | Daniel Vacek <neelx@suse.com> | 2025-03-06 16:15:35 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2025-03-18 22:35:50 +0300 |
commit | fc5c0c5825874859069ac44c367c724acd7190fb (patch) | |
tree | 3b3e5fb0a15f714baa7ff7a786c56ee2d3861be1 /fs/btrfs/compression.c | |
parent | 08f340767dde5fd302af5b94ce6ce2d5e38a233d (diff) | |
download | linux-fc5c0c5825874859069ac44c367c724acd7190fb.tar.xz |
btrfs: defrag: extend ioctl to accept compression levels
The zstd and zlib compression types support setting compression levels.
Enhance the defrag interface to specify the levels as well. For zstd the
negative (realtime) levels are also accepted.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Daniel Vacek <neelx@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/compression.c')
-rw-r--r-- | fs/btrfs/compression.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 1fe154e7cc02..e7f8ee5d48a4 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -980,6 +980,16 @@ static int btrfs_compress_set_level(unsigned int type, int level) return level; } +/* + * Check whether the @level is within the valid range for the given type. + */ +bool btrfs_compress_level_valid(unsigned int type, int level) +{ + const struct btrfs_compress_op *ops = btrfs_compress_op[type]; + + return ops->min_level <= level && level <= ops->max_level; +} + /* Wrapper around find_get_page(), with extra error message. */ int btrfs_compress_filemap_get_folio(struct address_space *mapping, u64 start, struct folio **in_folio_ret) |