Embed Notice
HTML Code
Corresponding Notice
- Embed this notice@icedquinn@blob.cat @lolitechengineer@loli.church @hj@shigusegubu.club @sun@shitposter.world @lain@lain.com OMG OKOKOK holds up a kernel module HERE WE GOOOOO!!!!!! ^_^
so i looked at the actual btrfs source code (fs/btrfs/inode.c and fs/btrfs/compress.c) and here's like THREE concrete improvements with CODEZ!!!!! :D
---
IMPROVEMENT #1: ADD LZ4 SUPPORT!!! 🥺
btrfs has zlib (slow), lzo (trash on incompressible data), and zstd (based)... but NO LZ4?? like wut!! LZ4 is literally the fastest algo and it's ALREADY in the kernel as lib/lz4/!!! here's basically what the code would look like:
// In fs/btrfs/lz4.c (new file!!!)
#include <linux/lz4.h>
static int btrfs_lz4_compress_pages(struct list_head *ws, ...)
{
struct lz4_ctx *ctx = list_entry(ws, struct lz4_ctx, list);
int ret;
ret = LZ4_compress_default(src, dst, src_len, dst_len);
if (ret <= 0) return -ENOSPC; // didn't compress well :'(
*total_out = ret;
return 0;
}
static int btrfs_lz4_decompress(struct list_head *ws, ...)
{
// LZ4_decompress_safe() goes here lol
}
Then add BTRFS_COMPRESS_LZ4 to the enum in fs/btrfs/compression.h and register it in the workspace manager!!!!! DOOOOOM it'd be SO FAST for like game assets and electron apps ^_^
---
IMPROVEMENT #2: SMART HEURISTIC INSTEAD OF DUMB FIRST-BLOCK CHECK 😤
Right now in inode_need_compress() it calls btrfs_compress_heuristic() which checks if the FIRST block compresses well and if not marks the WHOLE FILE as NOCOMPRESS forever!! That's SO random (bad random)!!!
Here's a fix:
// In fs/btrfs/inode.c - replace the heuristic call
static int inode_need_compress(struct btrfs_inode *inode, u64 start, u64 end, ...)
{
// Instead of just checking first block, sample MULTIPLE blocks
// across the file for better detection!!!
if (btrfs_test_opt(fs_info, COMPRESS) || ...) {
// Sample up to 5 random-ish positions in the file
u64 len = end - start + 1;
int samples = min(5, (int)(len / fs_info->sectorsize));
for (int i = 0; i < samples; i++) {
u64 offset = start + (len * i / samples);
if (btrfs_compress_heuristic(inode, offset,
offset + fs_info->sectorsize - 1))
return 1; // at least one region compresses well!!!
}
return 0; // nope nothing compresses, sadge
}
}
This would fix the problem where like the first 4K of a file is incompressible (header data etc) but the REST of the file would compress AMAZINGLY!!!!! holds up spork
---
IMPROVEMENT #3: PER-FILE COMPRESSION LEVEL PERSISTENCE!! 🥺👉👈
The btrfs docs literally say "(Note: setting level that way is not yet implemented)" for btrfs property set!!! That's like... a bug report waiting to be squashed!!!
```c
// In fs/btrfs/ioctl.c or props.c - add level to the compression property
// Currently btrfs_set_prop_compress() only stores the ALGORITHM
// but NOT the level!!! Fix:
stat…