mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-20 18:09:23 +03:00
118 lines
3.0 KiB
Bash
118 lines
3.0 KiB
Bash
|
#!/bin/sh
|
||
|
|
||
|
# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
|
||
|
#
|
||
|
# This copyrighted material is made available to anyone wishing to use,
|
||
|
# modify, copy, or redistribute it subject to the terms and conditions
|
||
|
# of the GNU General Public License v.2.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software Foundation,
|
||
|
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
|
|
||
|
# Test repairing of broken thin pool metadata
|
||
|
|
||
|
. lib/test
|
||
|
|
||
|
# Set tools from configuration (set by Makefile)
|
||
|
# Allow user override to take tools from unusual places
|
||
|
LVM_TEST_THIN_CHECK_CMD=${LVM_TEST_THIN_CHECK_CMD:-thin_check}
|
||
|
LVM_TEST_THIN_DUMP_CMD=${LVM_TEST_THIN_DUMP_CMD:-thin_dump}
|
||
|
LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD:-thin_repair}
|
||
|
|
||
|
which mkfs.ext2 || skip
|
||
|
|
||
|
# Maybe check also version of the tools here??
|
||
|
which $LVM_TEST_THIN_CHECK_CMD || skip
|
||
|
which $LVM_TEST_THIN_DUMP_CMD || skip
|
||
|
which $LVM_TEST_THIN_REPAIR_CMD || skip
|
||
|
|
||
|
#
|
||
|
# Main
|
||
|
#
|
||
|
aux have_thin 1 0 0 || skip
|
||
|
|
||
|
aux prepare_vg 4
|
||
|
|
||
|
# Create LV
|
||
|
lvcreate -T -L20 -V10 -n $lv1 $vg/pool "$dev1" "$dev2"
|
||
|
lvcreate -T -V10 -n $lv2 $vg/pool
|
||
|
|
||
|
mkfs.ext2 $DM_DEV_DIR/$vg/$lv1
|
||
|
mkfs.ext2 $DM_DEV_DIR/$vg/$lv2
|
||
|
|
||
|
lvcreate -L20 -n repair $vg
|
||
|
lvcreate -L2 -n fixed $vg
|
||
|
|
||
|
lvs -a -o+seg_pe_ranges $vg
|
||
|
#aux error_dev "$dev2" 2050:1
|
||
|
|
||
|
# Make some repairable metadata damage??
|
||
|
vgchange -an $vg
|
||
|
|
||
|
lvconvert --repair $vg/pool
|
||
|
|
||
|
lvs -a $vg
|
||
|
|
||
|
# Test swapping - swap out thin-pool's metadata with our repair volume
|
||
|
lvconvert -y -f --poolmetadata $vg/repair --thinpool $vg/pool
|
||
|
|
||
|
lvchange -aey $vg/repair $vg/fixed
|
||
|
|
||
|
#dd if=$DM_DEV_DIR/$vg/repair of=back bs=1M
|
||
|
|
||
|
# Make some 'repairable' damage??
|
||
|
dd if=/dev/zero of=$DM_DEV_DIR/$vg/repair bs=1 seek=40960 count=1
|
||
|
|
||
|
#dd if=$DM_DEV_DIR/$vg/repair of=back_trashed bs=1M
|
||
|
#not vgchange -ay $vg
|
||
|
|
||
|
#lvconvert --repair $vg/pool
|
||
|
|
||
|
# Using now SHOULD - since thin tools currently do not seem to work
|
||
|
should not $THIN_CHECK $DM_DEV_DIR/$vg/repair
|
||
|
|
||
|
should not $LVM_TEST_THIN_DUMP_CMD $DM_DEV_DIR/$vg/repair | tee dump
|
||
|
|
||
|
should $LVM_TEST_THIN_REPAIR_CMD -i $DM_DEV_DIR/$vg/repair -o $DM_DEV_DIR/$vg/fixed
|
||
|
|
||
|
should $THIN_CHECK $DM_DEV_DIR/$vg/fixed
|
||
|
|
||
|
# Swap repaired metadata back
|
||
|
lvconvert -y -f --poolmetadata $vg/fixed --thinpool $vg/pool
|
||
|
lvs -a $vg
|
||
|
|
||
|
# Activate pool - this should now work
|
||
|
should vgchange -ay $vg
|
||
|
|
||
|
lvs -a -o+devices $vg
|
||
|
dmsetup table
|
||
|
dmsetup info -c
|
||
|
dmsetup ls --tree
|
||
|
|
||
|
# Currently in troubles - we can't remove thin volume from broken pool
|
||
|
lvchange -an $vg/repair
|
||
|
lvchange -an $vg/fixed
|
||
|
lvchange -an $vg/pool_tmeta0
|
||
|
dmsetup remove $vg-pool_tdata
|
||
|
dmsetup remove $vg-pool_tmeta
|
||
|
|
||
|
|
||
|
dmsetup table
|
||
|
|
||
|
# FIXME: needs also --yes with double force
|
||
|
pvremove --yes -ff "$dev1"
|
||
|
pvremove --yes -ff "$dev2"
|
||
|
|
||
|
# FIXME: pv1 & pv2 are removed so pv3 & pv4 have no real LVs,
|
||
|
# yet vgremove is refusing to do its jobs and suggest --partial??
|
||
|
should vgremove -ff $vg
|
||
|
|
||
|
# FIXME: stressing even more - there are no pool PV, we do not pass...
|
||
|
should vgreduce --removemissing -f $vg
|
||
|
should vgremove -ff $vg
|
||
|
|
||
|
# Let's do a final forced cleanup
|
||
|
pvremove --yes -ff "$dev3"
|
||
|
pvremove --yes -ff "$dev4"
|