mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-08 06:44:35 +08:00
fe8eb122c8
This patch allows to change max_comp_streams on initialised zcomp. Introduce zcomp set_max_streams() knob, zcomp_strm_multi_set_max_streams() and zcomp_strm_single_set_max_streams() callbacks to change streams limit for zcomp_strm_multi and zcomp_strm_single, accordingly. set_max_streams for single steam zcomp does nothing. If user has lowered the limit, then zcomp_strm_multi_set_max_streams() attempts to immediately free extra streams (as much as it can, depending on idle streams availability). Note, this patch does not allow to change stream 'policy' from single to multi stream (or vice versa) on already initialised compression backend. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Jerome Marchand <jmarchan@redhat.com> Cc: Nitin Gupta <ngupta@vflare.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
67 lines
1.9 KiB
C
67 lines
1.9 KiB
C
/*
|
|
* Copyright (C) 2014 Sergey Senozhatsky.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*/
|
|
|
|
#ifndef _ZCOMP_H_
|
|
#define _ZCOMP_H_
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
struct zcomp_strm {
|
|
/* compression/decompression buffer */
|
|
void *buffer;
|
|
/*
|
|
* The private data of the compression stream, only compression
|
|
* stream backend can touch this (e.g. compression algorithm
|
|
* working memory)
|
|
*/
|
|
void *private;
|
|
/* used in multi stream backend, protected by backend strm_lock */
|
|
struct list_head list;
|
|
};
|
|
|
|
/* static compression backend */
|
|
struct zcomp_backend {
|
|
int (*compress)(const unsigned char *src, unsigned char *dst,
|
|
size_t *dst_len, void *private);
|
|
|
|
int (*decompress)(const unsigned char *src, size_t src_len,
|
|
unsigned char *dst);
|
|
|
|
void *(*create)(void);
|
|
void (*destroy)(void *private);
|
|
|
|
const char *name;
|
|
};
|
|
|
|
/* dynamic per-device compression frontend */
|
|
struct zcomp {
|
|
void *stream;
|
|
struct zcomp_backend *backend;
|
|
|
|
struct zcomp_strm *(*strm_find)(struct zcomp *comp);
|
|
void (*strm_release)(struct zcomp *comp, struct zcomp_strm *zstrm);
|
|
int (*set_max_streams)(struct zcomp *comp, int num_strm);
|
|
void (*destroy)(struct zcomp *comp);
|
|
};
|
|
|
|
struct zcomp *zcomp_create(const char *comp, int max_strm);
|
|
void zcomp_destroy(struct zcomp *comp);
|
|
|
|
struct zcomp_strm *zcomp_strm_find(struct zcomp *comp);
|
|
void zcomp_strm_release(struct zcomp *comp, struct zcomp_strm *zstrm);
|
|
|
|
int zcomp_compress(struct zcomp *comp, struct zcomp_strm *zstrm,
|
|
const unsigned char *src, size_t *dst_len);
|
|
|
|
int zcomp_decompress(struct zcomp *comp, const unsigned char *src,
|
|
size_t src_len, unsigned char *dst);
|
|
|
|
int zcomp_set_max_streams(struct zcomp *comp, int num_strm);
|
|
#endif /* _ZCOMP_H_ */
|