git: sys/dev/disk/dm: Add dm-flakey target
Tomohiro Kusumi
tkusumi at crater.dragonflybsd.org
Thu Nov 19 05:50:01 PST 2015
commit b9790952d463c74d2706f84a3b2b5e035eb3059b
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date: Sun Nov 15 19:22:47 2015 +0900
sys/dev/disk/dm: Add dm-flakey target
This commit adds a new dm target dm-flakey.
This target simulates failing devices for testing purposes.
See dm_target_flakey(4) for details.
Note that using this dm target may results in some unstable
status including kernel panic. For example hammer is likely
to cause kernel panic by write data corruption by dm-flakey.
Don't use this target over any block device in production.
===== Example1 - Error write I/Os
# kldload dm_target_flakey
# dmsetup create flakey1 --table "0 234436482 flakey ${DEV} 0 1 1"
# newfs_hammer -L TEST /dev/mapper/flakey1
Volume 0 DEVICE /dev/mapper/flakey1 size 111.79GB
initialize freemap volume 0
initializing the undo map (504 MB)
newfs_hammer: Write volume 0 (/dev/mapper/flakey1): Input/output error
# dmsetup remove /dev/mapper/flakey1
===== Example2 - Silently drop write I/Os
# newfs_hammer -L TEST ${DEV} > /dev/null
# mount_hammer ${DEV} /HAMMER
# cd /HAMMER
# git clone /usr/local/src/dragonfly
Cloning into 'dragonfly'...
done.
Checking out files: 100% (34434/34434), done.
# cd
# umount /HAMMER
# dmsetup create flakey2 --table "0 234436482 flakey ${DEV} 0 1 1 1 drop_writes"
# mount_hammer /dev/mapper/flakey2 /HAMMER
# dmesg | tail -3
HAMMER() Critical error inode=-1 error=5 while flushing meta-data
HAMMER() Forcing read-only mode
HAMMER(TEST) mounted clean, no recovery needed
# hammer volume-list /HAMMER
/dev/mapper/flakey2
# mount | grep "/HAMMER"
TEST on /HAMMER (hammer, local, read-only)
# cd /HAMMER/dragonfly
# git log -p > /dev/null; echo $?
0
# cd
# umount /HAMMER
# dmsetup remove /dev/mapper/flakey2
===== Example3 - Corrupt read I/Os
# dd if=/dev/zero of=${DEV} bs=1024 count=10000 >/dev/null 2>&1
# dmsetup create flakey3 --table "0 234436482 flakey ${DEV} 0 1 1 5 corrupt_bio_byte 1 r 65 0"
# od -tx1 /dev/mapper/flakey3 | head -10
0000000 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
0010000 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0010020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
0020000 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0020020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
0030000 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
# dmsetup remove /dev/mapper/flakey3
# kldunload dm_target_flakey
Summary of changes:
share/man/man4/Makefile | 1 +
.../man4/{dm_target_delay.4 => dm_target_flakey.4} | 74 +++-
sys/conf/files | 1 +
sys/config/LINT64 | 1 +
sys/dev/disk/dm/dm.h | 1 +
sys/dev/disk/dm/targets/Makefile | 2 +-
sys/dev/disk/dm/targets/flakey/Makefile | 5 +
sys/dev/disk/dm/targets/flakey/dm_target_flakey.c | 411 +++++++++++++++++++++
8 files changed, 481 insertions(+), 15 deletions(-)
copy share/man/man4/{dm_target_delay.4 => dm_target_flakey.4} (50%)
create mode 100644 sys/dev/disk/dm/targets/flakey/Makefile
create mode 100644 sys/dev/disk/dm/targets/flakey/dm_target_flakey.c
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/b9790952d463c74d2706f84a3b2b5e035eb3059b
--
DragonFly BSD source repository
More information about the Commits
mailing list