98.13. thin-provisioning-tools-1.3.4
thin_check and its family, without which LVM refuses to activate a thin pool
| Version | 1.3.4, release 1 |
| Shelf | disk — Block devices: partitioning, RAID, LVM, block encryption, SMART, NVMe, recovery, image writing and async I/O |
| Phase | 41_system (System), 394 of 1047 in build order |
| Licence | GPL-3.0-only |
| Homepage | https://github.com/jthornber/thin-provisioning-tools |
| Build time | 2.6 SBU |
| Installed size | 4.1 MiB in 46 files |
| Recipe | ports/core/disk/thin-provisioning-tools/kpkgbuild |
About
thin-provisioning-tools checks, dumps, restores and repairs the on-disk metadata of the kernel’s device-mapper thin-provisioning, cache and era targets: thin_check, thin_dump, thin_repair, cache_check and the rest. lvm2 runs thin_check before it activates a thin pool and cache_check before it activates a cached volume, and refuses the volume when the program cannot be run, so these tools are what makes LVM thin pools and caches usable on KDOS. lvm2 is configured with each tool’s path under /usr/sbin, and the initramfs carries thin_check and cache_check for a root on such a volume. It is a Rust program built from a vendored crate bundle.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/disk.txt:
LVM shells out to thin_check before it will activate a thin pool and refuses the pool when the call fails — and the shipped lvm.conf already names /usr/sbin/thin_check by absolute path. The initramfs carries it and cache_check, for a root on a thin or a cached volume.
Sources
thin-provisioning-tools-1.3.4.tar.gz(475.6 KiB)
sha256e09caa006ee6ff1e0b32dea934e6cb5d96412cd31163d82bd7ccdc1ac06304d5
upstream: https://github.com/jthornber/thin-provisioning-tools/archive/refs/tags/v1.3.4.tar.gz
archive copy: sources-1/disk--thin-provisioning-tools-1.3.4.tar.gzthin-provisioning-tools-vendor-1.3.4.tar.xz(13.3 MiB)
sha256f5bb0bc17ea4509ec783a5ea8c214e2fddb4bc8b236c33c515ce800622806bbf
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-1/disk--thin-provisioning-tools-vendor-1.3.4.tar.xz
Dependencies
Depends on: rust, gawk, pkgconf, lvm2.
Required by: no port names it.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install thin-provisioning-tools'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/disk/thin-provisioning-tools.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/disk/thin-provisioning-tools
echo 'e09caa006ee6ff1e0b32dea934e6cb5d96412cd31163d82bd7ccdc1ac06304d5 thin-provisioning-tools-1.3.4.tar.gz' | sha256sum -c -
echo 'f5bb0bc17ea4509ec783a5ea8c214e2fddb4bc8b236c33c515ce800622806bbf thin-provisioning-tools-vendor-1.3.4.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/thin-provisioning-tools
SRC=$SRC_ROOT/thin-provisioning-tools-1.3.4
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf thin-provisioning-tools-1.3.4.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
export CARGO_HOME="$SRC_ROOT/.cargo"
export RUSTFLAGS="-C target-feature=-crt-static"
export CARGO_NET_OFFLINE=true
cargo build --release --frozen --offline --features io_uring
install -Dm755 target/release/pdata_tools "$PKG/usr/sbin/pdata_tools"
for t in thin_check thin_dump thin_restore thin_repair thin_rmap thin_metadata_size \
thin_trim thin_delta thin_ls thin_metadata_pack thin_metadata_unpack thin_migrate \
cache_check cache_dump cache_restore cache_repair cache_metadata_size cache_writeback \
era_check era_dump era_restore era_invalidate; do
ln -sf pdata_tools "$PKG/usr/sbin/$t"
make "man8/$t.8"
install -Dm644 "man8/$t.8" -t "$PKG/usr/share/man/man8"
done
The switches, and why each is set:
--features io_uring— Compiles in the asynchronous I/O engine, built on theio-uringcrate from the vendor bundle. It is used only when asked for with the hidden--io-engine asyncoption; every tool still reads and writes through the synchronous engine by default, so a kernel without io_uring loses nothing.CARGO_NET_OFFLINE=true— Cargo’s environment form ofnet.offline: it never reaches the network, the same as--offlineon the command line.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/thin-provisioning-tools, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf thin-provisioning-tools-1.3.4-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/thin-provisioning-tools, and runs the triggers its paths call for.
Contents
Installed programs: cache_check, cache_dump, cache_metadata_size, cache_repair, cache_restore, cache_writeback, era_check, era_dump, era_invalidate, era_restore, pdata_tools, thin_check, thin_delta, thin_dump, thin_ls, thin_metadata_pack, thin_metadata_size, thin_metadata_unpack, thin_migrate, thin_repair, thin_restore, thin_rmap, thin_trim.
Installed directories: /usr/share/licenses/thin-provisioning-tools.
Short descriptions
cache_check |
validates cache metadata on a device or file. |
cache_dump |
dump cache metadata from device or file to standard output. |
cache_metadata_size |
Estimate the size of the metadata device needed for a given configuration. |
cache_repair |
repair cache binary metadata from device/file to device/file. |
cache_restore |
restore cache metadata file to device or file. |
cache_writeback |
writeback dirty blocks to the origin device. |
era_check |
validate era metadata on device or file. |
era_dump |
dump era metadata from device or file to standard output. |
era_invalidate |
Provide a list of blocks that have changed since a particular era. |
era_restore |
restore era metadata file to device or file. |
thin_check |
validates thin provisioning metadata on a device or file |
thin_delta |
Print the differences in the mappings between two thin devices. |
thin_dump |
dump thin provisioning metadata from device or file to standard output. |
thin_ls |
List thin volumes within a pool. |
thin_metadata_pack |
pack thin provisioning binary metadata. |
thin_metadata_size |
thin provisioning metadata device/file size calculator. |
thin_metadata_unpack |
unpack thin provisioning binary metadata. |
thin_repair |
repair thin provisioning binary metadata. |
thin_restore |
restore thin provisioning metadata file to device or file. |
thin_rmap |
output reverse map of a thin provisioned region of blocks from metadata device or file. |
thin_trim |
Issue discard requests for free pool space (offline tool). |
Notes
- One binary, many names. Upstream builds a single program,
pdata_tools, which picks the tool to run from the name it is invoked by. The recipe installs it in/usr/sbinand makes each tool a symbolic link to it, the same links upstream’smake installmakes; the links are what makethin_checka command. - The manual pages are made one by one. For each tool,
make man8/<tool>.8renders the page fromman8/<tool>.txtwith thebin/txt2manscript in the source, which callsgawkby name, so gawk is independs. The recipe does not run upstream’smake install, whose rule builds the program with a plaincargo build --release, without the recipe’s features and offline flags. - Built after lvm2.
thin_migratetalks to device-mapper through thedevicemappercrate, which links lvm2’slibdevmapper, found through pkg-config, so lvm2 is independs. lvm2 is therefore configured before these tools exist, and cannot runthin_check -Vorcache_check -Vto learn their versions; the lvm2 recipe names each tool’s path and the--clear-needs-check-flagsupport outright instead.