Skip to content

Commit

Permalink
zloop testing by randomly assign vdevs as rotational.
Browse files Browse the repository at this point in the history
The random assignment is a dirty hack.  Reason for this is that it has
to be set before the device open finishes, or the rotor vector index
will be assigned on whatever initial nonrot value the device has.
  • Loading branch information
inkdot7 committed Jan 13, 2017
1 parent 02996a2 commit 8e765f6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/ztest/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,20 @@ make_vdev_root(char *path, char *aux, char *pool, size_t size, uint64_t ashift,
return (root);
}

boolean_t ztest_vdev_nonrot(void);

boolean_t
ztest_vdev_nonrot()
{
boolean_t nonrot;

nonrot = ztest_random(2) == 1 ? B_TRUE : B_FALSE;

printf("NONROT: %d\n", nonrot);

return (nonrot);
}

/*
* Find a random spa version. Returns back a random spa version in the
* range [initial_version, SPA_VERSION_FEATURES].
Expand Down Expand Up @@ -6541,6 +6555,14 @@ ztest_init(ztest_shared_t *zs)
VERIFY3U(0, ==, nvlist_add_uint64(props, buf, 0));
free(buf);
}
{
char *buf;
VERIFY3S(-1, !=, asprintf(&buf, "ssd<=meta:%d,%d;mixed<=%d;hdd",
32, 4, 64));
VERIFY3U(0, ==, nvlist_add_string(props,
ZPOOL_CONFIG_ROTORVECTOR, buf));
free(buf);
}
VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props, NULL));
nvlist_free(nvroot);
nvlist_free(props);
Expand Down
4 changes: 4 additions & 0 deletions module/zfs/metaslab.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,10 @@ metaslab_group_set_rotor_category(metaslab_group_t *mg, boolean_t failed_dev)
mg->mg_nrot = METASLAB_CLASS_ROTORS-1;
else
mg->mg_nrot = metaslab_vdev_rotor_category(mc, mg->mg_vd);

#ifndef _KERNEL
printf("SET mg->mg_nrot = %d\n", mg->mg_nrot);
#endif
}

void
Expand Down
15 changes: 15 additions & 0 deletions module/zfs/vdev_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ vdev_file_rele(vdev_t *vd)
ASSERT(vd->vdev_path != NULL);
}

#ifndef _KERNEL
boolean_t ztest_vdev_nonrot(void);

boolean_t
__attribute__((weak)) ztest_vdev_nonrot()
{
return (B_TRUE);
}
#endif

static int
vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
uint64_t *ashift)
Expand All @@ -60,9 +70,14 @@ vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
vattr_t vattr;
int error;

#ifdef _KERNEL
/* Rotational optimizations only make sense on block devices */
vd->vdev_nonrot = B_TRUE;
vd->vdev_nonrot_mix = B_FALSE;
#else
vd->vdev_nonrot = ztest_vdev_nonrot();
vd->vdev_nonrot_mix = B_FALSE;
#endif

/*
* We must have a pathname, and it must be absolute.
Expand Down

0 comments on commit 8e765f6

Please sign in to comment.