Skip to content

Commit c99c900

Browse files
Madhav Sureshbehlendorf
authored andcommitted
Illumos #3006
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero Reviewed by Matt Ahrens <matthew.ahrens@delphix.com> Reviewed by George Wilson <george.wilson@delphix.com> Approved by Eric Schrock <eric.schrock@delphix.com> References: illumos/illumos-gate@fb09f5a https://illumos.org/issues/3006 Requires: openzfs/spl@1c6d149 Ported-by: Tim Chase <tim@chase2k.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #1509
1 parent 9eaf083 commit c99c900

32 files changed

+199
-187
lines changed

cmd/ztest/ztest.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ ztest_dsl_prop_set_uint64(char *osname, zfs_prop_t prop, uint64_t value,
10391039
ztest_record_enospc(FTAG);
10401040
return (error);
10411041
}
1042-
ASSERT3U(error, ==, 0);
1042+
ASSERT0(error);
10431043

10441044
setpoint = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
10451045
VERIFY3U(dsl_prop_get(osname, propname, sizeof (curval),
@@ -1073,7 +1073,7 @@ ztest_spa_prop_set_uint64(zpool_prop_t prop, uint64_t value)
10731073
ztest_record_enospc(FTAG);
10741074
return (error);
10751075
}
1076-
ASSERT3U(error, ==, 0);
1076+
ASSERT0(error);
10771077

10781078
return (error);
10791079
}
@@ -1776,7 +1776,7 @@ ztest_replay_setattr(ztest_ds_t *zd, lr_setattr_t *lr, boolean_t byteswap)
17761776

17771777
ASSERT3U(lr->lr_size, >=, sizeof (*bbt));
17781778
ASSERT3U(lr->lr_size, <=, db->db_size);
1779-
VERIFY3U(dmu_set_bonus(db, lr->lr_size, tx), ==, 0);
1779+
VERIFY0(dmu_set_bonus(db, lr->lr_size, tx));
17801780
bbt = ztest_bt_bonus(db);
17811781

17821782
ztest_bt_generate(bbt, os, lr->lr_foid, -1ULL, lr->lr_mode, txg, crtxg);
@@ -3200,7 +3200,7 @@ ztest_objset_destroy_cb(const char *name, void *arg)
32003200
error = dmu_object_info(os, ZTEST_DIROBJ, &doi);
32013201
if (error != ENOENT) {
32023202
/* We could have crashed in the middle of destroying it */
3203-
ASSERT3U(error, ==, 0);
3203+
ASSERT0(error);
32043204
ASSERT3U(doi.doi_type, ==, DMU_OT_ZAP_OTHER);
32053205
ASSERT3S(doi.doi_physical_blocks_512, >=, 0);
32063206
}
@@ -3673,10 +3673,10 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
36733673
*/
36743674
error = dmu_read(os, packobj, packoff, packsize, packbuf,
36753675
DMU_READ_PREFETCH);
3676-
ASSERT3U(error, ==, 0);
3676+
ASSERT0(error);
36773677
error = dmu_read(os, bigobj, bigoff, bigsize, bigbuf,
36783678
DMU_READ_PREFETCH);
3679-
ASSERT3U(error, ==, 0);
3679+
ASSERT0(error);
36803680

36813681
/*
36823682
* Get a tx for the mods to both packobj and bigobj.
@@ -3999,10 +3999,10 @@ ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id)
39993999
if (i != 0 || ztest_random(2) != 0) {
40004000
error = dmu_read(os, packobj, packoff,
40014001
packsize, packbuf, DMU_READ_PREFETCH);
4002-
ASSERT3U(error, ==, 0);
4002+
ASSERT0(error);
40034003
error = dmu_read(os, bigobj, bigoff, bigsize,
40044004
bigbuf, DMU_READ_PREFETCH);
4005-
ASSERT3U(error, ==, 0);
4005+
ASSERT0(error);
40064006
}
40074007
compare_and_update_pbbufs(s, packbuf, bigbuf, bigsize,
40084008
n, chunksize, txg);
@@ -4287,7 +4287,7 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
42874287
if (error == ENOENT)
42884288
goto out;
42894289

4290-
ASSERT3U(error, ==, 0);
4290+
ASSERT0(error);
42914291

42924292
tx = dmu_tx_create(os);
42934293
dmu_tx_hold_zap(tx, object, B_TRUE, NULL);
@@ -4494,7 +4494,7 @@ ztest_commit_callback(void *arg, int error)
44944494
data->zcd_called = B_TRUE;
44954495

44964496
if (error == ECANCELED) {
4497-
ASSERT3U(data->zcd_txg, ==, 0);
4497+
ASSERT0(data->zcd_txg);
44984498
ASSERT(!data->zcd_added);
44994499

45004500
/*
@@ -4704,7 +4704,7 @@ ztest_spa_prop_get_set(ztest_ds_t *zd, uint64_t id)
47044704
(void) ztest_spa_prop_set_uint64(ZPOOL_PROP_DEDUPDITTO,
47054705
ZIO_DEDUPDITTO_MIN + ztest_random(ZIO_DEDUPDITTO_MIN));
47064706

4707-
VERIFY3U(spa_prop_get(ztest_spa, &props), ==, 0);
4707+
VERIFY0(spa_prop_get(ztest_spa, &props));
47084708

47094709
if (ztest_opts.zo_verbose >= 6)
47104710
dump_nvlist(props, 4);
@@ -5557,7 +5557,7 @@ ztest_dataset_open(int d)
55575557
}
55585558
ASSERT(error == 0 || error == EEXIST);
55595559

5560-
VERIFY3U(dmu_objset_hold(name, zd, &os), ==, 0);
5560+
VERIFY0(dmu_objset_hold(name, zd, &os));
55615561
(void) rw_exit(&ztest_name_lock);
55625562

55635563
ztest_zd_init(zd, ZTEST_GET_SHARED_DS(d), os);
@@ -5757,7 +5757,7 @@ ztest_run(ztest_shared_t *zs)
57575757

57585758
/* Verify that at least one commit cb was called in a timely fashion */
57595759
if (zc_cb_counter >= ZTEST_COMMIT_CB_MIN_REG)
5760-
VERIFY3U(zc_min_txg_delay, ==, 0);
5760+
VERIFY0(zc_min_txg_delay);
57615761

57625762
spa_close(spa, FTAG);
57635763

include/sys/zfs_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
#define _SYS_RWLOCK_H
7373
#define _SYS_CONDVAR_H
7474
#define _SYS_SYSTM_H
75-
#define _SYS_DEBUG_H
7675
#define _SYS_T_LOCK_H
7776
#define _SYS_VNODE_H
7877
#define _SYS_VFS_H
@@ -112,6 +111,7 @@
112111
#include <sys/u8_textprep.h>
113112
#include <sys/fm/fs/zfs.h>
114113
#include <sys/sunddi.h>
114+
#include <sys/debug.h>
115115

116116
/*
117117
* Stack

lib/libspl/include/assert.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,19 @@ extern void __assert(const char *, const char *, int);
8080
#define VERIFY3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t)
8181
#define VERIFY3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t)
8282
#define VERIFY3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t)
83+
#define VERIFY0(x) VERIFY3_IMPL(x, ==, 0, uint64_t)
8384

8485
#ifdef NDEBUG
8586
#define ASSERT3S(x, y, z) ((void)0)
8687
#define ASSERT3U(x, y, z) ((void)0)
8788
#define ASSERT3P(x, y, z) ((void)0)
89+
#define ASSERT0(x) ((void)0)
8890
#define ASSERTV(x)
8991
#else
9092
#define ASSERT3S(x, y, z) VERIFY3S(x, y, z)
9193
#define ASSERT3U(x, y, z) VERIFY3U(x, y, z)
9294
#define ASSERT3P(x, y, z) VERIFY3P(x, y, z)
95+
#define ASSERT0(x) VERIFY0(x)
9396
#define ASSERTV(x) x
9497
#endif /* NDEBUG */
9598

0 commit comments

Comments
 (0)