Lines Matching refs:ws
94 static int compression_compress_pages(int type, struct list_head *ws, in compression_compress_pages() argument
101 return zlib_compress_pages(ws, mapping, start, pages, in compression_compress_pages()
104 return lzo_compress_pages(ws, mapping, start, pages, in compression_compress_pages()
107 return zstd_compress_pages(ws, mapping, start, pages, in compression_compress_pages()
125 static int compression_decompress_bio(struct list_head *ws, in compression_decompress_bio() argument
129 case BTRFS_COMPRESS_ZLIB: return zlib_decompress_bio(ws, cb); in compression_decompress_bio()
130 case BTRFS_COMPRESS_LZO: return lzo_decompress_bio(ws, cb); in compression_decompress_bio()
131 case BTRFS_COMPRESS_ZSTD: return zstd_decompress_bio(ws, cb); in compression_decompress_bio()
142 static int compression_decompress(int type, struct list_head *ws, in compression_decompress() argument
147 case BTRFS_COMPRESS_ZLIB: return zlib_decompress(ws, data_in, dest_page, in compression_decompress()
149 case BTRFS_COMPRESS_LZO: return lzo_decompress(ws, data_in, dest_page, in compression_decompress()
151 case BTRFS_COMPRESS_ZSTD: return zstd_decompress(ws, data_in, dest_page, in compression_decompress()
593 static void free_heuristic_ws(struct list_head *ws) in free_heuristic_ws() argument
597 workspace = list_entry(ws, struct heuristic_ws, list); in free_heuristic_ws()
607 struct heuristic_ws *ws; in alloc_heuristic_ws() local
609 ws = kzalloc(sizeof(*ws), GFP_KERNEL); in alloc_heuristic_ws()
610 if (!ws) in alloc_heuristic_ws()
613 ws->sample = kvmalloc(MAX_SAMPLE_SIZE, GFP_KERNEL); in alloc_heuristic_ws()
614 if (!ws->sample) in alloc_heuristic_ws()
617 ws->bucket = kcalloc(BUCKET_SIZE, sizeof(*ws->bucket), GFP_KERNEL); in alloc_heuristic_ws()
618 if (!ws->bucket) in alloc_heuristic_ws()
621 ws->bucket_b = kcalloc(BUCKET_SIZE, sizeof(*ws->bucket_b), GFP_KERNEL); in alloc_heuristic_ws()
622 if (!ws->bucket_b) in alloc_heuristic_ws()
625 INIT_LIST_HEAD(&ws->list); in alloc_heuristic_ws()
626 return &ws->list; in alloc_heuristic_ws()
628 free_heuristic_ws(&ws->list); in alloc_heuristic_ws()
660 static void free_workspace(int type, struct list_head *ws) in free_workspace() argument
663 case BTRFS_COMPRESS_NONE: return free_heuristic_ws(ws); in free_workspace()
664 case BTRFS_COMPRESS_ZLIB: return zlib_free_workspace(ws); in free_workspace()
665 case BTRFS_COMPRESS_LZO: return lzo_free_workspace(ws); in free_workspace()
666 case BTRFS_COMPRESS_ZSTD: return zstd_free_workspace(ws); in free_workspace()
705 struct list_head *ws; in btrfs_cleanup_workspace_manager() local
709 ws = wsman->idle_ws.next; in btrfs_cleanup_workspace_manager()
710 list_del(ws); in btrfs_cleanup_workspace_manager()
711 free_workspace(type, ws); in btrfs_cleanup_workspace_manager()
821 void btrfs_put_workspace(int type, struct list_head *ws) in btrfs_put_workspace() argument
839 list_add(ws, idle_ws); in btrfs_put_workspace()
846 free_workspace(type, ws); in btrfs_put_workspace()
852 static void put_workspace(int type, struct list_head *ws) in put_workspace() argument
855 case BTRFS_COMPRESS_NONE: return btrfs_put_workspace(type, ws); in put_workspace()
856 case BTRFS_COMPRESS_ZLIB: return btrfs_put_workspace(type, ws); in put_workspace()
857 case BTRFS_COMPRESS_LZO: return btrfs_put_workspace(type, ws); in put_workspace()
858 case BTRFS_COMPRESS_ZSTD: return zstd_put_workspace(ws); in put_workspace()
1093 static u32 shannon_entropy(struct heuristic_ws *ws) in shannon_entropy() argument
1100 sz_base = ilog2_w(ws->sample_size); in shannon_entropy()
1101 for (i = 0; i < BUCKET_SIZE && ws->bucket[i].count > 0; i++) { in shannon_entropy()
1102 p = ws->bucket[i].count; in shannon_entropy()
1107 entropy_sum /= ws->sample_size; in shannon_entropy()
1229 static int byte_core_set_size(struct heuristic_ws *ws) in byte_core_set_size() argument
1233 const u32 core_set_threshold = ws->sample_size * 90 / 100; in byte_core_set_size()
1234 struct bucket_item *bucket = ws->bucket; in byte_core_set_size()
1237 radix_sort(ws->bucket, ws->bucket_b, BUCKET_SIZE); in byte_core_set_size()
1267 static u32 byte_set_size(const struct heuristic_ws *ws) in byte_set_size() argument
1273 if (ws->bucket[i].count > 0) in byte_set_size()
1283 if (ws->bucket[i].count > 0) { in byte_set_size()
1293 static bool sample_repeated_patterns(struct heuristic_ws *ws) in sample_repeated_patterns() argument
1295 const u32 half_of_sample = ws->sample_size / 2; in sample_repeated_patterns()
1296 const u8 *data = ws->sample; in sample_repeated_patterns()
1302 struct heuristic_ws *ws) in heuristic_collect_sample() argument
1338 memcpy(&ws->sample[curr_sample_pos], &in_data[i], in heuristic_collect_sample()
1350 ws->sample_size = curr_sample_pos; in heuristic_collect_sample()
1371 struct heuristic_ws *ws; in btrfs_compress_heuristic() local
1376 ws = list_entry(ws_list, struct heuristic_ws, list); in btrfs_compress_heuristic()
1378 heuristic_collect_sample(inode, start, end, ws); in btrfs_compress_heuristic()
1380 if (sample_repeated_patterns(ws)) { in btrfs_compress_heuristic()
1385 memset(ws->bucket, 0, sizeof(*ws->bucket)*BUCKET_SIZE); in btrfs_compress_heuristic()
1387 for (i = 0; i < ws->sample_size; i++) { in btrfs_compress_heuristic()
1388 byte = ws->sample[i]; in btrfs_compress_heuristic()
1389 ws->bucket[byte].count++; in btrfs_compress_heuristic()
1392 i = byte_set_size(ws); in btrfs_compress_heuristic()
1398 i = byte_core_set_size(ws); in btrfs_compress_heuristic()
1409 i = shannon_entropy(ws); in btrfs_compress_heuristic()