Permalink
Browse files
fstests: add dm-log-writes test and supporting code
This patch adds the supporting code for using the dm-log-writes target. The bash stuff is similar to the dmflakey code, it just gives us functions to build and tear down a dm-log-writes target. We add a new LOGWRITES_DEV variable to take in the device we will use as the log and add checks for that. I've rigged up fsx to have an integrity check mode. Basically it works like it normally works, but when it fsync()'s it marks the log with a unique mark and dumps it's buffer to a file with the mark in the filename. I did this with a system() call simply because it was the fastest. I can link the device-mapper libraries and do it programatically if that would be preferred, but this works pretty well. The test itself just runs 200 ops and exits, then finds all of the good buffers in the directory we provided and replays up to the mark given, mounts the file system and compares the md5sum, unmounts and fsck's to check for metadata integrity. dm-log-writes will pretend to do discard and the replay tool will replay it properly depending on the underlying device, either by writing 0's or actually calling the discard ioctl, so I've enabled discard in the test for maximum fun. This test relies on the supporting userspace code I've written for dm-logs-writes. It can be found here https://github.com/josefbacik/log-writes.git Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com>
- Loading branch information
Showing
with
374 additions
and 19 deletions.
- +2 −0 README
- +1 −0 common/config
- +80 −0 common/dmlogwrites
- +46 −0 common/rc
- +112 −19 ltp/fsx.c
- +130 −0 tests/generic/326
- +2 −0 tests/generic/326.out
- +1 −0 tests/generic/group
| @@ -0,0 +1,80 @@ | ||
| ##/bin/bash | ||
| # | ||
| # Copyright (c) 2015 Facebook, Inc. All Rights Reserved. | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License as | ||
| # published by the Free Software Foundation. | ||
| # | ||
| # This program is distributed in the hope that it would be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write the Free Software Foundation, | ||
| # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| # | ||
| # | ||
| # common functions for setting up and tearing down a dm log-writes device | ||
|
|
||
| _init_log_writes() | ||
| { | ||
| local BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV` | ||
| LOGWRITES_NAME=logwrites-test | ||
| LOGWRITES_DMDEV=/dev/mapper/$LOGWRITES_NAME | ||
| LOGWRITES_TABLE="0 $BLK_DEV_SIZE log-writes $SCRATCH_DEV $LOGWRITES_DEV" | ||
| $DMSETUP_PROG create $LOGWRITES_NAME --table "$LOGWRITES_TABLE" || \ | ||
| _fatal "failed to create log-writes device" | ||
| $DMSETUP_PROG mknodes > /dev/null 2>&1 | ||
| } | ||
|
|
||
| _log_writes_mark() | ||
| { | ||
| [ $# -ne 1 ] && _fatal "_log_writes_mark takes one argument" | ||
| $DMSETUP_PROG message $LOGWRITES_NAME 0 mark $1 | ||
| } | ||
|
|
||
| _log_writes_mkfs() | ||
| { | ||
| _scratch_options mkfs | ||
| _mkfs_dev $SCRATCH_OPTIONS $LOGWRITES_DMDEV | ||
| _log_writes_mark mkfs | ||
| } | ||
|
|
||
| _mount_log_writes() | ||
| { | ||
| mount -t $FSTYP $MOUNT_OPTIONS $* $LOGWRITES_DMDEV $SCRATCH_MNT | ||
| } | ||
|
|
||
| _unmount_log_writes() | ||
| { | ||
| $UMOUNT_PROG $SCRATCH_MNT | ||
| } | ||
|
|
||
| # _replay_log <mark> | ||
| # | ||
| # This replays the log contained on $INTEGRITY_DEV onto $SCRATCH_DEV upto the | ||
| # mark passed in. | ||
| _replay_log() | ||
| { | ||
| _mark=$1 | ||
|
|
||
| $REPLAYLOG_PROG --log $LOGWRITES_DEV --replay $SCRATCH_DEV \ | ||
| --end-mark $_mark > /dev/null 2>&1 | ||
| [ $? -ne 0 ] && _fatal "replay failed" | ||
| } | ||
|
|
||
| _log_writes_remove() | ||
| { | ||
| $DMSETUP_PROG remove $LOGWRITES_NAME > /dev/null 2>&1 | ||
| $DMSETUP_PROG mknodes > /dev/null 2>&1 | ||
| } | ||
|
|
||
| _cleanup_log_writes() | ||
| { | ||
| # If dmsetup load fails then we need to make sure to do resume here | ||
| # otherwise the umount will hang | ||
| $UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1 | ||
| _log_writes_remove | ||
| } |
Oops, something went wrong.