fs/erofs/decompressor_crypto.c
Source file repositories/reference/linux-study-clean/fs/erofs/decompressor_crypto.c
File Facts
- System
- Linux kernel
- Corpus path
fs/erofs/decompressor_crypto.c- Extension
.c- Size
- 4351 bytes
- Lines
- 183
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/scatterlist.hcrypto/acompress.hcompress.h
Detected Declarations
struct z_erofs_crypto_enginefunction __z_erofs_crypto_decompressfunction z_erofs_crypto_decompressfunction z_erofs_crypto_enable_enginefunction z_erofs_crypto_disable_all_enginesfunction z_erofs_crypto_show_engines
Annotated Snippet
struct z_erofs_crypto_engine {
char *crypto_name;
struct crypto_acomp *tfm;
};
static struct z_erofs_crypto_engine *z_erofs_crypto[Z_EROFS_COMPRESSION_MAX] = {
[Z_EROFS_COMPRESSION_LZ4] = (struct z_erofs_crypto_engine[]) {
{},
},
[Z_EROFS_COMPRESSION_LZMA] = (struct z_erofs_crypto_engine[]) {
{},
},
[Z_EROFS_COMPRESSION_DEFLATE] = (struct z_erofs_crypto_engine[]) {
{ .crypto_name = "qat_deflate", },
{},
},
[Z_EROFS_COMPRESSION_ZSTD] = (struct z_erofs_crypto_engine[]) {
{},
},
};
static DECLARE_RWSEM(z_erofs_crypto_rwsem);
static struct crypto_acomp *z_erofs_crypto_get_engine(int alg)
{
struct z_erofs_crypto_engine *e;
for (e = z_erofs_crypto[alg]; e->crypto_name; ++e)
if (e->tfm)
return e->tfm;
return NULL;
}
int z_erofs_crypto_decompress(struct z_erofs_decompress_req *rq,
struct page **pgpl)
{
struct crypto_acomp *tfm;
int i, err;
down_read(&z_erofs_crypto_rwsem);
tfm = z_erofs_crypto_get_engine(rq->alg);
if (!tfm) {
err = -EOPNOTSUPP;
goto out;
}
for (i = 0; i < rq->outpages; i++) {
struct page *const page = rq->out[i];
struct page *victim;
if (!page) {
victim = __erofs_allocpage(pgpl, rq->gfp, true);
if (!victim) {
err = -ENOMEM;
goto out;
}
set_page_private(victim, Z_EROFS_SHORTLIVED_PAGE);
rq->out[i] = victim;
}
}
err = __z_erofs_crypto_decompress(rq, tfm);
out:
up_read(&z_erofs_crypto_rwsem);
return err;
}
int z_erofs_crypto_enable_engine(const char *name, int len)
{
struct z_erofs_crypto_engine *e;
struct crypto_acomp *tfm;
int alg;
down_write(&z_erofs_crypto_rwsem);
for (alg = 0; alg < Z_EROFS_COMPRESSION_MAX; ++alg) {
for (e = z_erofs_crypto[alg]; e->crypto_name; ++e) {
if (!strncmp(name, e->crypto_name, len)) {
if (e->tfm)
break;
tfm = crypto_alloc_acomp(e->crypto_name, 0, 0);
if (IS_ERR(tfm)) {
up_write(&z_erofs_crypto_rwsem);
return -EOPNOTSUPP;
}
e->tfm = tfm;
break;
}
}
}
up_write(&z_erofs_crypto_rwsem);
return 0;
}
Annotation
- Immediate include surface: `linux/scatterlist.h`, `crypto/acompress.h`, `compress.h`.
- Detected declarations: `struct z_erofs_crypto_engine`, `function __z_erofs_crypto_decompress`, `function z_erofs_crypto_decompress`, `function z_erofs_crypto_enable_engine`, `function z_erofs_crypto_disable_all_engines`, `function z_erofs_crypto_show_engines`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- 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.