drivers/block/zram/zcomp.h
Source file repositories/reference/linux-study-clean/drivers/block/zram/zcomp.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/block/zram/zcomp.h- Extension
.h- Size
- 2425 bytes
- Lines
- 97
- Domain
- Driver Families
- Bucket
- drivers/block
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/mutex.h
Detected Declarations
struct deflate_paramsstruct zcomp_paramsstruct zcomp_ctxstruct zcomp_strmstruct zcomp_reqstruct zcomp_opsstruct zcomp
Annotated Snippet
struct deflate_params {
s32 winbits;
};
/*
* Immutable driver (backend) parameters. The driver may attach private
* data to it (e.g. driver representation of the dictionary, etc.).
*
* This data is kept per-comp and is shared among execution contexts.
*/
struct zcomp_params {
void *dict;
size_t dict_sz;
s32 level;
union {
struct deflate_params deflate;
};
void *drv_data;
};
/*
* Run-time driver context - scratch buffers, etc. It is modified during
* request execution (compression/decompression), cannot be shared, so
* it's in per-CPU area.
*/
struct zcomp_ctx {
void *context;
};
struct zcomp_strm {
struct mutex lock;
/* compression buffer */
void *buffer;
/* local copy of handle memory */
void *local_copy;
struct zcomp_ctx ctx;
};
struct zcomp_req {
const unsigned char *src;
const size_t src_len;
unsigned char *dst;
size_t dst_len;
};
struct zcomp_ops {
int (*compress)(struct zcomp_params *params, struct zcomp_ctx *ctx,
struct zcomp_req *req);
int (*decompress)(struct zcomp_params *params, struct zcomp_ctx *ctx,
struct zcomp_req *req);
int (*create_ctx)(struct zcomp_params *params, struct zcomp_ctx *ctx);
void (*destroy_ctx)(struct zcomp_ctx *ctx);
int (*setup_params)(struct zcomp_params *params);
void (*release_params)(struct zcomp_params *params);
const char *name;
};
/* dynamic per-device compression frontend */
struct zcomp {
struct zcomp_strm __percpu *stream;
const struct zcomp_ops *ops;
struct zcomp_params *params;
struct hlist_node node;
};
int zcomp_cpu_up_prepare(unsigned int cpu, struct hlist_node *node);
int zcomp_cpu_dead(unsigned int cpu, struct hlist_node *node);
ssize_t zcomp_available_show(const char *comp, char *buf, ssize_t at);
const char *zcomp_lookup_backend_name(const char *comp);
struct zcomp *zcomp_create(const char *alg, struct zcomp_params *params);
void zcomp_destroy(struct zcomp *comp);
struct zcomp_strm *zcomp_stream_get(struct zcomp *comp);
void zcomp_stream_put(struct zcomp_strm *zstrm);
int zcomp_compress(struct zcomp *comp, struct zcomp_strm *zstrm,
const void *src, unsigned int *dst_len);
int zcomp_decompress(struct zcomp *comp, struct zcomp_strm *zstrm,
const void *src, unsigned int src_len, void *dst);
#endif /* _ZCOMP_H_ */
Annotation
- Immediate include surface: `linux/mutex.h`.
- Detected declarations: `struct deflate_params`, `struct zcomp_params`, `struct zcomp_ctx`, `struct zcomp_strm`, `struct zcomp_req`, `struct zcomp_ops`, `struct zcomp`.
- Atlas domain: Driver Families / drivers/block.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.