return NULL;
}
+const char* btrfs_compress_typelevel2str(enum btrfs_compression_type type,
+ int level, char *buf, size_t len)
+{
+ switch (type) {
+ case BTRFS_COMPRESS_ZLIB:
+ case BTRFS_COMPRESS_LZO:
+ case BTRFS_COMPRESS_ZSTD:
+ if (level) {
+ snprintf(buf, len, "%s:%d",
+ btrfs_compress_type2str(type), level);
+ return buf;
+ }
+ return btrfs_compress_type2str(type);
+ default:
+ break;
+ }
+
+ return NULL;
+}
+
static inline struct compressed_bio *to_compressed_bio(struct btrfs_bio *bbio)
{
return container_of(bbio, struct compressed_bio, bbio);
extern const struct btrfs_compress_levels btrfs_zstd_compress;
const char* btrfs_compress_type2str(enum btrfs_compression_type type);
+const char* btrfs_compress_typelevel2str(enum btrfs_compression_type type,
+ int level, char *buf, size_t len);
bool btrfs_compress_is_valid_type(const char *str);
int btrfs_compress_heuristic(struct btrfs_inode *inode, u64 start, u64 end);
static const char *prop_compression_extract(const struct btrfs_inode *inode,
char *buf, size_t len)
{
- switch (inode->prop_compress) {
- case BTRFS_COMPRESS_ZLIB:
- case BTRFS_COMPRESS_LZO:
- case BTRFS_COMPRESS_ZSTD:
- if (inode->prop_compress_level) {
- snprintf(buf, len, "%s:%d",
- btrfs_compress_type2str(inode->prop_compress),
- inode->prop_compress_level);
- return buf;
- }
- return btrfs_compress_type2str(inode->prop_compress);
- default:
- break;
- }
-
- return NULL;
+ return btrfs_compress_typelevel2str(inode->prop_compress,
+ inode->prop_compress_level,
+ buf, len);
}
static struct prop_handler prop_handlers[] = {