lkml.org 
[lkml]   [2017]   [Jul]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 3/4] btrfs: Add zstd support
On Thu, Jun 29, 2017 at 12:41:07PM -0700, Nick Terrell wrote:
> +static void zstd_free_workspace(struct list_head *ws)
> +{
> + struct workspace *workspace = list_entry(ws, struct workspace, list);
> +
> + vfree(workspace->mem);
> + kfree(workspace->buf);
> + kfree(workspace);
> +}
> +
> +static struct list_head *zstd_alloc_workspace(void)
> +{
> + ZSTD_parameters params =
> + zstd_get_btrfs_parameters(ZSTD_BTRFS_MAX_INPUT);
> + struct workspace *workspace;
> +
> + workspace = kzalloc(sizeof(*workspace), GFP_NOFS);
> + if (!workspace)
> + return ERR_PTR(-ENOMEM);
> +
> + workspace->size = max_t(size_t,
> + ZSTD_CStreamWorkspaceBound(params.cParams),
> + ZSTD_DStreamWorkspaceBound(ZSTD_BTRFS_MAX_INPUT));
> + workspace->mem = vmalloc(workspace->size);
> + workspace->buf = kmalloc(PAGE_SIZE, GFP_NOFS);
> + if (!workspace->mem || !workspace->buf)
> + goto fail;
> +
> + INIT_LIST_HEAD(&workspace->list);
> +
> + return &workspace->list;
> +fail:
> + zstd_free_workspace(&workspace->list);
> + return ERR_PTR(-ENOMEM);
> +}

In the next iteration, please update the workspace allocations so that
they use kvmalloc/kvfree and GFP_KERNEL (eg. 6acafd1eff426).

\
 
 \ /
  Last update: 2017-07-18 20:23    [W:0.129 / U:2.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site