mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Add zdb -r <dataset> <object-id | file> <output>
While you can use zdb -R poolname vdev:offset:[<lsize>/]<psize>[:flags] to extract individual DVAs from a vdev, it would be handy for be able copy an entire file out of the pool. Given a file or object number, add support to copy the contents to a file. Useful for debugging and recovery. Reviewed-by: Jorgen Lundman <lundman@lundman.net> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Allan Jude <allan@klarasystems.com> Closes #11027
This commit is contained in:
@@ -119,7 +119,7 @@ tests = ['zdb_002_pos', 'zdb_003_pos', 'zdb_004_pos', 'zdb_005_pos',
|
||||
'zdb_006_pos', 'zdb_args_neg', 'zdb_args_pos',
|
||||
'zdb_block_size_histogram', 'zdb_checksum', 'zdb_decompress',
|
||||
'zdb_display_block', 'zdb_object_range_neg', 'zdb_object_range_pos',
|
||||
'zdb_objset_id', 'zdb_decompress_zstd']
|
||||
'zdb_objset_id', 'zdb_decompress_zstd', 'zdb_recover', 'zdb_recover_2']
|
||||
pre =
|
||||
post =
|
||||
tags = ['functional', 'cli_root', 'zdb']
|
||||
|
||||
@@ -14,4 +14,6 @@ dist_pkgdata_SCRIPTS = \
|
||||
zdb_object_range_neg.ksh \
|
||||
zdb_object_range_pos.ksh \
|
||||
zdb_display_block.ksh \
|
||||
zdb_objset_id.ksh
|
||||
zdb_objset_id.ksh \
|
||||
zdb_recover.ksh \
|
||||
zdb_recover_2.ksh
|
||||
|
||||
@@ -56,7 +56,7 @@ set -A args "create" "add" "destroy" "import fakepool" \
|
||||
"add mirror fakepool" "add raidz fakepool" \
|
||||
"add raidz1 fakepool" "add raidz2 fakepool" \
|
||||
"setvprop" "blah blah" "-%" "--?" "-*" "-=" \
|
||||
"-a" "-f" "-g" "-j" "-n" "-o" "-p" "-p /tmp" "-r" \
|
||||
"-a" "-f" "-g" "-j" "-n" "-o" "-p" "-p /tmp" \
|
||||
"-t" "-w" "-z" "-E" "-H" "-I" "-J" "-K" \
|
||||
"-N" "-Q" "-R" "-T" "-W"
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#!/bin/ksh
|
||||
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by Allan Jude.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# Description:
|
||||
# zdb -r <dataset> <path> <destination>
|
||||
# Will extract <path> (relative to <dataset>) to the file <destination>
|
||||
# Similar to -R, except it does the work for you to find each record
|
||||
#
|
||||
# Strategy:
|
||||
# 1. Create a pool
|
||||
# 2. Write some data to a file
|
||||
# 3. Extract the file
|
||||
# 4. Compare the file to the original
|
||||
#
|
||||
|
||||
function cleanup
|
||||
{
|
||||
datasetexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||
rm $tmpfile
|
||||
}
|
||||
|
||||
log_assert "Verify zdb -r <dataset> <path> <dest> extract the correct data."
|
||||
log_onexit cleanup
|
||||
init_data=$TESTDIR/file1
|
||||
tmpfile="$TEST_BASE_DIR/zdb-recover"
|
||||
write_count=8
|
||||
blksize=131072
|
||||
verify_runnable "global"
|
||||
verify_disk_count "$DISKS" 2
|
||||
|
||||
default_mirror_setup_noexit $DISKS
|
||||
file_write -o create -w -f $init_data -b $blksize -c $write_count
|
||||
log_must zpool sync $TESTPOOL
|
||||
|
||||
output=$(zdb -r $TESTPOOL/$TESTFS file1 $tmpfile)
|
||||
log_must cmp $init_data $tmpfile
|
||||
|
||||
log_pass "zdb -r <dataset> <path> <dest> extracts the correct data."
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/bin/ksh
|
||||
|
||||
#
|
||||
# This file and its contents are supplied under the terms of the
|
||||
# Common Development and Distribution License ("CDDL"), version 1.0.
|
||||
# You may only use this file in accordance with the terms of version
|
||||
# 1.0 of the CDDL.
|
||||
#
|
||||
# A full copy of the text of the CDDL should have accompanied this
|
||||
# source. A copy of the CDDL is also available via the Internet at
|
||||
# http://www.illumos.org/license/CDDL.
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright (c) 2021 by Allan Jude.
|
||||
#
|
||||
|
||||
. $STF_SUITE/include/libtest.shlib
|
||||
|
||||
#
|
||||
# Description:
|
||||
# zdb -r <dataset> <path> <destination>
|
||||
# Will extract <path> (relative to <dataset>) to the file <destination>
|
||||
# Similar to -R, except it does the work for you to find each record
|
||||
#
|
||||
# Strategy:
|
||||
# 1. Create a pool
|
||||
# 2. Write some data to a file
|
||||
# 3. Append to the file so it isn't an divisible by 2
|
||||
# 4. Extract the file
|
||||
# 5. Compare the file to the original
|
||||
#
|
||||
|
||||
function cleanup
|
||||
{
|
||||
datasetexists $TESTPOOL && destroy_pool $TESTPOOL
|
||||
rm $tmpfile
|
||||
}
|
||||
|
||||
log_assert "Verify zdb -r <dataset> <path> <dest> extract the correct data."
|
||||
log_onexit cleanup
|
||||
init_data=$TESTDIR/file1
|
||||
tmpfile="$TEST_BASE_DIR/zdb-recover"
|
||||
write_count=8
|
||||
blksize=131072
|
||||
verify_runnable "global"
|
||||
verify_disk_count "$DISKS" 2
|
||||
|
||||
default_mirror_setup_noexit $DISKS
|
||||
file_write -o create -w -f $init_data -b $blksize -c $write_count
|
||||
log_must echo "zfs" >> $init_data
|
||||
log_must zpool sync $TESTPOOL
|
||||
|
||||
output=$(zdb -r $TESTPOOL/$TESTFS file1 $tmpfile)
|
||||
log_must cmp $init_data $tmpfile
|
||||
|
||||
log_pass "zdb -r <dataset> <path> <dest> extracts the correct data."
|
||||
Reference in New Issue
Block a user