Commit Graph
3 Commits
Author SHA1 Message Date
Abdullah Zulfiqar c6c24b3e3a btrfs: implement Volume::NumFreeBlocks()
info->free_blocks in btrfs_read_fs_info() was hardcoded to 0,
which made df and any statvfs() based tool report a btrfs volume
as completely full regardless of actual usage.

Add btrfs_super_block::UsedSize() alongside the existing
TotalSize(), and use it to implement Volume::NumFreeBlocks() as
(TotalSize() - UsedSize()) / BlockSize().

Verified against btrfs-progs ground truth using fs_shell on a
freshly formatted 512 MB volume, free size reports 511.8MiB,
after writing a 200 MB file, free size drops to 311.6 MB,
matching real usage (200.75 MB per 'btrfs filesystem usage') to
within ~350 KB of B-tree metadata overhead.

Fixes #20182

Change-Id: Iffe9802480b1b8fa8cdb65f0c27a46ba921138b0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11258
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
2026-07-15 08:08:57 +00:00
Abdullah Zulfiqar ec061bd4f6 btrfs: Add Zstd decompression support for inline extents
Implement Zstd decompression for inline extents using kernel_libzstd
* Used zstd logic with #ifdef ZSTD_ENABLED to support architectures where Zstd is not yet available (e.g ARM64)
* Refactor BTRFS_EXTENT_COMPRESS_NONE handling: During testing with small files (which remain uncompressed inline), it was observed that the previous logic could cause integer underflows if the item_size was smaller than the header, resulting in garbage output. So I added explicit validation (item_size <= header_size) to prevent this.
* Update Jamfile to conditionally include Zstd headers and use $(HAIKU_ZSTD_LIB).
* Fixed coding style violations (else placement).

Change-Id: I74d8fd0b7d6d61bbc45fe571d5aacf5c74df0bd7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10309
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-02-05 07:49:07 +00:00
Abdullah Zulfiqar d52ea5c8d2 btrfs: handle unknown compression instead of panicking
Instead of triggering a Kernel Debugging Land (KDL) session when
encountering an unsupported compression type (like ZSTD), the driver
now returns B_NOT_SUPPORTED and logs an error.

This keeps the system stable and allows the VFS to handle the error
gracefully.

Fixes #19914

Change-Id: I5f43eef1c04982014430de63f3840af0d6cfefb0
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10263
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2026-01-24 15:12:08 +00:00