Files
apfstests/common/dmdust
T
Omar Sandoval e2e468d4dd btrfs/14{2,3}: use dm-dust instead of fail_make_request
These two tests test direct I/O and buffered read repair, respectively,
with fail_make_request. However, by using "fail_make_request/times",
they rely on repair having a specific I/O pattern. My pending Btrfs
direct I/O refactoring patch series changes this I/O pattern and thus
breaks this test.

The dm-dust target (added in v5.2) emulates a device with bad blocks
that are fixed when written to (like a device that remaps bad blocks).
This is exactly what we want for testing repair. Add some common dm-dust
helpers and update the tests to use dm-dust.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-05-18 00:25:17 +08:00

36 lines
839 B
Bash

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2020 Facebook. All Rights Reserved.
#
# common functions for setting up and tearing down a dmdust device
_init_dust()
{
local DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
DUST_DEV=/dev/mapper/dust-test
DUST_TABLE="0 $DEV_SIZE dust $SCRATCH_DEV 0 512"
_dmsetup_create dust-test --table "$DUST_TABLE" || \
_fatal "failed to create dust device"
}
_mount_dust()
{
_scratch_options mount
_mount -t $FSTYP `_common_dev_mount_options $*` $SCRATCH_OPTIONS \
$DUST_DEV $SCRATCH_MNT
}
_unmount_dust()
{
$UMOUNT_PROG $SCRATCH_MNT
}
_cleanup_dust()
{
# If dmsetup load fails then we need to make sure to do resume here
# otherwise the umount will hang
$DMSETUP_PROG resume dust-test > /dev/null 2>&1
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
_dmsetup_remove dust-test
}