diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/diff-dump-tree.sh | 13 | ||||
-rwxr-xr-x | scripts/main.sh | 60 | ||||
-rwxr-xr-x | scripts/mount.sh | 18 | ||||
-rwxr-xr-x | scripts/run-check.sh | 6 | ||||
-rwxr-xr-x | scripts/run-chunk-recover.sh | 7 | ||||
-rwxr-xr-x | scripts/run-clear-nodes.sh | 5 | ||||
-rwxr-xr-x | scripts/run-fsck.sh | 9 |
7 files changed, 58 insertions, 60 deletions
diff --git a/scripts/diff-dump-tree.sh b/scripts/diff-dump-tree.sh index 3d560d9..c3de337 100755 --- a/scripts/diff-dump-tree.sh +++ b/scripts/diff-dump-tree.sh @@ -1,4 +1,8 @@ #!/bin/bash +readonly image=../scratch/new.img + +###################################################################### + set -e ( cd ../btrfs-progs @@ -12,14 +16,19 @@ set -e fi make ) + +make build + +###################################################################### + diff -u \ - <(../btrfs-progs/btrfs inspect dump-tree --noscan --csum-items ../scratch/new.img | + <(../btrfs-progs/btrfs inspect dump-tree --noscan --csum-items "$image" | sed -e 's/ UNKNOWN.0 / UNTYPED /g' \ -e 's/\b18446744073709551615\b/-1/g' \ -e 's/INODE_REF 6)/INODE_REF ROOT_TREE_DIR)/g' \ -e 's/ROOT_BACKREF 5)/ROOT_BACKREF FS_TREE)/g' \ ) \ - <(go run ./cmd/btrfs-rec/ inspect dump-trees --pv=../scratch/new.img | + <(./bin/btrfs-rec inspect dump-trees --pv="$image" | sed -E \ -e 's/([0-9]),/\1/g' \ ) diff --git a/scripts/main.sh b/scripts/main.sh index d89f387..365862f 100755 --- a/scripts/main.sh +++ b/scripts/main.sh @@ -1,30 +1,40 @@ #!/bin/bash +readonly image=../scratch/dump-zero.img + +###################################################################### + set -e -b=../scratch/dump-zero -gen() ( + +run-btrfs-rec() { local tgt=$1; shift local log=${tgt%.*}.log if test -s "$tgt"; then return fi - { set -x; command time --verbose "$@"; } \ - >"$tgt" \ - 2> >(tee >&2 "$log") -) + { + set -x; + command time --verbose \ + ./bin/btrfs-rec \ + --pv="$image" \ + --profile.cpu="${tgt%.*}.cpu.pprof" \ + --profile.allocs="${tgt%.*}.allocs.pprof" \ + "$@" + } >"$tgt" 2> >(tee >&2 "$log") +} set -x -CGO_ENABLED=0 go build -trimpath ./cmd/btrfs-rec -mkdir -p "$b.gen" +make build +gendir="${image%.img}.gen" +mkdir -p "$gendir" +export GOMEMLIMIT="$(awk '/^MemTotal:/{ print $2 "KiB" }' </proc/meminfo)" { set +x; } &>/dev/null -export GOMEMLIMIT="$(awk '/^MemTotal:/{ print $2 "KiB" }' </proc/meminfo)" +###################################################################### -gen $b.gen/0.scandevices.json \ - ./btrfs-rec --pv=$b.img \ +run-btrfs-rec $gendir/0.scandevices.json \ inspect scandevices -gen $b.gen/1.mappings.json \ - ./btrfs-rec --pv=$b.img \ - inspect rebuild-mappings $b.gen/0.scandevices.json +run-btrfs-rec $gendir/1.mappings.json \ + inspect rebuild-mappings $gendir/0.scandevices.json # 1.mappings.log says: # @@ -44,19 +54,19 @@ gen $b.gen/1.mappings.json \ # # And then run that through `rebuild-mappings` again to fill in the # flags and normalize it. -gen $b.gen/2.mappings.json \ - ./btrfs-rec --pv=$b.img --mappings=<(sed <$b.gen/1.mappings.json \ +run-btrfs-rec $gendir/2.mappings.json \ + --mappings=<(sed <$gendir/1.mappings.json \ -e '2a{"LAddr":5242880,"PAddr":{"Dev":1,"Addr":5242880},"Size":1},' \ -e '2a{"LAddr":13631488,"PAddr":{"Dev":1,"Addr":13631488},"Size":1},') \ - inspect rebuild-mappings $b.gen/0.scandevices.json + inspect rebuild-mappings $gendir/0.scandevices.json -gen $b.gen/3.nodes.json \ - ./btrfs-rec --pv=$b.img --mappings=$b.gen/2.mappings.json \ - inspect rebuild-nodes $b.gen/0.scandevices.json +run-btrfs-rec $gendir/3.nodes.json \ + --mappings=$gendir/2.mappings.json \ + inspect rebuild-nodes $gendir/0.scandevices.json -# gen $b.gen/4.ls-files.txt \ -# ./btrfs-rec --pv=$b.img --mappings=$b.gen/2.mappings.json \ +# run-btrfs-rec $gendir/4.ls-files.txt \ +# --mappings=$gendir/2.mappings.json \ # inspect ls-files -# gen $b.gen/4.ls-trees.txt \ -# ./btrfs-rec --pv=$b.img --mappings=$b.gen/2.mappings.json \ -# inspect ls-trees --scandevices=$b.gen/0.scandevices.json +# run-btrfs-rec $gendir/4.ls-trees.txt \ +# --mappings=$gendir/2.mappings.json \ +# inspect ls-trees --scandevices=$gendir/0.scandevices.json diff --git a/scripts/mount.sh b/scripts/mount.sh index f75f403..bf84163 100755 --- a/scripts/mount.sh +++ b/scripts/mount.sh @@ -1,14 +1,20 @@ #!/bin/bash +readonly image=../scratch/dump-zero.img + +###################################################################### + set -e set -x -go build ./cmd/btrfs-rec +make build -mkdir -p ../scratch/dump-zero.mnt +gendir="${image%.img}.gen" +mountpoint="${image%.img}.mnt" +mkdir -p "$mountpoint" -sudo ./btrfs-rec \ - --pv ../scratch/dump-zero.img \ - --mappings=../scratch/dump-zero.gen/2.mappings.json \ +sudo ./bin/btrfs-rec \ + --pv="$image" + --mappings="$gendir/2.mappings.json" \ inspect mount \ --skip-filesums \ - ../scratch/dump-zero.mnt + "$mountpoint" diff --git a/scripts/run-check.sh b/scripts/run-check.sh deleted file mode 100755 index 6301305..0000000 --- a/scripts/run-check.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -set -e -rm -f ../scratch/dump-check.img -cp --reflink=always ../scratch/dump-{clearnodes,check}.img -make -C ../btrfs-progs -time ../btrfs-progs/btrfs check --progress --repair ../scratch/dump-check.img diff --git a/scripts/run-chunk-recover.sh b/scripts/run-chunk-recover.sh deleted file mode 100755 index f9a93d3..0000000 --- a/scripts/run-chunk-recover.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -e -rm -f ../scratch/dump-scratch.img -cp --reflink=always ../scratch/dump-{zero,scratch}.img -chmod 600 ../scratch/dump-scratch.img -make -C ../btrfs-progs -time ../btrfs-progs/btrfs rescue chunk-recover ../scratch/dump-scratch.img diff --git a/scripts/run-clear-nodes.sh b/scripts/run-clear-nodes.sh deleted file mode 100755 index 48186f8..0000000 --- a/scripts/run-clear-nodes.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -e -rm -f ../scratch/dump-clearnodes.img -cp --reflink=always ../scratch/dump-{scratch,clearnodes}.img -time go run ./cmd/btrfs-rec repair clear-bad-nodes --pv=../scratch/dump-clearnodes.img diff --git a/scripts/run-fsck.sh b/scripts/run-fsck.sh deleted file mode 100755 index 7fca6c0..0000000 --- a/scripts/run-fsck.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e -rm -f ../scratch/dump-scratch.img -cp --reflink=always ../scratch/dump-{zero,scratch}.img -chmod 600 ../scratch/dump-scratch.img -time go run ./cmd/btrfs-fsck ../scratch/dump-scratch.img -#make -C ../btrfs-progs -#time ../btrfs-progs/btrfs rescue chunk-recover ../scratch/dump-scratch.img -#time ../btrfs-progs/btrfs check ../scratch/dump-scratch.img |