Prune /*NOTREACHED*/

This includes a simplification of mkbusy and format correctness in zhack
and ztest

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Issue #12201
This commit is contained in:
наб 2021-06-05 14:18:37 +02:00 committed by Brian Behlendorf
parent 5dbf6c5a66
commit 90f1c3c946
11 changed files with 246 additions and 257 deletions

View File

@ -414,10 +414,9 @@ get_usage(zfs_help_t idx)
return (gettext("\tunjail <jailid|jailname> <filesystem>\n")); return (gettext("\tunjail <jailid|jailname> <filesystem>\n"));
case HELP_WAIT: case HELP_WAIT:
return (gettext("\twait [-t <activity>] <filesystem>\n")); return (gettext("\twait [-t <activity>] <filesystem>\n"));
default:
__builtin_unreachable();
} }
abort();
/* NOTREACHED */
} }
void void

View File

@ -36,7 +36,7 @@
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
static void static __attribute__((noreturn)) void
usage(void) usage(void)
{ {
(void) fprintf(stderr, (void) fprintf(stderr,
@ -51,7 +51,6 @@ usage(void)
" will be generated.\n" " will be generated.\n"
"The value must be unique among your systems.\n"); "The value must be unique among your systems.\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* NOTREACHED */
} }
int int

View File

@ -56,7 +56,7 @@ static importargs_t g_importargs;
static char *g_pool; static char *g_pool;
static boolean_t g_readonly; static boolean_t g_readonly;
static void static __attribute__((noreturn)) void
usage(void) usage(void)
{ {
(void) fprintf(stderr, (void) fprintf(stderr,
@ -81,7 +81,7 @@ usage(void)
} }
static void static __attribute__((noreturn)) __attribute__((format(printf, 3, 4))) void
fatal(spa_t *spa, void *tag, const char *fmt, ...) fatal(spa_t *spa, void *tag, const char *fmt, ...)
{ {
va_list ap; va_list ap;
@ -112,7 +112,6 @@ space_delta_cb(dmu_object_type_t bonustype, const void *data,
return (ENOENT); return (ENOENT);
(void) fprintf(stderr, "modifying object that needs user accounting"); (void) fprintf(stderr, "modifying object that needs user accounting");
abort(); abort();
/* NOTREACHED */
} }
/* /*
@ -318,7 +317,8 @@ zhack_do_feature_enable(int argc, char **argv)
mos = spa->spa_meta_objset; mos = spa->spa_meta_objset;
if (zfeature_is_supported(feature.fi_guid)) if (zfeature_is_supported(feature.fi_guid))
fatal(spa, FTAG, "'%s' is a real feature, will not enable"); fatal(spa, FTAG, "'%s' is a real feature, will not enable",
feature.fi_guid);
if (0 == zap_contains(mos, spa->spa_feat_desc_obj, feature.fi_guid)) if (0 == zap_contains(mos, spa->spa_feat_desc_obj, feature.fi_guid))
fatal(spa, FTAG, "feature already enabled: %s", fatal(spa, FTAG, "feature already enabled: %s",
feature.fi_guid); feature.fi_guid);
@ -412,7 +412,8 @@ zhack_do_feature_ref(int argc, char **argv)
if (zfeature_is_supported(feature.fi_guid)) { if (zfeature_is_supported(feature.fi_guid)) {
fatal(spa, FTAG, fatal(spa, FTAG,
"'%s' is a real feature, will not change refcount"); "'%s' is a real feature, will not change refcount",
feature.fi_guid);
} }
if (0 == zap_contains(mos, spa->spa_feat_for_read_obj, if (0 == zap_contains(mos, spa->spa_feat_for_read_obj,

View File

@ -429,10 +429,9 @@ get_usage(zpool_help_t idx)
case HELP_WAIT: case HELP_WAIT:
return (gettext("\twait [-Hp] [-T d|u] [-t <activity>[,...]] " return (gettext("\twait [-Hp] [-T d|u] [-t <activity>[,...]] "
"<pool> [interval]\n")); "<pool> [interval]\n"));
default:
__builtin_unreachable();
} }
abort();
/* NOTREACHED */
} }
static void static void

View File

@ -622,7 +622,7 @@ static void sig_handler(int signo)
char *fatal_msg; char *fatal_msg;
static void static __attribute__((noreturn)) __attribute__((format(printf, 2, 3))) void
fatal(int do_perror, char *message, ...) fatal(int do_perror, char *message, ...)
{ {
va_list args; va_list args;
@ -674,7 +674,6 @@ str2shift(const char *buf)
} }
(void) fprintf(stderr, "ztest: invalid bytes suffix: %s\n", buf); (void) fprintf(stderr, "ztest: invalid bytes suffix: %s\n", buf);
usage(B_FALSE); usage(B_FALSE);
/* NOTREACHED */
} }
static uint64_t static uint64_t
@ -875,7 +874,7 @@ ztest_random(uint64_t range)
return (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"); fatal(B_TRUE, "short read from /dev/urandom");
return (r % range); return (r % range);
} }
@ -1210,9 +1209,8 @@ ztest_is_draid_spare(const char *name)
{ {
uint64_t spare_id = 0, parity = 0, vdev_id = 0; uint64_t spare_id = 0, parity = 0, vdev_id = 0;
if (sscanf(name, VDEV_TYPE_DRAID "%llu-%llu-%llu", if (sscanf(name, VDEV_TYPE_DRAID "%"PRIu64"-%"PRIu64"-%"PRIu64"",
(u_longlong_t *)&parity, (u_longlong_t *)&vdev_id, &parity, &vdev_id, &spare_id) == 3) {
(u_longlong_t *)&spare_id) == 3) {
return (B_TRUE); return (B_TRUE);
} }
@ -1254,9 +1252,9 @@ make_vdev_file(char *path, char *aux, char *pool, size_t size, uint64_t ashift)
if (size != 0 && !draid_spare) { if (size != 0 && !draid_spare) {
int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666); int fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (fd == -1) if (fd == -1)
fatal(1, "can't open %s", path); fatal(B_TRUE, "can't open %s", path);
if (ftruncate(fd, size) != 0) if (ftruncate(fd, size) != 0)
fatal(1, "can't ftruncate %s", path); fatal(B_TRUE, "can't ftruncate %s", path);
(void) close(fd); (void) close(fd);
} }
@ -2841,8 +2839,9 @@ ztest_od_init(ztest_od_t *od, uint64_t id, char *tag, uint64_t index,
od->od_blocksize = 0; od->od_blocksize = 0;
od->od_gen = 0; od->od_gen = 0;
(void) snprintf(od->od_name, sizeof (od->od_name), "%s(%lld)[%llu]", (void) snprintf(od->od_name, sizeof (od->od_name),
tag, (longlong_t)id, (u_longlong_t)index); "%s(%"PRId64")[%"PRIu64"]",
tag, id, index);
} }
/* /*
@ -2985,7 +2984,7 @@ ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id)
VERIFY0(spa_open(zo->zo_pool, &spa, FTAG)); VERIFY0(spa_open(zo->zo_pool, &spa, FTAG));
int error = spa_destroy(zo->zo_pool); int error = spa_destroy(zo->zo_pool);
if (error != EBUSY && error != ZFS_ERR_EXPORT_IN_PROGRESS) { if (error != EBUSY && error != ZFS_ERR_EXPORT_IN_PROGRESS) {
fatal(0, "spa_destroy(%s) returned unexpected value %d", fatal(B_FALSE, "spa_destroy(%s) returned unexpected value %d",
spa->spa_name, error); spa->spa_name, error);
} }
spa_close(spa, FTAG); spa_close(spa, FTAG);
@ -3108,8 +3107,9 @@ ztest_spa_upgrade(ztest_ds_t *zd, uint64_t id)
newversion = ztest_random_spa_version(version + 1); newversion = ztest_random_spa_version(version + 1);
if (ztest_opts.zo_verbose >= 4) { if (ztest_opts.zo_verbose >= 4) {
(void) printf("upgrading spa version from %llu to %llu\n", (void) printf("upgrading spa version from "
(u_longlong_t)version, (u_longlong_t)newversion); "%"PRIu64" to %"PRIu64"\n",
version, newversion);
} }
spa_upgrade(spa, newversion); spa_upgrade(spa, newversion);
@ -3139,7 +3139,7 @@ ztest_spa_checkpoint(spa_t *spa)
ztest_record_enospc(FTAG); ztest_record_enospc(FTAG);
break; break;
default: default:
fatal(0, "spa_checkpoint(%s) = %d", spa->spa_name, error); fatal(B_FALSE, "spa_checkpoint(%s) = %d", spa->spa_name, error);
} }
} }
@ -3156,7 +3156,7 @@ ztest_spa_discard_checkpoint(spa_t *spa)
case ZFS_ERR_NO_CHECKPOINT: case ZFS_ERR_NO_CHECKPOINT:
break; break;
default: default:
fatal(0, "spa_discard_checkpoint(%s) = %d", fatal(B_FALSE, "spa_discard_checkpoint(%s) = %d",
spa->spa_name, error); spa->spa_name, error);
} }
@ -3266,7 +3266,7 @@ ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id)
case ZFS_ERR_DISCARDING_CHECKPOINT: case ZFS_ERR_DISCARDING_CHECKPOINT:
break; break;
default: default:
fatal(0, "spa_vdev_remove() = %d", error); fatal(B_FALSE, "spa_vdev_remove() = %d", error);
} }
} else { } else {
spa_config_exit(spa, SCL_VDEV, FTAG); spa_config_exit(spa, SCL_VDEV, FTAG);
@ -3289,7 +3289,7 @@ ztest_vdev_add_remove(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc("spa_vdev_add"); ztest_record_enospc("spa_vdev_add");
break; break;
default: default:
fatal(0, "spa_vdev_add() = %d", error); fatal(B_FALSE, "spa_vdev_add() = %d", error);
} }
} }
@ -3347,7 +3347,7 @@ ztest_vdev_class_add(ztest_ds_t *zd, uint64_t id)
if (error == ENOSPC) if (error == ENOSPC)
ztest_record_enospc("spa_vdev_add"); ztest_record_enospc("spa_vdev_add");
else if (error != 0) else if (error != 0)
fatal(0, "spa_vdev_add() = %d", error); fatal(B_FALSE, "spa_vdev_add() = %d", error);
/* /*
* 50% of the time allow small blocks in the special class * 50% of the time allow small blocks in the special class
@ -3453,7 +3453,7 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id)
case 0: case 0:
break; break;
default: default:
fatal(0, "spa_vdev_add(%p) = %d", nvroot, error); fatal(B_FALSE, "spa_vdev_add(%p) = %d", nvroot, error);
} }
fnvlist_free(nvroot); fnvlist_free(nvroot);
} else { } else {
@ -3475,8 +3475,9 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id)
break; break;
default: default:
if (error != ignore_err) if (error != ignore_err)
fatal(0, "spa_vdev_remove(%llu) = %d", guid, fatal(B_FALSE,
error); "spa_vdev_remove(%"PRIu64") = %d",
guid, error);
} }
} }
@ -3698,7 +3699,8 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
if (error != 0 && error != ENODEV && error != EBUSY && if (error != 0 && error != ENODEV && error != EBUSY &&
error != ENOTSUP && error != ZFS_ERR_CHECKPOINT_EXISTS && error != ENOTSUP && error != ZFS_ERR_CHECKPOINT_EXISTS &&
error != ZFS_ERR_DISCARDING_CHECKPOINT) error != ZFS_ERR_DISCARDING_CHECKPOINT)
fatal(0, "detach (%s) returned %d", oldpath, error); fatal(B_FALSE, "detach (%s) returned %d",
oldpath, error);
goto out; goto out;
} }
@ -3813,7 +3815,7 @@ ztest_vdev_attach_detach(ztest_ds_t *zd, uint64_t id)
expected_error = error; expected_error = error;
if (error != expected_error && expected_error != EBUSY) { if (error != expected_error && expected_error != EBUSY) {
fatal(0, "attach (%s %llu, %s %llu, %d) " fatal(B_FALSE, "attach (%s %"PRIu64", %s %"PRIu64", %d) "
"returned %d, expected %d", "returned %d, expected %d",
oldpath, oldsize, newpath, oldpath, oldsize, newpath,
newsize, replacing, error, expected_error); newsize, replacing, error, expected_error);
@ -3944,8 +3946,8 @@ online_vdev(vdev_t *vd, void *arg)
*/ */
if (error || newstate != VDEV_STATE_HEALTHY) { if (error || newstate != VDEV_STATE_HEALTHY) {
if (ztest_opts.zo_verbose >= 5) { if (ztest_opts.zo_verbose >= 5) {
(void) printf("Unable to expand vdev, state %llu, " (void) printf("Unable to expand vdev, state %u, "
"error %d\n", (u_longlong_t)newstate, error); "error %d\n", newstate, error);
} }
return (vd); return (vd);
} }
@ -3960,12 +3962,12 @@ online_vdev(vdev_t *vd, void *arg)
if (generation != spa->spa_config_generation) { if (generation != spa->spa_config_generation) {
if (ztest_opts.zo_verbose >= 5) { if (ztest_opts.zo_verbose >= 5) {
(void) printf("vdev configuration has changed, " (void) printf("vdev configuration has changed, "
"guid %llu, state %llu, expected gen %llu, " "guid %"PRIu64", state %"PRIu64", "
"got gen %llu\n", "expected gen %"PRIu64", got gen %"PRIu64"\n",
(u_longlong_t)guid, guid,
(u_longlong_t)tvd->vdev_state, tvd->vdev_state,
(u_longlong_t)generation, generation,
(u_longlong_t)spa->spa_config_generation); spa->spa_config_generation);
} }
return (vd); return (vd);
} }
@ -4126,7 +4128,8 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
* Make sure we were able to grow the vdev. * Make sure we were able to grow the vdev.
*/ */
if (new_ms_count <= old_ms_count) { if (new_ms_count <= old_ms_count) {
fatal(0, "LUN expansion failed: ms_count %llu < %llu\n", fatal(B_FALSE,
"LUN expansion failed: ms_count %"PRIu64" < %"PRIu64"\n",
old_ms_count, new_ms_count); old_ms_count, new_ms_count);
} }
@ -4134,7 +4137,8 @@ ztest_vdev_LUN_growth(ztest_ds_t *zd, uint64_t id)
* Make sure we were able to grow the pool. * Make sure we were able to grow the pool.
*/ */
if (new_class_space <= old_class_space) { if (new_class_space <= old_class_space) {
fatal(0, "LUN expansion failed: class_space %llu < %llu\n", fatal(B_FALSE,
"LUN expansion failed: class_space %"PRIu64" < %"PRIu64"\n",
old_class_space, new_class_space); old_class_space, new_class_space);
} }
@ -4281,7 +4285,7 @@ ztest_snapshot_create(char *osname, uint64_t id)
char snapname[ZFS_MAX_DATASET_NAME_LEN]; char snapname[ZFS_MAX_DATASET_NAME_LEN];
int error; int error;
(void) snprintf(snapname, sizeof (snapname), "%llu", (u_longlong_t)id); (void) snprintf(snapname, sizeof (snapname), "%"PRIu64"", id);
error = dmu_objset_snapshot_one(osname, snapname); error = dmu_objset_snapshot_one(osname, snapname);
if (error == ENOSPC) { if (error == ENOSPC) {
@ -4289,7 +4293,7 @@ ztest_snapshot_create(char *osname, uint64_t id)
return (B_FALSE); return (B_FALSE);
} }
if (error != 0 && error != EEXIST) { if (error != 0 && error != EEXIST) {
fatal(0, "ztest_snapshot_create(%s@%s) = %d", osname, fatal(B_FALSE, "ztest_snapshot_create(%s@%s) = %d", osname,
snapname, error); snapname, error);
} }
return (B_TRUE); return (B_TRUE);
@ -4301,12 +4305,13 @@ ztest_snapshot_destroy(char *osname, uint64_t id)
char snapname[ZFS_MAX_DATASET_NAME_LEN]; char snapname[ZFS_MAX_DATASET_NAME_LEN];
int error; int error;
(void) snprintf(snapname, sizeof (snapname), "%s@%llu", osname, (void) snprintf(snapname, sizeof (snapname), "%s@%"PRIu64"",
(u_longlong_t)id); osname, id);
error = dsl_destroy_snapshot(snapname, B_FALSE); error = dsl_destroy_snapshot(snapname, B_FALSE);
if (error != 0 && error != ENOENT) if (error != 0 && error != ENOENT)
fatal(0, "ztest_snapshot_destroy(%s) = %d", snapname, error); fatal(B_FALSE, "ztest_snapshot_destroy(%s) = %d",
snapname, error);
return (B_TRUE); return (B_TRUE);
} }
@ -4326,8 +4331,8 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id)
(void) pthread_rwlock_rdlock(&ztest_name_lock); (void) pthread_rwlock_rdlock(&ztest_name_lock);
(void) snprintf(name, sizeof (name), "%s/temp_%llu", (void) snprintf(name, sizeof (name), "%s/temp_%"PRIu64"",
ztest_opts.zo_pool, (u_longlong_t)id); ztest_opts.zo_pool, id);
/* /*
* If this dataset exists from a previous run, process its replay log * If this dataset exists from a previous run, process its replay log
@ -4366,7 +4371,7 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc(FTAG); ztest_record_enospc(FTAG);
goto out; goto out;
} }
fatal(0, "dmu_objset_create(%s) = %d", name, error); fatal(B_FALSE, "dmu_objset_create(%s) = %d", name, error);
} }
VERIFY0(ztest_dmu_objset_own(name, DMU_OST_OTHER, B_FALSE, B_TRUE, VERIFY0(ztest_dmu_objset_own(name, DMU_OST_OTHER, B_FALSE, B_TRUE,
@ -4448,32 +4453,35 @@ ztest_dsl_dataset_cleanup(char *osname, uint64_t id)
clone2name = umem_alloc(ZFS_MAX_DATASET_NAME_LEN, UMEM_NOFAIL); clone2name = umem_alloc(ZFS_MAX_DATASET_NAME_LEN, UMEM_NOFAIL);
snap3name = umem_alloc(ZFS_MAX_DATASET_NAME_LEN, UMEM_NOFAIL); snap3name = umem_alloc(ZFS_MAX_DATASET_NAME_LEN, UMEM_NOFAIL);
(void) snprintf(snap1name, ZFS_MAX_DATASET_NAME_LEN, (void) snprintf(snap1name, ZFS_MAX_DATASET_NAME_LEN, "%s@s1_%"PRIu64"",
"%s@s1_%llu", osname, (u_longlong_t)id); osname, id);
(void) snprintf(clone1name, ZFS_MAX_DATASET_NAME_LEN, (void) snprintf(clone1name, ZFS_MAX_DATASET_NAME_LEN, "%s/c1_%"PRIu64"",
"%s/c1_%llu", osname, (u_longlong_t)id); osname, id);
(void) snprintf(snap2name, ZFS_MAX_DATASET_NAME_LEN, (void) snprintf(snap2name, ZFS_MAX_DATASET_NAME_LEN, "%s@s2_%"PRIu64"",
"%s@s2_%llu", clone1name, (u_longlong_t)id); clone1name, id);
(void) snprintf(clone2name, ZFS_MAX_DATASET_NAME_LEN, (void) snprintf(clone2name, ZFS_MAX_DATASET_NAME_LEN, "%s/c2_%"PRIu64"",
"%s/c2_%llu", osname, (u_longlong_t)id); osname, id);
(void) snprintf(snap3name, ZFS_MAX_DATASET_NAME_LEN, (void) snprintf(snap3name, ZFS_MAX_DATASET_NAME_LEN, "%s@s3_%"PRIu64"",
"%s@s3_%llu", clone1name, (u_longlong_t)id); clone1name, id);
error = dsl_destroy_head(clone2name); error = dsl_destroy_head(clone2name);
if (error && error != ENOENT) if (error && error != ENOENT)
fatal(0, "dsl_destroy_head(%s) = %d", clone2name, error); fatal(B_FALSE, "dsl_destroy_head(%s) = %d", clone2name, error);
error = dsl_destroy_snapshot(snap3name, B_FALSE); error = dsl_destroy_snapshot(snap3name, B_FALSE);
if (error && error != ENOENT) if (error && error != ENOENT)
fatal(0, "dsl_destroy_snapshot(%s) = %d", snap3name, error); fatal(B_FALSE, "dsl_destroy_snapshot(%s) = %d",
snap3name, error);
error = dsl_destroy_snapshot(snap2name, B_FALSE); error = dsl_destroy_snapshot(snap2name, B_FALSE);
if (error && error != ENOENT) if (error && error != ENOENT)
fatal(0, "dsl_destroy_snapshot(%s) = %d", snap2name, error); fatal(B_FALSE, "dsl_destroy_snapshot(%s) = %d",
snap2name, error);
error = dsl_destroy_head(clone1name); error = dsl_destroy_head(clone1name);
if (error && error != ENOENT) if (error && error != ENOENT)
fatal(0, "dsl_destroy_head(%s) = %d", clone1name, error); fatal(B_FALSE, "dsl_destroy_head(%s) = %d", clone1name, error);
error = dsl_destroy_snapshot(snap1name, B_FALSE); error = dsl_destroy_snapshot(snap1name, B_FALSE);
if (error && error != ENOENT) if (error && error != ENOENT)
fatal(0, "dsl_destroy_snapshot(%s) = %d", snap1name, error); fatal(B_FALSE, "dsl_destroy_snapshot(%s) = %d",
snap1name, error);
umem_free(snap1name, ZFS_MAX_DATASET_NAME_LEN); umem_free(snap1name, ZFS_MAX_DATASET_NAME_LEN);
umem_free(clone1name, ZFS_MAX_DATASET_NAME_LEN); umem_free(clone1name, ZFS_MAX_DATASET_NAME_LEN);
@ -4507,16 +4515,16 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
ztest_dsl_dataset_cleanup(osname, id); ztest_dsl_dataset_cleanup(osname, id);
(void) snprintf(snap1name, ZFS_MAX_DATASET_NAME_LEN, (void) snprintf(snap1name, ZFS_MAX_DATASET_NAME_LEN, "%s@s1_%"PRIu64"",
"%s@s1_%llu", osname, (u_longlong_t)id); osname, id);
(void) snprintf(clone1name, ZFS_MAX_DATASET_NAME_LEN, (void) snprintf(clone1name, ZFS_MAX_DATASET_NAME_LEN, "%s/c1_%"PRIu64"",
"%s/c1_%llu", osname, (u_longlong_t)id); osname, id);
(void) snprintf(snap2name, ZFS_MAX_DATASET_NAME_LEN, (void) snprintf(snap2name, ZFS_MAX_DATASET_NAME_LEN, "%s@s2_%"PRIu64"",
"%s@s2_%llu", clone1name, (u_longlong_t)id); clone1name, id);
(void) snprintf(clone2name, ZFS_MAX_DATASET_NAME_LEN, (void) snprintf(clone2name, ZFS_MAX_DATASET_NAME_LEN, "%s/c2_%"PRIu64"",
"%s/c2_%llu", osname, (u_longlong_t)id); osname, id);
(void) snprintf(snap3name, ZFS_MAX_DATASET_NAME_LEN, (void) snprintf(snap3name, ZFS_MAX_DATASET_NAME_LEN, "%s@s3_%"PRIu64"",
"%s@s3_%llu", clone1name, (u_longlong_t)id); clone1name, id);
error = dmu_objset_snapshot_one(osname, strchr(snap1name, '@') + 1); error = dmu_objset_snapshot_one(osname, strchr(snap1name, '@') + 1);
if (error && error != EEXIST) { if (error && error != EEXIST) {
@ -4524,7 +4532,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc(FTAG); ztest_record_enospc(FTAG);
goto out; goto out;
} }
fatal(0, "dmu_take_snapshot(%s) = %d", snap1name, error); fatal(B_FALSE, "dmu_take_snapshot(%s) = %d", snap1name, error);
} }
error = dmu_objset_clone(clone1name, snap1name); error = dmu_objset_clone(clone1name, snap1name);
@ -4533,7 +4541,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc(FTAG); ztest_record_enospc(FTAG);
goto out; goto out;
} }
fatal(0, "dmu_objset_create(%s) = %d", clone1name, error); fatal(B_FALSE, "dmu_objset_create(%s) = %d", clone1name, error);
} }
error = dmu_objset_snapshot_one(clone1name, strchr(snap2name, '@') + 1); error = dmu_objset_snapshot_one(clone1name, strchr(snap2name, '@') + 1);
@ -4542,7 +4550,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc(FTAG); ztest_record_enospc(FTAG);
goto out; goto out;
} }
fatal(0, "dmu_open_snapshot(%s) = %d", snap2name, error); fatal(B_FALSE, "dmu_open_snapshot(%s) = %d", snap2name, error);
} }
error = dmu_objset_snapshot_one(clone1name, strchr(snap3name, '@') + 1); error = dmu_objset_snapshot_one(clone1name, strchr(snap3name, '@') + 1);
@ -4551,7 +4559,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc(FTAG); ztest_record_enospc(FTAG);
goto out; goto out;
} }
fatal(0, "dmu_open_snapshot(%s) = %d", snap3name, error); fatal(B_FALSE, "dmu_open_snapshot(%s) = %d", snap3name, error);
} }
error = dmu_objset_clone(clone2name, snap3name); error = dmu_objset_clone(clone2name, snap3name);
@ -4560,13 +4568,13 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc(FTAG); ztest_record_enospc(FTAG);
goto out; goto out;
} }
fatal(0, "dmu_objset_create(%s) = %d", clone2name, error); fatal(B_FALSE, "dmu_objset_create(%s) = %d", clone2name, error);
} }
error = ztest_dmu_objset_own(snap2name, DMU_OST_ANY, B_TRUE, B_TRUE, error = ztest_dmu_objset_own(snap2name, DMU_OST_ANY, B_TRUE, B_TRUE,
FTAG, &os); FTAG, &os);
if (error) if (error)
fatal(0, "dmu_objset_own(%s) = %d", snap2name, error); fatal(B_FALSE, "dmu_objset_own(%s) = %d", snap2name, error);
error = dsl_dataset_promote(clone2name, NULL); error = dsl_dataset_promote(clone2name, NULL);
if (error == ENOSPC) { if (error == ENOSPC) {
dmu_objset_disown(os, B_TRUE, FTAG); dmu_objset_disown(os, B_TRUE, FTAG);
@ -4574,8 +4582,8 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
goto out; goto out;
} }
if (error != EBUSY) if (error != EBUSY)
fatal(0, "dsl_dataset_promote(%s), %d, not EBUSY", clone2name, fatal(B_FALSE, "dsl_dataset_promote(%s), %d, not EBUSY",
error); clone2name, error);
dmu_objset_disown(os, B_TRUE, FTAG); dmu_objset_disown(os, B_TRUE, FTAG);
out: out:
@ -4662,8 +4670,8 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
size = sizeof (ztest_od_t) * OD_ARRAY_SIZE; size = sizeof (ztest_od_t) * OD_ARRAY_SIZE;
od = umem_alloc(size, UMEM_NOFAIL); od = umem_alloc(size, UMEM_NOFAIL);
dmu_tx_t *tx; dmu_tx_t *tx;
int i, freeit, error; int freeit, error;
uint64_t n, s, txg; uint64_t i, n, s, txg;
bufwad_t *packbuf, *bigbuf, *pack, *bigH, *bigT; bufwad_t *packbuf, *bigbuf, *pack, *bigH, *bigT;
uint64_t packobj, packoff, packsize, bigobj, bigoff, bigsize; uint64_t packobj, packoff, packsize, bigobj, bigoff, bigsize;
uint64_t chunksize = (1000 + ztest_random(1000)) * sizeof (uint64_t); uint64_t chunksize = (1000 + ztest_random(1000)) * sizeof (uint64_t);
@ -4810,18 +4818,22 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
ASSERT3U((uintptr_t)bigT - (uintptr_t)bigbuf, <, bigsize); ASSERT3U((uintptr_t)bigT - (uintptr_t)bigbuf, <, bigsize);
if (pack->bw_txg > txg) if (pack->bw_txg > txg)
fatal(0, "future leak: got %llx, open txg is %llx", fatal(B_FALSE,
"future leak: got %"PRIx64", open txg is %"PRIx64"",
pack->bw_txg, txg); pack->bw_txg, txg);
if (pack->bw_data != 0 && pack->bw_index != n + i) if (pack->bw_data != 0 && pack->bw_index != n + i)
fatal(0, "wrong index: got %llx, wanted %llx+%llx", fatal(B_FALSE, "wrong index: "
"got %"PRIx64", wanted %"PRIx64"+%"PRIx64"",
pack->bw_index, n, i); pack->bw_index, n, i);
if (bcmp(pack, bigH, sizeof (bufwad_t)) != 0) if (bcmp(pack, bigH, sizeof (bufwad_t)) != 0)
fatal(0, "pack/bigH mismatch in %p/%p", pack, bigH); fatal(B_FALSE, "pack/bigH mismatch in %p/%p",
pack, bigH);
if (bcmp(pack, bigT, sizeof (bufwad_t)) != 0) if (bcmp(pack, bigT, sizeof (bufwad_t)) != 0)
fatal(0, "pack/bigT mismatch in %p/%p", pack, bigT); fatal(B_FALSE, "pack/bigT mismatch in %p/%p",
pack, bigT);
if (freeit) { if (freeit) {
bzero(pack, sizeof (bufwad_t)); bzero(pack, sizeof (bufwad_t));
@ -4842,20 +4854,16 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
if (freeit) { if (freeit) {
if (ztest_opts.zo_verbose >= 7) { if (ztest_opts.zo_verbose >= 7) {
(void) printf("freeing offset %llx size %llx" (void) printf("freeing offset %"PRIx64" size %"PRIx64""
" txg %llx\n", " txg %"PRIx64"\n",
(u_longlong_t)bigoff, bigoff, bigsize, txg);
(u_longlong_t)bigsize,
(u_longlong_t)txg);
} }
VERIFY0(dmu_free_range(os, bigobj, bigoff, bigsize, tx)); VERIFY0(dmu_free_range(os, bigobj, bigoff, bigsize, tx));
} else { } else {
if (ztest_opts.zo_verbose >= 7) { if (ztest_opts.zo_verbose >= 7) {
(void) printf("writing offset %llx size %llx" (void) printf("writing offset %"PRIx64" size %"PRIx64""
" txg %llx\n", " txg %"PRIx64"\n",
(u_longlong_t)bigoff, bigoff, bigsize, txg);
(u_longlong_t)bigsize,
(u_longlong_t)txg);
} }
dmu_write(os, bigobj, bigoff, bigsize, bigbuf, tx); dmu_write(os, bigobj, bigoff, bigsize, bigbuf, tx);
} }
@ -4913,18 +4921,22 @@ compare_and_update_pbbufs(uint64_t s, bufwad_t *packbuf, bufwad_t *bigbuf,
ASSERT3U((uintptr_t)bigT - (uintptr_t)bigbuf, <, bigsize); ASSERT3U((uintptr_t)bigT - (uintptr_t)bigbuf, <, bigsize);
if (pack->bw_txg > txg) if (pack->bw_txg > txg)
fatal(0, "future leak: got %llx, open txg is %llx", fatal(B_FALSE,
"future leak: got %"PRIx64", open txg is %"PRIx64"",
pack->bw_txg, txg); pack->bw_txg, txg);
if (pack->bw_data != 0 && pack->bw_index != n + i) if (pack->bw_data != 0 && pack->bw_index != n + i)
fatal(0, "wrong index: got %llx, wanted %llx+%llx", fatal(B_FALSE, "wrong index: "
"got %"PRIx64", wanted %"PRIx64"+%"PRIx64"",
pack->bw_index, n, i); pack->bw_index, n, i);
if (bcmp(pack, bigH, sizeof (bufwad_t)) != 0) if (bcmp(pack, bigH, sizeof (bufwad_t)) != 0)
fatal(0, "pack/bigH mismatch in %p/%p", pack, bigH); fatal(B_FALSE, "pack/bigH mismatch in %p/%p",
pack, bigH);
if (bcmp(pack, bigT, sizeof (bufwad_t)) != 0) if (bcmp(pack, bigT, sizeof (bufwad_t)) != 0)
fatal(0, "pack/bigT mismatch in %p/%p", pack, bigT); fatal(B_FALSE, "pack/bigT mismatch in %p/%p",
pack, bigT);
pack->bw_index = n + i; pack->bw_index = n + i;
pack->bw_txg = txg; pack->bw_txg = txg;
@ -5103,11 +5115,9 @@ ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id)
*/ */
dmu_write(os, packobj, packoff, packsize, packbuf, tx); dmu_write(os, packobj, packoff, packsize, packbuf, tx);
if (ztest_opts.zo_verbose >= 7) { if (ztest_opts.zo_verbose >= 7) {
(void) printf("writing offset %llx size %llx" (void) printf("writing offset %"PRIx64" size %"PRIx64""
" txg %llx\n", " txg %"PRIx64"\n",
(u_longlong_t)bigoff, bigoff, bigsize, txg);
(u_longlong_t)bigsize,
(u_longlong_t)txg);
} }
for (off = bigoff, j = 0; j < s; j++, off += chunksize) { for (off = bigoff, j = 0; j < s; j++, off += chunksize) {
dmu_buf_t *dbt; dmu_buf_t *dbt;
@ -5308,8 +5318,8 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
ints = MAX(ZTEST_ZAP_MIN_INTS, object % ZTEST_ZAP_MAX_INTS); ints = MAX(ZTEST_ZAP_MIN_INTS, object % ZTEST_ZAP_MAX_INTS);
prop = ztest_random(ZTEST_ZAP_MAX_PROPS); prop = ztest_random(ZTEST_ZAP_MAX_PROPS);
(void) sprintf(propname, "prop_%llu", (u_longlong_t)prop); (void) sprintf(propname, "prop_%"PRIu64"", prop);
(void) sprintf(txgname, "txg_%llu", (u_longlong_t)prop); (void) sprintf(txgname, "txg_%"PRIu64"", prop);
bzero(value, sizeof (value)); bzero(value, sizeof (value));
last_txg = 0; last_txg = 0;
@ -5354,7 +5364,8 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
goto out; goto out;
if (last_txg > txg) if (last_txg > txg)
fatal(0, "zap future leak: old %llu new %llu", last_txg, txg); fatal(B_FALSE, "zap future leak: old %"PRIu64" new %"PRIu64"",
last_txg, txg);
for (i = 0; i < ints; i++) for (i = 0; i < ints; i++)
value[i] = txg + object + i; value[i] = txg + object + i;
@ -5370,8 +5381,8 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
* Remove a random pair of entries. * Remove a random pair of entries.
*/ */
prop = ztest_random(ZTEST_ZAP_MAX_PROPS); prop = ztest_random(ZTEST_ZAP_MAX_PROPS);
(void) sprintf(propname, "prop_%llu", (u_longlong_t)prop); (void) sprintf(propname, "prop_%"PRIu64"", prop);
(void) sprintf(txgname, "txg_%llu", (u_longlong_t)prop); (void) sprintf(txgname, "txg_%"PRIu64"", prop);
error = zap_length(os, object, txgname, &zl_intsize, &zl_ints); error = zap_length(os, object, txgname, &zl_intsize, &zl_ints);
@ -5400,8 +5411,7 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id)
{ {
objset_t *os = zd->zd_os; objset_t *os = zd->zd_os;
ztest_od_t *od; ztest_od_t *od;
uint64_t object, txg; uint64_t object, txg, value;
int i;
od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL); od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0, 0); ztest_od_init(od, id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0, 0);
@ -5416,14 +5426,13 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id)
* and gets upgraded to a fatzap. Also, since we are adding * and gets upgraded to a fatzap. Also, since we are adding
* 2050 entries we should see ptrtbl growth and leaf-block split. * 2050 entries we should see ptrtbl growth and leaf-block split.
*/ */
for (i = 0; i < 2050; i++) { for (value = 0; value < 2050; value++) {
char name[ZFS_MAX_DATASET_NAME_LEN]; char name[ZFS_MAX_DATASET_NAME_LEN];
uint64_t value = i;
dmu_tx_t *tx; dmu_tx_t *tx;
int error; int error;
(void) snprintf(name, sizeof (name), "fzap-%llu-%llu", (void) snprintf(name, sizeof (name), "fzap-%"PRIu64"-%"PRIu64"",
(u_longlong_t)id, (u_longlong_t)value); id, value);
tx = dmu_tx_create(os); tx = dmu_tx_create(os);
dmu_tx_hold_zap(tx, object, B_TRUE, name); dmu_tx_hold_zap(tx, object, B_TRUE, name);
@ -5527,8 +5536,8 @@ ztest_zap_parallel(ztest_ds_t *zd, uint64_t id)
if (error == 0) { if (error == 0) {
if (data == string_value && if (data == string_value &&
bcmp(name, data, namelen) != 0) bcmp(name, data, namelen) != 0)
fatal(0, "name '%s' != val '%s' len %d", fatal(B_FALSE, "name '%s' != val '%s' len %d",
name, data, namelen); name, (char *)data, namelen);
} else { } else {
ASSERT3U(error, ==, ENOENT); ASSERT3U(error, ==, ENOENT);
} }
@ -5580,9 +5589,10 @@ ztest_commit_callback(void *arg, int error)
synced_txg = spa_last_synced_txg(data->zcd_spa); synced_txg = spa_last_synced_txg(data->zcd_spa);
if (data->zcd_txg > synced_txg) if (data->zcd_txg > synced_txg)
fatal(0, "commit callback of txg %" PRIu64 " called prematurely" fatal(B_FALSE,
", last synced txg = %" PRIu64 "\n", data->zcd_txg, "commit callback of txg %"PRIu64" called prematurely, "
synced_txg); "last synced txg = %"PRIu64"\n",
data->zcd_txg, synced_txg);
data->zcd_called = B_TRUE; data->zcd_called = B_TRUE;
@ -5704,7 +5714,8 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id)
&old_txg, DMU_READ_PREFETCH)); &old_txg, DMU_READ_PREFETCH));
if (old_txg > txg) if (old_txg > txg)
fatal(0, "future leak: got %" PRIu64 ", open txg is %" PRIu64, fatal(B_FALSE,
"future leak: got %"PRIu64", open txg is %"PRIu64"",
old_txg, txg); old_txg, txg);
dmu_write(os, od->od_object, 0, sizeof (uint64_t), &txg, tx); dmu_write(os, od->od_object, 0, sizeof (uint64_t), &txg, tx);
@ -5726,8 +5737,10 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id)
tmp_cb = list_head(&zcl.zcl_callbacks); tmp_cb = list_head(&zcl.zcl_callbacks);
if (tmp_cb != NULL && if (tmp_cb != NULL &&
tmp_cb->zcd_txg + ZTEST_COMMIT_CB_THRESH < txg) { tmp_cb->zcd_txg + ZTEST_COMMIT_CB_THRESH < txg) {
fatal(0, "Commit callback threshold exceeded, oldest txg: %" fatal(B_FALSE,
PRIu64 ", open txg: %" PRIu64 "\n", tmp_cb->zcd_txg, txg); "Commit callback threshold exceeded, "
"oldest txg: %"PRIu64", open txg: %"PRIu64"\n",
tmp_cb->zcd_txg, txg);
} }
/* /*
@ -5885,12 +5898,11 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
dmu_objset_name(os, osname); dmu_objset_name(os, osname);
(void) snprintf(snapname, sizeof (snapname), "sh1_%llu", (void) snprintf(snapname, sizeof (snapname), "sh1_%"PRIu64"", id);
(u_longlong_t)id);
(void) snprintf(fullname, sizeof (fullname), "%s@%s", osname, snapname); (void) snprintf(fullname, sizeof (fullname), "%s@%s", osname, snapname);
(void) snprintf(clonename, sizeof (clonename), (void) snprintf(clonename, sizeof (clonename), "%s/ch1_%"PRIu64"",
"%s/ch1_%llu", osname, (u_longlong_t)id); osname, id);
(void) snprintf(tag, sizeof (tag), "tag_%llu", (u_longlong_t)id); (void) snprintf(tag, sizeof (tag), "tag_%"PRIu64"", id);
/* /*
* Clean up from any previous run. * Clean up from any previous run.
@ -5915,7 +5927,7 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc("dmu_objset_snapshot"); ztest_record_enospc("dmu_objset_snapshot");
goto out; goto out;
} }
fatal(0, "dmu_objset_snapshot(%s) = %d", fullname, error); fatal(B_FALSE, "dmu_objset_snapshot(%s) = %d", fullname, error);
} }
error = dmu_objset_clone(clonename, fullname); error = dmu_objset_clone(clonename, fullname);
@ -5924,22 +5936,22 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc("dmu_objset_clone"); ztest_record_enospc("dmu_objset_clone");
goto out; goto out;
} }
fatal(0, "dmu_objset_clone(%s) = %d", clonename, error); fatal(B_FALSE, "dmu_objset_clone(%s) = %d", clonename, error);
} }
error = dsl_destroy_snapshot(fullname, B_TRUE); error = dsl_destroy_snapshot(fullname, B_TRUE);
if (error) { if (error) {
fatal(0, "dsl_destroy_snapshot(%s, B_TRUE) = %d", fatal(B_FALSE, "dsl_destroy_snapshot(%s, B_TRUE) = %d",
fullname, error); fullname, error);
} }
error = dsl_destroy_head(clonename); error = dsl_destroy_head(clonename);
if (error) if (error)
fatal(0, "dsl_destroy_head(%s) = %d", clonename, error); fatal(B_FALSE, "dsl_destroy_head(%s) = %d", clonename, error);
error = dmu_objset_hold(fullname, FTAG, &origin); error = dmu_objset_hold(fullname, FTAG, &origin);
if (error != ENOENT) if (error != ENOENT)
fatal(0, "dmu_objset_hold(%s) = %d", fullname, error); fatal(B_FALSE, "dmu_objset_hold(%s) = %d", fullname, error);
/* /*
* Create snapshot, add temporary hold, verify that we can't * Create snapshot, add temporary hold, verify that we can't
@ -5952,7 +5964,7 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc("dmu_objset_snapshot"); ztest_record_enospc("dmu_objset_snapshot");
goto out; goto out;
} }
fatal(0, "dmu_objset_snapshot(%s) = %d", fullname, error); fatal(B_FALSE, "dmu_objset_snapshot(%s) = %d", fullname, error);
} }
holds = fnvlist_alloc(); holds = fnvlist_alloc();
@ -5964,25 +5976,26 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
ztest_record_enospc("dsl_dataset_user_hold"); ztest_record_enospc("dsl_dataset_user_hold");
goto out; goto out;
} else if (error) { } else if (error) {
fatal(0, "dsl_dataset_user_hold(%s, %s) = %u", fatal(B_FALSE, "dsl_dataset_user_hold(%s, %s) = %u",
fullname, tag, error); fullname, tag, error);
} }
error = dsl_destroy_snapshot(fullname, B_FALSE); error = dsl_destroy_snapshot(fullname, B_FALSE);
if (error != EBUSY) { if (error != EBUSY) {
fatal(0, "dsl_destroy_snapshot(%s, B_FALSE) = %d", fatal(B_FALSE, "dsl_destroy_snapshot(%s, B_FALSE) = %d",
fullname, error); fullname, error);
} }
error = dsl_destroy_snapshot(fullname, B_TRUE); error = dsl_destroy_snapshot(fullname, B_TRUE);
if (error) { if (error) {
fatal(0, "dsl_destroy_snapshot(%s, B_TRUE) = %d", fatal(B_FALSE, "dsl_destroy_snapshot(%s, B_TRUE) = %d",
fullname, error); fullname, error);
} }
error = user_release_one(fullname, tag); error = user_release_one(fullname, tag);
if (error) if (error)
fatal(0, "user_release_one(%s, %s) = %d", fullname, tag, error); fatal(B_FALSE, "user_release_one(%s, %s) = %d",
fullname, tag, error);
VERIFY3U(dmu_objset_hold(fullname, FTAG, &origin), ==, ENOENT); VERIFY3U(dmu_objset_hold(fullname, FTAG, &origin), ==, ENOENT);
@ -6263,14 +6276,15 @@ ztest_fault_inject(ztest_ds_t *zd, uint64_t id)
} }
if (pwrite(fd, &bad, sizeof (bad), offset) != sizeof (bad)) if (pwrite(fd, &bad, sizeof (bad), offset) != sizeof (bad))
fatal(1, "can't inject bad word at 0x%llx in %s", fatal(B_TRUE,
"can't inject bad word at 0x%"PRIx64" in %s",
offset, pathrand); offset, pathrand);
mutex_exit(&ztest_vdev_lock); mutex_exit(&ztest_vdev_lock);
if (ztest_opts.zo_verbose >= 7) if (ztest_opts.zo_verbose >= 7)
(void) printf("injected bad word into %s," (void) printf("injected bad word into %s,"
" offset 0x%llx\n", pathrand, (u_longlong_t)offset); " offset 0x%"PRIx64"\n", pathrand, offset);
} }
(void) close(fd); (void) close(fd);
@ -6358,8 +6372,8 @@ ztest_reguid(ztest_ds_t *zd, uint64_t id)
return; return;
if (ztest_opts.zo_verbose >= 4) { if (ztest_opts.zo_verbose >= 4) {
(void) printf("Changed guid old %llu -> %llu\n", (void) printf("Changed guid old %"PRIu64" -> %"PRIu64"\n",
(u_longlong_t)orig, (u_longlong_t)spa_guid(spa)); orig, spa_guid(spa));
} }
VERIFY3U(orig, !=, spa_guid(spa)); VERIFY3U(orig, !=, spa_guid(spa));
@ -6600,7 +6614,7 @@ ztest_get_zdb_bin(char *bin, int len)
strlcpy(bin, zdb_path, len); /* In env */ strlcpy(bin, zdb_path, len); /* In env */
if (!ztest_check_path(bin)) { if (!ztest_check_path(bin)) {
ztest_dump_core = 0; ztest_dump_core = 0;
fatal(1, "invalid ZDB_PATH '%s'", bin); fatal(B_TRUE, "invalid ZDB_PATH '%s'", bin);
} }
return; return;
} }
@ -6840,9 +6854,10 @@ ztest_run_zdb(char *pool)
ztest_dump_core = 0; ztest_dump_core = 0;
if (WIFEXITED(status)) if (WIFEXITED(status))
fatal(0, "'%s' exit code %d", zdb, WEXITSTATUS(status)); fatal(B_FALSE, "'%s' exit code %d", zdb, WEXITSTATUS(status));
else else
fatal(0, "'%s' died with signal %d", zdb, WTERMSIG(status)); fatal(B_FALSE, "'%s' died with signal %d",
zdb, WTERMSIG(status));
out: out:
umem_free(bin, len); umem_free(bin, len);
umem_free(zdb, len); umem_free(zdb, len);
@ -7013,7 +7028,8 @@ ztest_deadman_thread(void *arg)
* I/Os then it will end up aborting the tests. * I/Os then it will end up aborting the tests.
*/ */
if (spa_suspended(spa) || spa->spa_root_vdev == NULL) { if (spa_suspended(spa) || spa->spa_root_vdev == NULL) {
fatal(0, "aborting test after %llu seconds because " fatal(B_FALSE,
"aborting test after %lu seconds because "
"pool has transitioned to a suspended state.", "pool has transitioned to a suspended state.",
zfs_deadman_synctime_ms / 1000); zfs_deadman_synctime_ms / 1000);
} }
@ -7026,7 +7042,8 @@ ztest_deadman_thread(void *arg)
*/ */
overdue = zs->zs_proc_stop + MSEC2NSEC(zfs_deadman_synctime_ms); overdue = zs->zs_proc_stop + MSEC2NSEC(zfs_deadman_synctime_ms);
if (gethrtime() > overdue) { if (gethrtime() > overdue) {
fatal(0, "aborting test after %llu seconds because " fatal(B_FALSE,
"aborting test after %llu seconds because "
"the process is overdue for termination.", "the process is overdue for termination.",
(gethrtime() - zs->zs_proc_start) / NANOSEC); (gethrtime() - zs->zs_proc_start) / NANOSEC);
} }
@ -7187,7 +7204,8 @@ ztest_dataset_open(int d)
if (zilog->zl_header->zh_claim_lr_seq != 0 && if (zilog->zl_header->zh_claim_lr_seq != 0 &&
zilog->zl_header->zh_claim_lr_seq < committed_seq) zilog->zl_header->zh_claim_lr_seq < committed_seq)
fatal(0, "missing log records: claimed %llu < committed %llu", fatal(B_FALSE, "missing log records: "
"claimed %"PRIu64" < committed %"PRIu64"",
zilog->zl_header->zh_claim_lr_seq, committed_seq); zilog->zl_header->zh_claim_lr_seq, committed_seq);
ztest_dataset_dirobj_verify(zd); ztest_dataset_dirobj_verify(zd);
@ -7197,17 +7215,19 @@ ztest_dataset_open(int d)
ztest_dataset_dirobj_verify(zd); ztest_dataset_dirobj_verify(zd);
if (ztest_opts.zo_verbose >= 6) if (ztest_opts.zo_verbose >= 6)
(void) printf("%s replay %llu blocks, %llu records, seq %llu\n", (void) printf("%s replay %"PRIu64" blocks, "
"%"PRIu64" records, seq %"PRIu64"\n",
zd->zd_name, zd->zd_name,
(u_longlong_t)zilog->zl_parse_blk_count, zilog->zl_parse_blk_count,
(u_longlong_t)zilog->zl_parse_lr_count, zilog->zl_parse_lr_count,
(u_longlong_t)zilog->zl_replaying_seq); zilog->zl_replaying_seq);
zilog = zil_open(os, ztest_get_data); zilog = zil_open(os, ztest_get_data);
if (zilog->zl_replaying_seq != 0 && if (zilog->zl_replaying_seq != 0 &&
zilog->zl_replaying_seq < committed_seq) zilog->zl_replaying_seq < committed_seq)
fatal(0, "missing log records: replayed %llu < committed %llu", fatal(B_FALSE, "missing log records: "
"replayed %"PRIu64" < committed %"PRIu64"",
zilog->zl_replaying_seq, committed_seq); zilog->zl_replaying_seq, committed_seq);
return (0); return (0);
@ -7244,11 +7264,12 @@ ztest_replay_zil_cb(const char *name, void *arg)
ztest_opts.zo_verbose >= 6) { ztest_opts.zo_verbose >= 6) {
zilog_t *zilog = dmu_objset_zil(os); zilog_t *zilog = dmu_objset_zil(os);
(void) printf("%s replay %llu blocks, %llu records, seq %llu\n", (void) printf("%s replay %"PRIu64" blocks, "
"%"PRIu64" records, seq %"PRIu64"\n",
name, name,
(u_longlong_t)zilog->zl_parse_blk_count, zilog->zl_parse_blk_count,
(u_longlong_t)zilog->zl_parse_lr_count, zilog->zl_parse_lr_count,
(u_longlong_t)zilog->zl_replaying_seq); zilog->zl_replaying_seq);
} }
umem_free(zdtmp, sizeof (ztest_ds_t)); umem_free(zdtmp, sizeof (ztest_ds_t));
@ -7845,7 +7866,7 @@ exec_child(char *cmd, char *libpath, boolean_t ignorekill, int *statusp)
} }
if (pid == -1) if (pid == -1)
fatal(1, "fork failed"); fatal(B_TRUE, "fork failed");
if (pid == 0) { /* child */ if (pid == 0) { /* child */
char *emptyargv[2] = { cmd, NULL }; char *emptyargv[2] = { cmd, NULL };
@ -7894,7 +7915,6 @@ exec_child(char *cmd, char *libpath, boolean_t ignorekill, int *statusp)
} else { } else {
(void) fprintf(stderr, "something strange happened to child\n"); (void) fprintf(stderr, "something strange happened to child\n");
exit(4); exit(4);
/* NOTREACHED */
} }
} }
@ -8044,14 +8064,14 @@ main(int argc, char **argv)
hasalt = (strlen(ztest_opts.zo_alt_ztest) != 0); hasalt = (strlen(ztest_opts.zo_alt_ztest) != 0);
if (ztest_opts.zo_verbose >= 1) { if (ztest_opts.zo_verbose >= 1) {
(void) printf("%llu vdevs, %d datasets, %d threads," (void) printf("%"PRIu64" vdevs, %d datasets, %d threads,"
"%d %s disks, %llu seconds...\n\n", "%d %s disks, %"PRIu64" seconds...\n\n",
(u_longlong_t)ztest_opts.zo_vdevs, ztest_opts.zo_vdevs,
ztest_opts.zo_datasets, ztest_opts.zo_datasets,
ztest_opts.zo_threads, ztest_opts.zo_threads,
ztest_opts.zo_raid_children, ztest_opts.zo_raid_children,
ztest_opts.zo_raid_type, ztest_opts.zo_raid_type,
(u_longlong_t)ztest_opts.zo_time); ztest_opts.zo_time);
} }
cmd = umem_alloc(MAXNAMELEN, UMEM_NOFAIL); cmd = umem_alloc(MAXNAMELEN, UMEM_NOFAIL);
@ -8133,11 +8153,11 @@ main(int argc, char **argv)
print_time(zs->zs_proc_stop - now, timebuf); print_time(zs->zs_proc_stop - now, timebuf);
nicenum(zs->zs_space, numbuf, sizeof (numbuf)); nicenum(zs->zs_space, numbuf, sizeof (numbuf));
(void) printf("Pass %3d, %8s, %3llu ENOSPC, " (void) printf("Pass %3d, %8s, %3"PRIu64" ENOSPC, "
"%4.1f%% of %5s used, %3.0f%% done, %8s to go\n", "%4.1f%% of %5s used, %3.0f%% done, %8s to go\n",
iters, iters,
WIFEXITED(status) ? "Complete" : "SIGKILL", WIFEXITED(status) ? "Complete" : "SIGKILL",
(u_longlong_t)zs->zs_enospc_count, zs->zs_enospc_count,
100.0 * zs->zs_alloc / zs->zs_space, 100.0 * zs->zs_alloc / zs->zs_space,
numbuf, numbuf,
100.0 * (now - zs->zs_proc_start) / 100.0 * (now - zs->zs_proc_start) /
@ -8154,8 +8174,8 @@ main(int argc, char **argv)
zi = &ztest_info[f]; zi = &ztest_info[f];
zc = ZTEST_GET_SHARED_CALLSTATE(f); zc = ZTEST_GET_SHARED_CALLSTATE(f);
print_time(zc->zc_time, timebuf); print_time(zc->zc_time, timebuf);
(void) printf("%7llu %9s %s\n", (void) printf("%7"PRIu64" %9s %s\n",
(u_longlong_t)zc->zc_count, timebuf, zc->zc_count, timebuf,
zi->zi_funcname); zi->zi_funcname);
} }
(void) printf("\n"); (void) printf("\n");

View File

@ -1084,7 +1084,7 @@ zfsctl_snapdir_readdir(struct vop_readdir_args *ap)
} }
zfs_uio_setoffset(&uio, cookie + dots_offset); zfs_uio_setoffset(&uio, cookie + dots_offset);
} }
/* NOTREACHED */ __builtin_unreachable();
} }
static int static int

View File

@ -79,7 +79,6 @@ zfs_log_create_txtype(zil_create_t type, vsecattr_t *vsecp, vattr_t *vap)
return (TX_CREATE_ACL); return (TX_CREATE_ACL);
else else
return (TX_CREATE_ATTR); return (TX_CREATE_ATTR);
/*NOTREACHED*/
case Z_DIR: case Z_DIR:
if (vsecp == NULL && !isxvattr) if (vsecp == NULL && !isxvattr)
return (TX_MKDIR); return (TX_MKDIR);

View File

@ -4,3 +4,5 @@ pkgexecdir = $(datadir)/@PACKAGE@/zfs-tests/bin
pkgexec_PROGRAMS = mkbusy pkgexec_PROGRAMS = mkbusy
mkbusy_SOURCES = mkbusy.c mkbusy_SOURCES = mkbusy.c
mkbusy_LDADD = $(abs_top_builddir)/lib/libzfs_core/libzfs_core.la

View File

@ -29,19 +29,21 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <libzutil.h>
static void
static __attribute__((noreturn)) void
usage(char *progname) usage(char *progname)
{ {
(void) fprintf(stderr, "Usage: %s <dirname|filename>\n", progname); (void) fprintf(stderr, "Usage: %s <dirname|filename>\n", progname);
exit(1); exit(1);
} }
static void static __attribute__((noreturn)) void
fail(char *err, int rval) fail(char *err)
{ {
perror(err); perror(err);
exit(rval); exit(1);
} }
static void static void
@ -50,7 +52,7 @@ daemonize(void)
pid_t pid; pid_t pid;
if ((pid = fork()) < 0) { if ((pid = fork()) < 0) {
fail("fork", 1); fail("fork");
} else if (pid != 0) { } else if (pid != 0) {
(void) fprintf(stdout, "%ld\n", (long)pid); (void) fprintf(stdout, "%ld\n", (long)pid);
exit(0); exit(0);
@ -65,24 +67,14 @@ daemonize(void)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int ret, c; int c;
boolean_t isdir = B_FALSE; boolean_t isdir = B_FALSE;
boolean_t fflag = B_FALSE;
boolean_t rflag = B_FALSE;
struct stat sbuf; struct stat sbuf;
char *fpath = NULL; char *fpath = NULL;
char *prog = argv[0]; char *prog = argv[0];
while ((c = getopt(argc, argv, "fr")) != -1) { while ((c = getopt(argc, argv, "")) != -1) {
switch (c) { switch (c) {
/* Open the file or directory read only */
case 'r':
rflag = B_TRUE;
break;
/* Run in the foreground */
case 'f':
fflag = B_TRUE;
break;
default: default:
usage(prog); usage(prog);
} }
@ -94,84 +86,68 @@ main(int argc, char *argv[])
if (argc != 1) if (argc != 1)
usage(prog); usage(prog);
if ((ret = stat(argv[0], &sbuf)) != 0) { if (stat(argv[0], &sbuf) != 0) {
char *arg, *dname, *fname; char *arg;
int arglen; const char *dname, *fname;
char *slash; size_t arglen;
int rc; ssize_t dnamelen;
/* /*
* The argument supplied doesn't exist. Copy the path, and * The argument supplied doesn't exist. Copy the path, and
* remove the trailing slash if present. * remove the trailing slash if present.
*/ */
if ((arg = strdup(argv[0])) == NULL) if ((arg = strdup(argv[0])) == NULL)
fail("strdup", 1); fail("strdup");
arglen = strlen(arg); arglen = strlen(arg);
if (arg[arglen - 1] == '/') if (arg[arglen - 1] == '/')
arg[arglen - 1] = '\0'; arg[arglen - 1] = '\0';
/* /* Get the directory and file names. */
* Get the directory and file names, using the current directory fname = zfs_basename(arg);
* if the provided path doesn't specify a directory at all. dname = arg;
*/ if ((dnamelen = zfs_dirnamelen(arg)) != -1)
if ((slash = strrchr(arg, '/')) == NULL) { arg[dnamelen] = '\0';
dname = strdup("."); else
fname = strdup(arg); dname = ".";
} else {
*slash = '\0';
dname = strdup(arg);
fname = strdup(slash + 1);
}
free(arg);
if (dname == NULL || fname == NULL)
fail("strdup", 1);
/* The directory portion of the path must exist */ /* The directory portion of the path must exist */
if ((ret = stat(dname, &sbuf)) != 0 || !(sbuf.st_mode & if (stat(dname, &sbuf) != 0 || !(sbuf.st_mode & S_IFDIR))
S_IFDIR))
usage(prog); usage(prog);
rc = asprintf(&fpath, "%s/%s", dname, fname); if (asprintf(&fpath, "%s/%s", dname, fname) == -1)
free(dname); fail("asprintf");
free(fname);
if (rc == -1 || fpath == NULL)
fail("asprintf", 1);
} else if ((sbuf.st_mode & S_IFMT) == S_IFREG || free(arg);
(sbuf.st_mode & S_IFMT) == S_IFLNK || } else
(sbuf.st_mode & S_IFMT) == S_IFCHR || switch (sbuf.st_mode & S_IFMT) {
(sbuf.st_mode & S_IFMT) == S_IFBLK) { case S_IFDIR:
fpath = strdup(argv[0]);
} else if ((sbuf.st_mode & S_IFMT) == S_IFDIR) {
fpath = strdup(argv[0]);
isdir = B_TRUE; isdir = B_TRUE;
} else { /* FALLTHROUGH */
case S_IFLNK:
case S_IFCHR:
case S_IFBLK:
if ((fpath = strdup(argv[0])) == NULL)
fail("strdup");
break;
default:
usage(prog); usage(prog);
} }
if (fpath == NULL) if (!isdir) {
fail("strdup", 1); int fd;
if (isdir == B_FALSE) { if ((fd = open(fpath, O_CREAT | O_RDWR, 0600)) < 0)
int fd, flags; fail("open");
mode_t mode = S_IRUSR | S_IWUSR;
flags = rflag == B_FALSE ? O_CREAT | O_RDWR : O_RDONLY;
if ((fd = open(fpath, flags, mode)) < 0)
fail("open", 1);
} else { } else {
DIR *dp; DIR *dp;
if ((dp = opendir(fpath)) == NULL) if ((dp = opendir(fpath)) == NULL)
fail("opendir", 1); fail("opendir");
} }
free(fpath); free(fpath);
if (fflag == B_FALSE)
daemonize(); daemonize();
(void) pause(); (void) pause();
/* NOTREACHED */
return (0); return (0);
} }

View File

@ -44,7 +44,7 @@
#define FILE_MODE (S_ISVTX + S_IRUSR + S_IWUSR) #define FILE_MODE (S_ISVTX + S_IRUSR + S_IWUSR)
static void usage(void); static void usage(void) __attribute__((noreturn));
int int
main(int argc, char **argv) main(int argc, char **argv)
@ -278,5 +278,4 @@ static void usage()
(void) fprintf(stderr, gettext( (void) fprintf(stderr, gettext(
"Usage: mkfile [-nv] <size>[g|k|b|m] <name1> [<name2>] ...\n")); "Usage: mkfile [-nv] <size>[g|k|b|m] <name1> [<name2>] ...\n"));
exit(1); exit(1);
/* NOTREACHED */
} }

View File

@ -66,19 +66,15 @@ normal_writer(void *filename)
err(1, "failed to open %s", file_path); err(1, "failed to open %s", file_path);
} }
char *buf = malloc(1); char buf;
while (1) { while (1) {
write_num = write(fd, buf, 1); write_num = write(fd, &buf, 1);
if (write_num == 0) { if (write_num == 0) {
err(1, "write failed!"); err(1, "write failed!");
break; break;
} }
lseek(fd, page_size, SEEK_CUR); lseek(fd, page_size, SEEK_CUR);
} }
if (buf) {
free(buf);
}
} }
static void * static void *
@ -156,7 +152,6 @@ main(int argc, char **argv)
err(1, "pthread_create map_writer failed."); err(1, "pthread_create map_writer failed.");
} }
/* NOTREACHED */
pthread_join(map_write_tid, NULL); pthread_join(map_write_tid, NULL);
return (0); return (0);
} }