#!/usr/bin/env bash set -euo pipefail bash /scripts/guard.sh group="/hostcg/kubepods.slice/kubepods-pod${POD_UID//-/_}.slice" cd /lab/data require_bound=${1:-observe} [[ $require_bound == observe || $require_bound == assert ]] snapshot() { printf '[DEBUG-node4-attribution] %s\n' "$1" cat "$group/io.stat" printf 'ROOT_CGROUP\n' cat /hostcg/io.stat printf 'PHYSICAL_VDA\n' cat /sys/class/block/vda/stat } write_probe() { local label=$1 target=$2 start end snapshot "before-$label" start=$(date +%s%N) (ulimit -f 1024; dd if=/dev/urandom of="$target" bs=1048576 count=1 conv=fdatasync status=none) end=$(date +%s%N) awk -v label="$label" -v start="$start" -v end="$end" -v require_bound="$require_bound" 'BEGIN{s=(end-start)/1e9;printf "ATTRIBUTION %s seconds=%.6f\n",label,s;if(require_bound=="assert"&&s<0.75)exit 1}' snapshot "after-$label" } write_probe reused-inode io-buffered write_probe new-inode "attribution-new-$POD_UID" dd if=/lab/disk.img of=/dev/null count=0 iflag=nocache status=none write_probe reused-after-backing-eviction io-buffered write_probe plain-ext4-control "/lab/control/$POD_UID" rm -- "attribution-new-$POD_UID" "/lab/control/$POD_UID" printf 'ATTRIBUTION_COMPLETE\n'