Skip to content

Commit

Permalink
Ztest device removal and fault injection are mu...
Browse files Browse the repository at this point in the history
...tually exclusive

To work around the problem in which device evacuation will copy from
the corrupted side of a mirror, add the -e option to ztest to enable
device removal.  When it's enabled, fault injection is disabled.

Zloop.sh will now randomly enable device evacuation when there are no
raidz vdevs.

NOTE: This is a hack and is being implemented to allow additional
testing of full patch set.

Signed-off-by: Tim Chase <tim@chase2k.com>
  • Loading branch information
dweeezil committed Mar 4, 2018
1 parent a6de073 commit 88b143f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/ztest/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ typedef struct ztest_shared_opts {
uint64_t zo_maxloops;
uint64_t zo_metaslab_gang_bang;
int zo_mmp_test;
int zo_device_removal;
} ztest_shared_opts_t;

static const ztest_shared_opts_t ztest_opts_defaults = {
Expand All @@ -192,7 +193,8 @@ static const ztest_shared_opts_t ztest_opts_defaults = {
.zo_init = 1,
.zo_time = 300, /* 5 minutes */
.zo_maxloops = 50, /* max loops during spa_freeze() */
.zo_metaslab_gang_bang = 32 << 10
.zo_metaslab_gang_bang = 32 << 10,
.zo_device_removal = 0
};

extern uint64_t metaslab_gang_bang;
Expand Down Expand Up @@ -700,7 +702,7 @@ process_options(int argc, char **argv)
bcopy(&ztest_opts_defaults, zo, sizeof (*zo));

while ((opt = getopt(argc, argv,
"v:s:a:m:r:R:d:t:g:i:k:p:f:MVET:P:hF:B:o:G")) != EOF) {
"ev:s:a:m:r:R:d:t:g:i:k:p:f:MVET:P:hF:B:o:G")) != EOF) {
value = 0;
switch (opt) {
case 'v':
Expand Down Expand Up @@ -729,6 +731,9 @@ process_options(int argc, char **argv)
case 'a':
zo->zo_ashift = value;
break;
case 'e':
zo->zo_device_removal = 1;
break;
case 'm':
zo->zo_mirrors = value;
break;
Expand Down Expand Up @@ -3376,6 +3381,9 @@ ztest_device_removal(ztest_ds_t *zd, uint64_t id)
vdev_t *vd;
uint64_t guid;

if (ztest_opts.zo_device_removal == 0)
return;

mutex_enter(&ztest_vdev_lock);

spa_config_enter(spa, SCL_VDEV, FTAG, RW_READER);
Expand Down Expand Up @@ -5516,6 +5524,9 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
uint64_t guid0 = 0;
boolean_t islog = B_FALSE;

if (ztest_opts.zo_device_removal == 1)
return;

path0 = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
pathrand = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);

Expand Down
5 changes: 5 additions & 0 deletions scripts/zloop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ while [[ $timeout -eq 0 ]] || [[ $curtime -le $((starttime + timeout)) ]]; do
zopt="$zopt -s $size"
zopt="$zopt -f $workdir"

# Enable device removal 50% of the time when there's no raidz
if [[ $raidz -eq 0 ]] && [[ $((RANDOM % 2)) -eq 0 ]]; then
zopt="$zopt -e"
fi

# shellcheck disable=SC2124
cmd="$ZTEST $zopt $@"
desc="$(date '+%m/%d %T') $cmd"
Expand Down

0 comments on commit 88b143f

Please sign in to comment.