git://git.camperquake.de
/
zfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Disable ztest deadman timer
[zfs.git]
/
cmd
/
ztest
/
ztest.c
diff --git
a/cmd/ztest/ztest.c
b/cmd/ztest/ztest.c
index
9da15a1
..
7e941b5
100644
(file)
--- a/
cmd/ztest/ztest.c
+++ b/
cmd/ztest/ztest.c
@@
-121,8
+121,8
@@
#include <sys/fs/zfs.h>
#include <libnvpair.h>
#include <sys/fs/zfs.h>
#include <libnvpair.h>
-#define ZTEST_FD_DATA 3
-#define ZTEST_FD_RAND 4
+static int ztest_fd_data = -1;
+static int ztest_fd_rand = -1;
typedef struct ztest_shared_hdr {
uint64_t zh_hdr_size;
typedef struct ztest_shared_hdr {
uint64_t zh_hdr_size;
@@
-729,14
+729,17
@@
process_options(int argc, char **argv)
UINT64_MAX >> 2);
if (strlen(altdir) > 0) {
UINT64_MAX >> 2);
if (strlen(altdir) > 0) {
- char
cmd[MAXNAMELEN]
;
- char
realaltdir[MAXNAMELEN]
;
+ char
*cmd
;
+ char
*realaltdir
;
char *bin;
char *ztest;
char *isa;
int isalen;
char *bin;
char *ztest;
char *isa;
int isalen;
- (void) realpath(getexecname(), cmd);
+ cmd = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
+ realaltdir = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
+
+ VERIFY(NULL != realpath(getexecname(), cmd));
if (0 != access(altdir, F_OK)) {
ztest_dump_core = B_FALSE;
fatal(B_TRUE, "invalid alternate ztest path: %s",
if (0 != access(altdir, F_OK)) {
ztest_dump_core = B_FALSE;
fatal(B_TRUE, "invalid alternate ztest path: %s",
@@
-767,6
+770,9
@@
process_options(int argc, char **argv)
fatal(B_TRUE, "invalid alternate lib directory %s",
zo->zo_alt_libpath);
}
fatal(B_TRUE, "invalid alternate lib directory %s",
zo->zo_alt_libpath);
}
+
+ umem_free(cmd, MAXPATHLEN);
+ umem_free(realaltdir, MAXPATHLEN);
}
}
}
}
@@
-783,10
+789,12
@@
ztest_random(uint64_t range)
{
uint64_t r;
{
uint64_t r;
+ ASSERT3S(ztest_fd_rand, >=, 0);
+
if (range == 0)
return (0);
if (range == 0)
return (0);
- if (read(
ZTEST_FD_RAND
, &r, sizeof (r)) != sizeof (r))
+ if (read(
ztest_fd_rand
, &r, sizeof (r)) != sizeof (r))
fatal(1, "short read from /dev/urandom");
return (r % range);
fatal(1, "short read from /dev/urandom");
return (r % range);
@@
-5281,11
+5289,13
@@
ztest_resume_thread(void *arg)
#define GRACE 300
#define GRACE 300
+#if 0
static void
ztest_deadman_alarm(int sig)
{
fatal(0, "failed to complete within %d seconds of deadline", GRACE);
}
static void
ztest_deadman_alarm(int sig)
{
fatal(0, "failed to complete within %d seconds of deadline", GRACE);
}
+#endif
static void
ztest_execute(int test, ztest_info_t *zi, uint64_t id)
static void
ztest_execute(int test, ztest_info_t *zi, uint64_t id)
@@
-5542,11
+5552,13
@@
ztest_run(ztest_shared_t *zs)
(thread_func_t)ztest_resume_thread, spa, TS_RUN, NULL, 0, 0,
PTHREAD_CREATE_JOINABLE)), !=, NULL);
(thread_func_t)ztest_resume_thread, spa, TS_RUN, NULL, 0, 0,
PTHREAD_CREATE_JOINABLE)), !=, NULL);
+#if 0
/*
* Set a deadman alarm to abort() if we hang.
*/
signal(SIGALRM, ztest_deadman_alarm);
alarm((zs->zs_thread_stop - zs->zs_thread_start) / NANOSEC + GRACE);
/*
* Set a deadman alarm to abort() if we hang.
*/
signal(SIGALRM, ztest_deadman_alarm);
alarm((zs->zs_thread_stop - zs->zs_thread_start) / NANOSEC + GRACE);
+#endif
/*
* Verify that we can safely inquire about about any object,
/*
* Verify that we can safely inquire about about any object,
@@
-5815,26
+5827,13
@@
ztest_init(ztest_shared_t *zs)
}
static void
}
static void
-setup_
fds
(void)
+setup_
data_fd
(void)
{
{
- int fd;
-
- char *tmp = tempnam(NULL, NULL);
- fd = open(tmp, O_RDWR | O_CREAT, 0700);
- ASSERT3S(fd, >=, 0);
- if (fd != ZTEST_FD_DATA) {
- VERIFY3S(dup2(fd, ZTEST_FD_DATA), ==, ZTEST_FD_DATA);
- close(fd);
- }
- (void) unlink(tmp);
- free(tmp);
+ static char ztest_name_data[] = "/tmp/ztest.data.XXXXXX";
- fd = open("/dev/urandom", O_RDONLY);
- ASSERT3S(fd, >=, 0);
- if (fd != ZTEST_FD_RAND) {
- VERIFY3S(dup2(fd, ZTEST_FD_RAND), ==, ZTEST_FD_RAND);
- close(fd);
- }
+ ztest_fd_data = mkstemp(ztest_name_data);
+ ASSERT3S(ztest_fd_data, >=, 0);
+ (void) unlink(ztest_name_data);
}
static int
}
static int
@@
-5858,10
+5857,10
@@
setup_hdr(void)
ztest_shared_hdr_t *hdr;
hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
ztest_shared_hdr_t *hdr;
hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
- PROT_READ | PROT_WRITE, MAP_SHARED,
ZTEST_FD_DATA
, 0);
+ PROT_READ | PROT_WRITE, MAP_SHARED,
ztest_fd_data
, 0);
ASSERT(hdr != MAP_FAILED);
ASSERT(hdr != MAP_FAILED);
- VERIFY3U(0, ==, ftruncate(
ZTEST_FD_DATA
, sizeof (ztest_shared_hdr_t)));
+ VERIFY3U(0, ==, ftruncate(
ztest_fd_data
, sizeof (ztest_shared_hdr_t)));
hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t);
hdr->zh_opts_size = sizeof (ztest_shared_opts_t);
hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t);
hdr->zh_opts_size = sizeof (ztest_shared_opts_t);
@@
-5872,7
+5871,7
@@
setup_hdr(void)
hdr->zh_ds_count = ztest_opts.zo_datasets;
size = shared_data_size(hdr);
hdr->zh_ds_count = ztest_opts.zo_datasets;
size = shared_data_size(hdr);
- VERIFY3U(0, ==, ftruncate(
ZTEST_FD_DATA
, size));
+ VERIFY3U(0, ==, ftruncate(
ztest_fd_data
, size));
(void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
}
(void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
}
@@
-5885,14
+5884,14
@@
setup_data(void)
uint8_t *buf;
hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
uint8_t *buf;
hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
- PROT_READ, MAP_SHARED,
ZTEST_FD_DATA
, 0);
+ PROT_READ, MAP_SHARED,
ztest_fd_data
, 0);
ASSERT(hdr != MAP_FAILED);
size = shared_data_size(hdr);
(void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()),
ASSERT(hdr != MAP_FAILED);
size = shared_data_size(hdr);
(void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()),
- PROT_READ | PROT_WRITE, MAP_SHARED,
ZTEST_FD_DATA
, 0);
+ PROT_READ | PROT_WRITE, MAP_SHARED,
ztest_fd_data
, 0);
ASSERT(hdr != MAP_FAILED);
buf = (uint8_t *)hdr;
ASSERT(hdr != MAP_FAILED);
buf = (uint8_t *)hdr;
@@
-5911,12
+5910,13
@@
exec_child(char *cmd, char *libpath, boolean_t ignorekill, int *statusp)
{
pid_t pid;
int status;
{
pid_t pid;
int status;
- char
cmdbuf[MAXPATHLEN]
;
+ char
*cmdbuf = NULL
;
pid = fork();
if (cmd == NULL) {
pid = fork();
if (cmd == NULL) {
- (void) strlcpy(cmdbuf, getexecname(), sizeof (cmdbuf));
+ cmdbuf = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
+ (void) strlcpy(cmdbuf, getexecname(), MAXPATHLEN);
cmd = cmdbuf;
}
cmd = cmdbuf;
}
@@
-5925,9
+5925,15
@@
exec_child(char *cmd, char *libpath, boolean_t ignorekill, int *statusp)
if (pid == 0) { /* child */
char *emptyargv[2] = { cmd, NULL };
if (pid == 0) { /* child */
char *emptyargv[2] = { cmd, NULL };
+ char fd_data_str[12];
struct rlimit rl = { 1024, 1024 };
(void) setrlimit(RLIMIT_NOFILE, &rl);
struct rlimit rl = { 1024, 1024 };
(void) setrlimit(RLIMIT_NOFILE, &rl);
+
+ (void) close(ztest_fd_rand);
+ VERIFY(11 >= snprintf(fd_data_str, 12, "%d", ztest_fd_data));
+ VERIFY(0 == setenv("ZTEST_FD_DATA", fd_data_str, 1));
+
(void) enable_extended_FILE_stdio(-1, -1);
if (libpath != NULL)
VERIFY(0 == setenv("LD_LIBRARY_PATH", libpath, 1));
(void) enable_extended_FILE_stdio(-1, -1);
if (libpath != NULL)
VERIFY(0 == setenv("LD_LIBRARY_PATH", libpath, 1));
@@
-5936,6
+5942,11
@@
exec_child(char *cmd, char *libpath, boolean_t ignorekill, int *statusp)
fatal(B_TRUE, "exec failed: %s", cmd);
}
fatal(B_TRUE, "exec failed: %s", cmd);
}
+ if (cmdbuf != NULL) {
+ umem_free(cmdbuf, MAXPATHLEN);
+ cmd = NULL;
+ }
+
while (waitpid(pid, &status, 0) != pid)
continue;
if (statusp != NULL)
while (waitpid(pid, &status, 0) != pid)
continue;
if (statusp != NULL)
@@
-6002,39
+6013,41
@@
main(int argc, char **argv)
char timebuf[100];
char numbuf[6];
spa_t *spa;
char timebuf[100];
char numbuf[6];
spa_t *spa;
- char
cmd[MAXNAMELEN]
;
+ char
*cmd
;
boolean_t hasalt;
int f;
boolean_t hasalt;
int f;
- boolean_t ischild = (0 == lseek(ZTEST_FD_DATA, 0, SEEK_CUR));
-
- ASSERT(ischild || errno == EBADF || errno == ESPIPE);
+ char *fd_data_str = getenv("ZTEST_FD_DATA");
(void) setvbuf(stdout, NULL, _IOLBF, 0);
(void) setvbuf(stdout, NULL, _IOLBF, 0);
- if (!ischild) {
+ ztest_fd_rand = open("/dev/urandom", O_RDONLY);
+ ASSERT3S(ztest_fd_rand, >=, 0);
+
+ if (!fd_data_str) {
dprintf_setup(&argc, argv);
process_options(argc, argv);
dprintf_setup(&argc, argv);
process_options(argc, argv);
- setup_
fds
();
+ setup_
data_fd
();
setup_hdr();
setup_data();
bcopy(&ztest_opts, ztest_shared_opts,
sizeof (*ztest_shared_opts));
} else {
setup_hdr();
setup_data();
bcopy(&ztest_opts, ztest_shared_opts,
sizeof (*ztest_shared_opts));
} else {
+ ztest_fd_data = atoi(fd_data_str);
setup_data();
bcopy(ztest_shared_opts, &ztest_opts, sizeof (ztest_opts));
}
ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count);
/* Override location of zpool.cache */
setup_data();
bcopy(ztest_shared_opts, &ztest_opts, sizeof (ztest_opts));
}
ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count);
/* Override location of zpool.cache */
-
(void)
asprintf((char **)&spa_config_path, "%s/zpool.cache",
- ztest_opts.zo_dir);
-
+
VERIFY(
asprintf((char **)&spa_config_path, "%s/zpool.cache",
+ ztest_opts.zo_dir)
!= -1)
;
+
ztest_ds = umem_alloc(ztest_opts.zo_datasets * sizeof (ztest_ds_t),
UMEM_NOFAIL);
zs = ztest_shared;
ztest_ds = umem_alloc(ztest_opts.zo_datasets * sizeof (ztest_ds_t),
UMEM_NOFAIL);
zs = ztest_shared;
- if (
ischild
) {
+ if (
fd_data_str
) {
metaslab_gang_bang = ztest_opts.zo_metaslab_gang_bang;
metaslab_df_alloc_threshold =
zs->zs_metaslab_df_alloc_threshold;
metaslab_gang_bang = ztest_opts.zo_metaslab_gang_bang;
metaslab_df_alloc_threshold =
zs->zs_metaslab_df_alloc_threshold;
@@
-6057,7
+6070,8
@@
main(int argc, char **argv)
(u_longlong_t)ztest_opts.zo_time);
}
(u_longlong_t)ztest_opts.zo_time);
}
- (void) strlcpy(cmd, getexecname(), sizeof (cmd));
+ cmd = umem_alloc(MAXNAMELEN, UMEM_NOFAIL);
+ (void) strlcpy(cmd, getexecname(), MAXNAMELEN);
zs->zs_do_init = B_TRUE;
if (strlen(ztest_opts.zo_alt_ztest) != 0) {
zs->zs_do_init = B_TRUE;
if (strlen(ztest_opts.zo_alt_ztest) != 0) {
@@
-6198,5
+6212,7
@@
main(int argc, char **argv)
kills, iters - kills, (100.0 * kills) / MAX(1, iters));
}
kills, iters - kills, (100.0 * kills) / MAX(1, iters));
}
+ umem_free(cmd, MAXNAMELEN);
+
return (0);
}
return (0);
}