Lines Matching refs:workspace
42 struct workspace { struct
89 static inline struct workspace *list_to_workspace(struct list_head *list) in list_to_workspace()
91 return container_of(list, struct workspace, list); in list_to_workspace()
120 struct workspace *victim = container_of(pos, struct workspace, in zstd_reclaim_timer_fn()
202 struct workspace *workspace; in zstd_cleanup_workspace_manager() local
208 workspace = container_of(wsm.idle_ws[i].next, in zstd_cleanup_workspace_manager()
209 struct workspace, list); in zstd_cleanup_workspace_manager()
210 list_del(&workspace->list); in zstd_cleanup_workspace_manager()
211 list_del(&workspace->lru_list); in zstd_cleanup_workspace_manager()
212 zstd_free_workspace(&workspace->list); in zstd_cleanup_workspace_manager()
234 struct workspace *workspace; in zstd_find_workspace() local
241 workspace = list_to_workspace(ws); in zstd_find_workspace()
244 workspace->req_level = level; in zstd_find_workspace()
245 if (level == workspace->level) in zstd_find_workspace()
246 list_del(&workspace->lru_list); in zstd_find_workspace()
310 struct workspace *workspace = list_to_workspace(ws); in zstd_put_workspace() local
315 if (workspace->req_level == workspace->level) { in zstd_put_workspace()
318 INIT_LIST_HEAD(&workspace->lru_list); in zstd_put_workspace()
320 workspace->last_used = jiffies; in zstd_put_workspace()
321 list_add(&workspace->lru_list, &wsm.lru_list); in zstd_put_workspace()
328 set_bit(workspace->level - 1, &wsm.active_map); in zstd_put_workspace()
329 list_add(&workspace->list, &wsm.idle_ws[workspace->level - 1]); in zstd_put_workspace()
330 workspace->req_level = 0; in zstd_put_workspace()
334 if (workspace->level == ZSTD_BTRFS_MAX_LEVEL) in zstd_put_workspace()
340 struct workspace *workspace = list_entry(ws, struct workspace, list); in zstd_free_workspace() local
342 kvfree(workspace->mem); in zstd_free_workspace()
343 kfree(workspace->buf); in zstd_free_workspace()
344 kfree(workspace); in zstd_free_workspace()
349 struct workspace *workspace; in zstd_alloc_workspace() local
351 workspace = kzalloc(sizeof(*workspace), GFP_KERNEL); in zstd_alloc_workspace()
352 if (!workspace) in zstd_alloc_workspace()
355 workspace->size = zstd_ws_mem_sizes[level - 1]; in zstd_alloc_workspace()
356 workspace->level = level; in zstd_alloc_workspace()
357 workspace->req_level = level; in zstd_alloc_workspace()
358 workspace->last_used = jiffies; in zstd_alloc_workspace()
359 workspace->mem = kvmalloc(workspace->size, GFP_KERNEL); in zstd_alloc_workspace()
360 workspace->buf = kmalloc(PAGE_SIZE, GFP_KERNEL); in zstd_alloc_workspace()
361 if (!workspace->mem || !workspace->buf) in zstd_alloc_workspace()
364 INIT_LIST_HEAD(&workspace->list); in zstd_alloc_workspace()
365 INIT_LIST_HEAD(&workspace->lru_list); in zstd_alloc_workspace()
367 return &workspace->list; in zstd_alloc_workspace()
369 zstd_free_workspace(&workspace->list); in zstd_alloc_workspace()
377 struct workspace *workspace = list_entry(ws, struct workspace, list); in zstd_compress_pages() local
388 zstd_parameters params = zstd_get_btrfs_parameters(workspace->req_level, in zstd_compress_pages()
396 stream = zstd_init_cstream(¶ms, len, workspace->mem, in zstd_compress_pages()
397 workspace->size); in zstd_compress_pages()
406 workspace->in_buf.src = kmap_local_page(in_page); in zstd_compress_pages()
407 workspace->in_buf.pos = 0; in zstd_compress_pages()
408 workspace->in_buf.size = min_t(size_t, len, PAGE_SIZE); in zstd_compress_pages()
418 workspace->out_buf.dst = page_address(out_page); in zstd_compress_pages()
419 workspace->out_buf.pos = 0; in zstd_compress_pages()
420 workspace->out_buf.size = min_t(size_t, max_out, PAGE_SIZE); in zstd_compress_pages()
425 ret2 = zstd_compress_stream(stream, &workspace->out_buf, in zstd_compress_pages()
426 &workspace->in_buf); in zstd_compress_pages()
435 if (tot_in + workspace->in_buf.pos > 8192 && in zstd_compress_pages()
436 tot_in + workspace->in_buf.pos < in zstd_compress_pages()
437 tot_out + workspace->out_buf.pos) { in zstd_compress_pages()
443 if (workspace->out_buf.pos >= max_out) { in zstd_compress_pages()
444 tot_out += workspace->out_buf.pos; in zstd_compress_pages()
450 if (workspace->out_buf.pos == workspace->out_buf.size) { in zstd_compress_pages()
463 workspace->out_buf.dst = page_address(out_page); in zstd_compress_pages()
464 workspace->out_buf.pos = 0; in zstd_compress_pages()
465 workspace->out_buf.size = min_t(size_t, max_out, in zstd_compress_pages()
470 if (workspace->in_buf.pos >= len) { in zstd_compress_pages()
471 tot_in += workspace->in_buf.pos; in zstd_compress_pages()
476 if (workspace->in_buf.pos == workspace->in_buf.size) { in zstd_compress_pages()
478 kunmap_local(workspace->in_buf.src); in zstd_compress_pages()
483 workspace->in_buf.src = kmap_local_page(in_page); in zstd_compress_pages()
484 workspace->in_buf.pos = 0; in zstd_compress_pages()
485 workspace->in_buf.size = min_t(size_t, len, PAGE_SIZE); in zstd_compress_pages()
491 ret2 = zstd_end_stream(stream, &workspace->out_buf); in zstd_compress_pages()
499 tot_out += workspace->out_buf.pos; in zstd_compress_pages()
502 if (workspace->out_buf.pos >= max_out) { in zstd_compress_pages()
503 tot_out += workspace->out_buf.pos; in zstd_compress_pages()
520 workspace->out_buf.dst = page_address(out_page); in zstd_compress_pages()
521 workspace->out_buf.pos = 0; in zstd_compress_pages()
522 workspace->out_buf.size = min_t(size_t, max_out, PAGE_SIZE); in zstd_compress_pages()
535 if (workspace->in_buf.src) { in zstd_compress_pages()
536 kunmap_local(workspace->in_buf.src); in zstd_compress_pages()
544 struct workspace *workspace = list_entry(ws, struct workspace, list); in zstd_decompress_bio() local
555 ZSTD_BTRFS_MAX_INPUT, workspace->mem, workspace->size); in zstd_decompress_bio()
562 workspace->in_buf.src = kmap_local_page(pages_in[page_in_index]); in zstd_decompress_bio()
563 workspace->in_buf.pos = 0; in zstd_decompress_bio()
564 workspace->in_buf.size = min_t(size_t, srclen, PAGE_SIZE); in zstd_decompress_bio()
566 workspace->out_buf.dst = workspace->buf; in zstd_decompress_bio()
567 workspace->out_buf.pos = 0; in zstd_decompress_bio()
568 workspace->out_buf.size = PAGE_SIZE; in zstd_decompress_bio()
573 ret2 = zstd_decompress_stream(stream, &workspace->out_buf, in zstd_decompress_bio()
574 &workspace->in_buf); in zstd_decompress_bio()
582 total_out += workspace->out_buf.pos; in zstd_decompress_bio()
583 workspace->out_buf.pos = 0; in zstd_decompress_bio()
585 ret = btrfs_decompress_buf2page(workspace->out_buf.dst, in zstd_decompress_bio()
590 if (workspace->in_buf.pos >= srclen) in zstd_decompress_bio()
597 if (workspace->in_buf.pos == workspace->in_buf.size) { in zstd_decompress_bio()
598 kunmap_local(workspace->in_buf.src); in zstd_decompress_bio()
601 workspace->in_buf.src = NULL; in zstd_decompress_bio()
606 workspace->in_buf.src = kmap_local_page(pages_in[page_in_index]); in zstd_decompress_bio()
607 workspace->in_buf.pos = 0; in zstd_decompress_bio()
608 workspace->in_buf.size = min_t(size_t, srclen, PAGE_SIZE); in zstd_decompress_bio()
614 if (workspace->in_buf.src) in zstd_decompress_bio()
615 kunmap_local(workspace->in_buf.src); in zstd_decompress_bio()
623 struct workspace *workspace = list_entry(ws, struct workspace, list); in zstd_decompress() local
631 ZSTD_BTRFS_MAX_INPUT, workspace->mem, workspace->size); in zstd_decompress()
640 workspace->in_buf.src = data_in; in zstd_decompress()
641 workspace->in_buf.pos = 0; in zstd_decompress()
642 workspace->in_buf.size = srclen; in zstd_decompress()
644 workspace->out_buf.dst = workspace->buf; in zstd_decompress()
645 workspace->out_buf.pos = 0; in zstd_decompress()
646 workspace->out_buf.size = PAGE_SIZE; in zstd_decompress()
650 && workspace->in_buf.pos < workspace->in_buf.size) { in zstd_decompress()
661 ret2 = zstd_decompress_stream(stream, &workspace->out_buf, in zstd_decompress()
662 &workspace->in_buf); in zstd_decompress()
671 total_out += workspace->out_buf.pos; in zstd_decompress()
672 workspace->out_buf.pos = 0; in zstd_decompress()
683 workspace->out_buf.size - buf_offset); in zstd_decompress()
686 workspace->out_buf.dst + buf_offset, bytes); in zstd_decompress()