From owner-svn-src-all@FreeBSD.ORG Tue Sep 27 08:50:37 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BBC3C106566B; Tue, 27 Sep 2011 08:50:37 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AAF288FC17; Tue, 27 Sep 2011 08:50:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8R8obfS013421; Tue, 27 Sep 2011 08:50:37 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8R8obQB013411; Tue, 27 Sep 2011 08:50:37 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201109270850.p8R8obQB013411@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Tue, 27 Sep 2011 08:50:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225787 - head/sbin/hastd X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Sep 2011 08:50:37 -0000 Author: pjd Date: Tue Sep 27 08:50:37 2011 New Revision: 225787 URL: http://svn.freebsd.org/changeset/base/225787 Log: Use PJDLOG_ASSERT() and PJDLOG_ABORT() everywhere instead of assert(). MFC after: 3 days Modified: head/sbin/hastd/activemap.c head/sbin/hastd/ebuf.c head/sbin/hastd/event.c head/sbin/hastd/hast_proto.c head/sbin/hastd/hooks.c head/sbin/hastd/metadata.c head/sbin/hastd/nv.c head/sbin/hastd/rangelock.c head/sbin/hastd/synch.h Modified: head/sbin/hastd/activemap.c ============================================================================== --- head/sbin/hastd/activemap.c Tue Sep 27 08:26:09 2011 (r225786) +++ head/sbin/hastd/activemap.c Tue Sep 27 08:50:37 2011 (r225787) @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include /* powerof2() */ #include -#include #include #include #include @@ -41,7 +40,14 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include + +#include "activemap.h" + +#ifndef PJDLOG_ASSERT +#include +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#endif #define ACTIVEMAP_MAGIC 0xac71e4 struct activemap { @@ -93,9 +99,9 @@ off2ext(const struct activemap *amp, off { int extent; - assert(offset >= 0 && offset < amp->am_mediasize); + PJDLOG_ASSERT(offset >= 0 && offset < amp->am_mediasize); extent = (offset >> amp->am_extentshift); - assert(extent >= 0 && extent < amp->am_nextents); + PJDLOG_ASSERT(extent >= 0 && extent < amp->am_nextents); return (extent); } @@ -104,9 +110,9 @@ ext2off(const struct activemap *amp, int { off_t offset; - assert(extent >= 0 && extent < amp->am_nextents); + PJDLOG_ASSERT(extent >= 0 && extent < amp->am_nextents); offset = ((off_t)extent << amp->am_extentshift); - assert(offset >= 0 && offset < amp->am_mediasize); + PJDLOG_ASSERT(offset >= 0 && offset < amp->am_mediasize); return (offset); } @@ -122,7 +128,7 @@ ext2reqs(const struct activemap *amp, in if (ext < amp->am_nextents - 1) return (((amp->am_extentsize - 1) / MAXPHYS) + 1); - assert(ext == amp->am_nextents - 1); + PJDLOG_ASSERT(ext == amp->am_nextents - 1); left = amp->am_mediasize % amp->am_extentsize; if (left == 0) left = amp->am_extentsize; @@ -139,13 +145,13 @@ activemap_init(struct activemap **ampp, { struct activemap *amp; - assert(ampp != NULL); - assert(mediasize > 0); - assert(extentsize > 0); - assert(powerof2(extentsize)); - assert(sectorsize > 0); - assert(powerof2(sectorsize)); - assert(keepdirty > 0); + PJDLOG_ASSERT(ampp != NULL); + PJDLOG_ASSERT(mediasize > 0); + PJDLOG_ASSERT(extentsize > 0); + PJDLOG_ASSERT(powerof2(extentsize)); + PJDLOG_ASSERT(sectorsize > 0); + PJDLOG_ASSERT(powerof2(sectorsize)); + PJDLOG_ASSERT(keepdirty > 0); amp = malloc(sizeof(*amp)); if (amp == NULL) @@ -225,10 +231,10 @@ keepdirty_add(struct activemap *amp, int */ if (amp->am_nkeepdirty >= amp->am_nkeepdirty_limit) { kd = TAILQ_LAST(&->am_keepdirty, skeepdirty); - assert(kd != NULL); + PJDLOG_ASSERT(kd != NULL); TAILQ_REMOVE(&->am_keepdirty, kd, kd_next); amp->am_nkeepdirty--; - assert(amp->am_nkeepdirty > 0); + PJDLOG_ASSERT(amp->am_nkeepdirty > 0); } if (kd == NULL) kd = malloc(sizeof(*kd)); @@ -261,7 +267,7 @@ keepdirty_free(struct activemap *amp) amp->am_nkeepdirty--; free(kd); } - assert(amp->am_nkeepdirty == 0); + PJDLOG_ASSERT(amp->am_nkeepdirty == 0); } /* @@ -271,7 +277,7 @@ void activemap_free(struct activemap *amp) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); amp->am_magic = 0; @@ -293,8 +299,8 @@ activemap_write_start(struct activemap * off_t end; int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(length > 0); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(length > 0); modified = false; end = offset + length - 1; @@ -307,7 +313,7 @@ activemap_write_start(struct activemap * * was modified and has to be flushed to disk. */ if (amp->am_memtab[ext]++ == 0) { - assert(!bit_test(amp->am_memmap, ext)); + PJDLOG_ASSERT(!bit_test(amp->am_memmap, ext)); bit_set(amp->am_memmap, ext); amp->am_ndirty++; } @@ -329,8 +335,8 @@ activemap_write_complete(struct activema off_t end; int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(length > 0); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(length > 0); modified = false; end = offset + length - 1; @@ -342,8 +348,8 @@ activemap_write_complete(struct activema * By returning true we inform the caller that on-disk bitmap * was modified and has to be flushed to disk. */ - assert(amp->am_memtab[ext] > 0); - assert(bit_test(amp->am_memmap, ext)); + PJDLOG_ASSERT(amp->am_memtab[ext] > 0); + PJDLOG_ASSERT(bit_test(amp->am_memmap, ext)); if (--amp->am_memtab[ext] == 0) { bit_clear(amp->am_memmap, ext); amp->am_ndirty--; @@ -365,15 +371,15 @@ activemap_extent_complete(struct activem bool modified; int reqs; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(extent >= 0 && extent < amp->am_nextents); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(extent >= 0 && extent < amp->am_nextents); modified = false; reqs = ext2reqs(amp, extent); - assert(amp->am_memtab[extent] >= reqs); + PJDLOG_ASSERT(amp->am_memtab[extent] >= reqs); amp->am_memtab[extent] -= reqs; - assert(bit_test(amp->am_memmap, extent)); + PJDLOG_ASSERT(bit_test(amp->am_memmap, extent)); if (amp->am_memtab[extent] == 0) { bit_clear(amp->am_memmap, extent); amp->am_ndirty--; @@ -390,7 +396,7 @@ uint64_t activemap_ndirty(const struct activemap *amp) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); return (amp->am_ndirty); } @@ -403,7 +409,7 @@ bool activemap_differ(const struct activemap *amp) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); return (memcmp(amp->am_diskmap, amp->am_memmap, amp->am_mapsize) != 0); @@ -416,7 +422,7 @@ size_t activemap_size(const struct activemap *amp) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); return (amp->am_mapsize); } @@ -429,7 +435,7 @@ size_t activemap_ondisk_size(const struct activemap *amp) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); return (amp->am_diskmapsize); } @@ -442,8 +448,8 @@ activemap_copyin(struct activemap *amp, { int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(size >= amp->am_mapsize); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(size >= amp->am_mapsize); memcpy(amp->am_diskmap, buf, amp->am_mapsize); memcpy(amp->am_memmap, buf, amp->am_mapsize); @@ -481,8 +487,8 @@ activemap_merge(struct activemap *amp, c bitstr_t *remmap = __DECONST(bitstr_t *, buf); int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(size >= amp->am_mapsize); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(size >= amp->am_mapsize); bit_ffs(remmap, amp->am_nextents, &ext); if (ext == -1) { @@ -521,7 +527,7 @@ const unsigned char * activemap_bitmap(struct activemap *amp, size_t *sizep) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); if (sizep != NULL) *sizep = amp->am_diskmapsize; @@ -539,11 +545,11 @@ activemap_calc_ondisk_size(uint64_t medi { uint64_t nextents, mapsize; - assert(mediasize > 0); - assert(extentsize > 0); - assert(powerof2(extentsize)); - assert(sectorsize > 0); - assert(powerof2(sectorsize)); + PJDLOG_ASSERT(mediasize > 0); + PJDLOG_ASSERT(extentsize > 0); + PJDLOG_ASSERT(powerof2(extentsize)); + PJDLOG_ASSERT(sectorsize > 0); + PJDLOG_ASSERT(powerof2(sectorsize)); nextents = ((mediasize - 1) / extentsize) + 1; mapsize = sizeof(bitstr_t) * bitstr_size(nextents); @@ -558,7 +564,7 @@ activemap_sync_rewind(struct activemap * { int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); bit_ffs(amp->am_syncmap, amp->am_nextents, &ext); if (ext == -1) { @@ -581,9 +587,9 @@ activemap_sync_offset(struct activemap * off_t syncoff, left; int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(lengthp != NULL); - assert(syncextp != NULL); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(lengthp != NULL); + PJDLOG_ASSERT(syncextp != NULL); *syncextp = -1; @@ -632,9 +638,10 @@ activemap_sync_offset(struct activemap * if (left > MAXPHYS) left = MAXPHYS; - assert(left >= 0 && left <= MAXPHYS); - assert(syncoff >= 0 && syncoff < amp->am_mediasize); - assert(syncoff + left >= 0 && syncoff + left <= amp->am_mediasize); + PJDLOG_ASSERT(left >= 0 && left <= MAXPHYS); + PJDLOG_ASSERT(syncoff >= 0 && syncoff < amp->am_mediasize); + PJDLOG_ASSERT(syncoff + left >= 0 && + syncoff + left <= amp->am_mediasize); *lengthp = left; return (syncoff); @@ -651,7 +658,7 @@ activemap_need_sync(struct activemap *am off_t end; int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); modified = false; end = offset + length - 1; @@ -659,7 +666,7 @@ activemap_need_sync(struct activemap *am for (ext = off2ext(amp, offset); ext <= off2ext(amp, end); ext++) { if (bit_test(amp->am_syncmap, ext)) { /* Already marked for synchronization. */ - assert(bit_test(amp->am_memmap, ext)); + PJDLOG_ASSERT(bit_test(amp->am_memmap, ext)); continue; } bit_set(amp->am_syncmap, ext); Modified: head/sbin/hastd/ebuf.c ============================================================================== --- head/sbin/hastd/ebuf.c Tue Sep 27 08:26:09 2011 (r225786) +++ head/sbin/hastd/ebuf.c Tue Sep 27 08:50:37 2011 (r225787) @@ -32,15 +32,21 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include #include #include #include +#include + #include "ebuf.h" +#ifndef PJDLOG_ASSERT +#include +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#endif + #define EBUF_MAGIC 0xeb0f41c struct ebuf { /* Magic to assert the caller uses valid structure. */ @@ -91,7 +97,7 @@ void ebuf_free(struct ebuf *eb) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); eb->eb_magic = 0; @@ -103,7 +109,7 @@ int ebuf_add_head(struct ebuf *eb, const void *data, size_t size) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); if (size > (size_t)(eb->eb_used - eb->eb_start)) { /* @@ -113,7 +119,7 @@ ebuf_add_head(struct ebuf *eb, const voi if (ebuf_head_extend(eb, size) < 0) return (-1); } - assert(size <= (size_t)(eb->eb_used - eb->eb_start)); + PJDLOG_ASSERT(size <= (size_t)(eb->eb_used - eb->eb_start)); eb->eb_size += size; eb->eb_used -= size; @@ -130,7 +136,7 @@ int ebuf_add_tail(struct ebuf *eb, const void *data, size_t size) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); if (size > (size_t)(eb->eb_end - (eb->eb_used + eb->eb_size))) { /* @@ -140,7 +146,8 @@ ebuf_add_tail(struct ebuf *eb, const voi if (ebuf_tail_extend(eb, size) < 0) return (-1); } - assert(size <= (size_t)(eb->eb_end - (eb->eb_used + eb->eb_size))); + PJDLOG_ASSERT(size <= + (size_t)(eb->eb_end - (eb->eb_used + eb->eb_size))); /* * If data is NULL the caller just wants to reserve space. @@ -156,8 +163,8 @@ void ebuf_del_head(struct ebuf *eb, size_t size) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); - assert(size <= eb->eb_size); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(size <= eb->eb_size); eb->eb_used += size; eb->eb_size -= size; @@ -167,8 +174,8 @@ void ebuf_del_tail(struct ebuf *eb, size_t size) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); - assert(size <= eb->eb_size); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(size <= eb->eb_size); eb->eb_size -= size; } @@ -180,7 +187,7 @@ void * ebuf_data(struct ebuf *eb, size_t *sizep) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); if (sizep != NULL) *sizep = eb->eb_size; @@ -194,7 +201,7 @@ size_t ebuf_size(struct ebuf *eb) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); return (eb->eb_size); } @@ -208,7 +215,7 @@ ebuf_head_extend(struct ebuf *eb, size_t unsigned char *newstart, *newused; size_t newsize; - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); newsize = eb->eb_end - eb->eb_start + (PAGE_SIZE / 4) + size; @@ -236,7 +243,7 @@ ebuf_tail_extend(struct ebuf *eb, size_t unsigned char *newstart; size_t newsize; - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); newsize = eb->eb_end - eb->eb_start + size + ((3 * PAGE_SIZE) / 4); Modified: head/sbin/hastd/event.c ============================================================================== --- head/sbin/hastd/event.c Tue Sep 27 08:26:09 2011 (r225786) +++ head/sbin/hastd/event.c Tue Sep 27 08:50:37 2011 (r225787) @@ -27,7 +27,6 @@ #include __FBSDID("$FreeBSD$"); -#include #include #include "hast.h" @@ -46,8 +45,8 @@ event_send(const struct hast_resource *r struct nv *nvin, *nvout; int error; - assert(res != NULL); - assert(event >= EVENT_MIN && event <= EVENT_MAX); + PJDLOG_ASSERT(res != NULL); + PJDLOG_ASSERT(event >= EVENT_MIN && event <= EVENT_MAX); nvin = nvout = NULL; @@ -89,7 +88,7 @@ event_recv(const struct hast_resource *r uint8_t event; int error; - assert(res != NULL); + PJDLOG_ASSERT(res != NULL); nvin = nvout = NULL; Modified: head/sbin/hastd/hast_proto.c ============================================================================== --- head/sbin/hastd/hast_proto.c Tue Sep 27 08:26:09 2011 (r225786) +++ head/sbin/hastd/hast_proto.c Tue Sep 27 08:50:37 2011 (r225787) @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include @@ -158,7 +157,7 @@ hast_proto_recv_hdr(const struct proto_c if (ebuf_add_tail(eb, NULL, hdr.size) < 0) goto fail; hptr = ebuf_data(eb, NULL); - assert(hptr != NULL); + PJDLOG_ASSERT(hptr != NULL); if (proto_recv(conn, hptr, hdr.size) < 0) goto fail; nv = nv_ntoh(eb); @@ -183,8 +182,8 @@ hast_proto_recv_data(const struct hast_r void *dptr; int ret; - assert(data != NULL); - assert(size > 0); + PJDLOG_ASSERT(data != NULL); + PJDLOG_ASSERT(size > 0); ret = -1; freedata = false; Modified: head/sbin/hastd/hooks.c ============================================================================== --- head/sbin/hastd/hooks.c Tue Sep 27 08:26:09 2011 (r225786) +++ head/sbin/hastd/hooks.c Tue Sep 27 08:50:37 2011 (r225787) @@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include @@ -138,7 +137,7 @@ void hook_init(void) { - assert(!hooks_initialized); + PJDLOG_ASSERT(!hooks_initialized); mtx_init(&hookprocs_lock); TAILQ_INIT(&hookprocs); @@ -150,12 +149,12 @@ hook_fini(void) { struct hookproc *hp; - assert(hooks_initialized); + PJDLOG_ASSERT(hooks_initialized); mtx_lock(&hookprocs_lock); while ((hp = TAILQ_FIRST(&hookprocs)) != NULL) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); - assert(hp->hp_pid > 0); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); + PJDLOG_ASSERT(hp->hp_pid > 0); hook_remove(hp); hook_free(hp); @@ -201,8 +200,8 @@ static void hook_add(struct hookproc *hp, pid_t pid) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ALLOCATED); - assert(hp->hp_pid == 0); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ALLOCATED); + PJDLOG_ASSERT(hp->hp_pid == 0); hp->hp_pid = pid; mtx_lock(&hookprocs_lock); @@ -215,9 +214,9 @@ static void hook_remove(struct hookproc *hp) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); - assert(hp->hp_pid > 0); - assert(mtx_owned(&hookprocs_lock)); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); + PJDLOG_ASSERT(hp->hp_pid > 0); + PJDLOG_ASSERT(mtx_owned(&hookprocs_lock)); TAILQ_REMOVE(&hookprocs, hp, hp_next); hp->hp_magic = HOOKPROC_MAGIC_ALLOCATED; @@ -227,8 +226,8 @@ static void hook_free(struct hookproc *hp) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ALLOCATED); - assert(hp->hp_pid > 0); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ALLOCATED); + PJDLOG_ASSERT(hp->hp_pid > 0); hp->hp_magic = 0; free(hp); @@ -239,11 +238,11 @@ hook_find(pid_t pid) { struct hookproc *hp; - assert(mtx_owned(&hookprocs_lock)); + PJDLOG_ASSERT(mtx_owned(&hookprocs_lock)); TAILQ_FOREACH(hp, &hookprocs, hp_next) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); - assert(hp->hp_pid > 0); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); + PJDLOG_ASSERT(hp->hp_pid > 0); if (hp->hp_pid == pid) break; @@ -286,7 +285,7 @@ hook_check(void) struct hookproc *hp, *hp2; time_t now; - assert(hooks_initialized); + PJDLOG_ASSERT(hooks_initialized); pjdlog_debug(2, "Checking hooks."); @@ -296,8 +295,8 @@ hook_check(void) now = time(NULL); mtx_lock(&hookprocs_lock); TAILQ_FOREACH_SAFE(hp, &hookprocs, hp_next, hp2) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); - assert(hp->hp_pid > 0); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); + PJDLOG_ASSERT(hp->hp_pid > 0); /* * If process doesn't exists we somehow missed it. @@ -347,7 +346,7 @@ hook_execv(const char *path, va_list ap) sigset_t mask; pid_t pid; - assert(hooks_initialized); + PJDLOG_ASSERT(hooks_initialized); if (path == NULL || path[0] == '\0') return; @@ -359,7 +358,7 @@ hook_execv(const char *path, va_list ap) if (args[ii] == NULL) break; } - assert(ii < sizeof(args) / sizeof(args[0])); + PJDLOG_ASSERT(ii < sizeof(args) / sizeof(args[0])); hp = hook_alloc(path, args); if (hp == NULL) Modified: head/sbin/hastd/metadata.c ============================================================================== --- head/sbin/hastd/metadata.c Tue Sep 27 08:26:09 2011 (r225786) +++ head/sbin/hastd/metadata.c Tue Sep 27 08:50:37 2011 (r225787) @@ -30,7 +30,6 @@ #include __FBSDID("$FreeBSD$"); -#include #include #include #include @@ -100,7 +99,7 @@ metadata_read(struct hast_resource *res, goto fail; } buf = ebuf_data(eb, NULL); - assert(buf != NULL); + PJDLOG_ASSERT(buf != NULL); done = pread(res->hr_localfd, buf, METADATA_SIZE, 0); if (done < 0 || done != METADATA_SIZE) { rerrno = errno; @@ -197,7 +196,7 @@ metadata_write(struct hast_resource *res nv_add_uint64(nv, res->hr_primary_localcnt, "localcnt"); nv_add_uint64(nv, res->hr_primary_remotecnt, "remotecnt"); } else /* if (res->hr_role == HAST_ROLE_SECONDARY) */ { - assert(res->hr_role == HAST_ROLE_SECONDARY); + PJDLOG_ASSERT(res->hr_role == HAST_ROLE_SECONDARY); nv_add_uint64(nv, res->hr_secondary_localcnt, "localcnt"); nv_add_uint64(nv, res->hr_secondary_remotecnt, "remotecnt"); } @@ -208,10 +207,10 @@ metadata_write(struct hast_resource *res } res->hr_previous_role = res->hr_role; eb = nv_hton(nv); - assert(eb != NULL); + PJDLOG_ASSERT(eb != NULL); ptr = ebuf_data(eb, &size); - assert(ptr != NULL); - assert(size < METADATA_SIZE); + PJDLOG_ASSERT(ptr != NULL); + PJDLOG_ASSERT(size < METADATA_SIZE); bcopy(ptr, buf, size); done = pwrite(res->hr_localfd, buf, METADATA_SIZE, 0); if (done < 0 || done != METADATA_SIZE) { Modified: head/sbin/hastd/nv.c ============================================================================== --- head/sbin/hastd/nv.c Tue Sep 27 08:26:09 2011 (r225786) +++ head/sbin/hastd/nv.c Tue Sep 27 08:50:37 2011 (r225787) @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include @@ -44,7 +43,17 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include + +#include "nv.h" + +#ifndef PJDLOG_ASSERT +#include +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#endif +#ifndef PJDLOG_ABORT +#define PJDLOG_ABORT(...) abort() +#endif #define NV_TYPE_NONE 0 @@ -98,8 +107,8 @@ struct nvhdr { #define NVH_SIZE(nvh) (NVH_HSIZE(nvh) + roundup2(NVH_DSIZE(nvh), 8)) #define NV_CHECK(nv) do { \ - assert((nv) != NULL); \ - assert((nv)->nv_magic == NV_MAGIC); \ + PJDLOG_ASSERT((nv) != NULL); \ + PJDLOG_ASSERT((nv)->nv_magic == NV_MAGIC); \ } while (0) static void nv_add(struct nv *nv, const unsigned char *value, size_t vsize, @@ -200,7 +209,7 @@ nv_validate(struct nv *nv, size_t *extra } NV_CHECK(nv); - assert(nv->nv_error == 0); + PJDLOG_ASSERT(nv->nv_error == 0); /* TODO: Check that names are unique? */ @@ -308,7 +317,7 @@ nv_validate(struct nv *nv, size_t *extra } break; default: - assert(!"invalid condition"); + PJDLOG_ABORT("invalid condition"); } if (error != 0) break; @@ -338,7 +347,7 @@ nv_hton(struct nv *nv) size_t size; NV_CHECK(nv); - assert(nv->nv_error == 0); + PJDLOG_ASSERT(nv->nv_error == 0); ptr = ebuf_data(nv->nv_ebuf, &size); while (size > 0) { @@ -346,9 +355,9 @@ nv_hton(struct nv *nv) * Minimum size at this point is size of nvhdr structure, * one character long name plus terminating '\0'. */ - assert(size >= sizeof(*nvh) + 2); + PJDLOG_ASSERT(size >= sizeof(*nvh) + 2); nvh = (struct nvhdr *)ptr; - assert(NVH_SIZE(nvh) <= size); + PJDLOG_ASSERT(NVH_SIZE(nvh) <= size); nv_swap(nvh, false); ptr += NVH_SIZE(nvh); size -= NVH_SIZE(nvh); @@ -367,7 +376,7 @@ nv_ntoh(struct ebuf *eb) size_t extra; int rerrno; - assert(eb != NULL); + PJDLOG_ASSERT(eb != NULL); nv = malloc(sizeof(*nv)); if (nv == NULL) @@ -494,8 +503,8 @@ nv_get_##type(struct nv *nv, const char va_end(nameap); \ if (nvh == NULL) \ return (0); \ - assert((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST); \ - assert(sizeof(value) == nvh->nvh_dsize); \ + PJDLOG_ASSERT((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST);\ + PJDLOG_ASSERT(sizeof(value) == nvh->nvh_dsize); \ bcopy(NVH_DATA(nvh), &value, sizeof(value)); \ \ return (value); \ @@ -525,8 +534,8 @@ nv_get_##type##_array(struct nv *nv, siz va_end(nameap); \ if (nvh == NULL) \ return (NULL); \ - assert((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST); \ - assert((nvh->nvh_dsize % sizeof(type##_t)) == 0); \ + PJDLOG_ASSERT((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST);\ + PJDLOG_ASSERT((nvh->nvh_dsize % sizeof(type##_t)) == 0); \ if (sizep != NULL) \ *sizep = nvh->nvh_dsize / sizeof(type##_t); \ return ((type##_t *)(void *)NVH_DATA(nvh)); \ @@ -555,11 +564,11 @@ nv_get_string(struct nv *nv, const char va_end(nameap); if (nvh == NULL) return (NULL); - assert((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST); - assert(nvh->nvh_dsize >= 1); + PJDLOG_ASSERT((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST); + PJDLOG_ASSERT(nvh->nvh_dsize >= 1); str = NVH_DATA(nvh); - assert(str[nvh->nvh_dsize - 1] == '\0'); - assert(strlen(str) == nvh->nvh_dsize - 1); + PJDLOG_ASSERT(str[nvh->nvh_dsize - 1] == '\0'); + PJDLOG_ASSERT(strlen(str) == nvh->nvh_dsize - 1); return (str); } @@ -602,7 +611,7 @@ nv_assert(struct nv *nv, const char *nam va_list nameap; va_start(nameap, namefmt); - assert(nv_vexists(nv, namefmt, nameap)); + PJDLOG_ASSERT(nv_vexists(nv, namefmt, nameap)); va_end(nameap); } @@ -624,13 +633,13 @@ nv_dump(struct nv *nv) } NV_CHECK(nv); - assert(nv->nv_error == 0); + PJDLOG_ASSERT(nv->nv_error == 0); ptr = ebuf_data(nv->nv_ebuf, &size); while (size > 0) { - assert(size >= sizeof(*nvh) + 2); + PJDLOG_ASSERT(size >= sizeof(*nvh) + 2); nvh = (struct nvhdr *)ptr; - assert(size >= NVH_SIZE(nvh)); + PJDLOG_ASSERT(size >= NVH_SIZE(nvh)); swap = ((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_NETWORK); dsize = NVH_DSIZE(nvh); data = NVH_DATA(nvh); @@ -734,7 +743,7 @@ nv_dump(struct nv *nv) printf("(string): %s", (char *)data); break; default: - assert(!"invalid condition"); + PJDLOG_ABORT("invalid condition"); } printf("\n"); ptr += NVH_SIZE(nvh); @@ -776,7 +785,7 @@ nv_add(struct nv *nv, const unsigned cha /* Add header first. */ if (ebuf_add_tail(nv->nv_ebuf, nvh, NVH_HSIZE(nvh)) < 0) { - assert(errno != 0); + PJDLOG_ASSERT(errno != 0); if (nv->nv_error == 0) nv->nv_error = errno; free(nvh); @@ -785,7 +794,7 @@ nv_add(struct nv *nv, const unsigned cha free(nvh); /* Add the actual data. */ if (ebuf_add_tail(nv->nv_ebuf, value, vsize) < 0) { - assert(errno != 0); + PJDLOG_ASSERT(errno != 0); if (nv->nv_error == 0) nv->nv_error = errno; return; @@ -794,9 +803,9 @@ nv_add(struct nv *nv, const unsigned cha vsize = roundup2(vsize, 8) - vsize; if (vsize == 0) return; - assert(vsize > 0 && vsize <= sizeof(align)); + PJDLOG_ASSERT(vsize > 0 && vsize <= sizeof(align)); if (ebuf_add_tail(nv->nv_ebuf, align, vsize) < 0) { - assert(errno != 0); + PJDLOG_ASSERT(errno != 0); if (nv->nv_error == 0) nv->nv_error = errno; return; @@ -811,7 +820,7 @@ nv_addv(struct nv *nv, const unsigned ch size_t namesize; namesize = vsnprintf(name, sizeof(name), namefmt, nameap); - assert(namesize > 0 && namesize < sizeof(name)); + PJDLOG_ASSERT(namesize > 0 && namesize < sizeof(name)); nv_add(nv, value, vsize, type, name); } @@ -832,14 +841,14 @@ nv_find(struct nv *nv, int type, const c NV_CHECK(nv); namesize = vsnprintf(name, sizeof(name), namefmt, nameap); - assert(namesize > 0 && namesize < sizeof(name)); + PJDLOG_ASSERT(namesize > 0 && namesize < sizeof(name)); namesize++; ptr = ebuf_data(nv->nv_ebuf, &size); while (size > 0) { - assert(size >= sizeof(*nvh) + 2); + PJDLOG_ASSERT(size >= sizeof(*nvh) + 2); nvh = (struct nvhdr *)ptr; - assert(size >= NVH_SIZE(nvh)); + PJDLOG_ASSERT(size >= NVH_SIZE(nvh)); nv_swap(nvh, true); if (strcmp(nvh->nvh_name, name) == 0) { if (type != NV_TYPE_NONE && @@ -927,7 +936,7 @@ nv_swap(struct nvhdr *nvh, bool tohost) le64toh(*(uint64_t *)(void *)p); break; default: - assert(!"invalid condition"); + PJDLOG_ABORT("invalid condition"); } } else { switch (vsize) { @@ -944,7 +953,7 @@ nv_swap(struct nvhdr *nvh, bool tohost) htole64(*(uint64_t *)(void *)p); break; default: - assert(!"invalid condition"); + PJDLOG_ABORT("invalid condition"); } } } @@ -952,6 +961,6 @@ nv_swap(struct nvhdr *nvh, bool tohost) case NV_TYPE_STRING: break; default: - assert(!"unrecognized type"); + PJDLOG_ABORT("unrecognized type"); } } Modified: head/sbin/hastd/rangelock.c ============================================================================== --- head/sbin/hastd/rangelock.c Tue Sep 27 08:26:09 2011 (r225786) +++ head/sbin/hastd/rangelock.c Tue Sep 27 08:50:37 2011 (r225787) @@ -32,13 +32,19 @@ __FBSDID("$FreeBSD$"); #include -#include #include #include #include +#include + #include "rangelock.h" +#ifndef PJDLOG_ASSERT +#include +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#endif + #define RANGELOCKS_MAGIC 0x94310c struct rangelocks { int rls_magic; /* Magic value. */ @@ -56,7 +62,7 @@ rangelock_init(struct rangelocks **rlsp) { struct rangelocks *rls; - assert(rlsp != NULL); + PJDLOG_ASSERT(rlsp != NULL); rls = malloc(sizeof(*rls)); if (rls == NULL) @@ -75,7 +81,7 @@ rangelock_free(struct rangelocks *rls) { struct rlock *rl; - assert(rls->rls_magic == RANGELOCKS_MAGIC); + PJDLOG_ASSERT(rls->rls_magic == RANGELOCKS_MAGIC); rls->rls_magic = 0; @@ -91,7 +97,7 @@ rangelock_add(struct rangelocks *rls, of { struct rlock *rl; - assert(rls->rls_magic == RANGELOCKS_MAGIC); + PJDLOG_ASSERT(rls->rls_magic == RANGELOCKS_MAGIC); rl = malloc(sizeof(*rl)); if (rl == NULL) @@ -107,13 +113,13 @@ rangelock_del(struct rangelocks *rls, of { struct rlock *rl; - assert(rls->rls_magic == RANGELOCKS_MAGIC); + PJDLOG_ASSERT(rls->rls_magic == RANGELOCKS_MAGIC); TAILQ_FOREACH(rl, &rls->rls_locks, rl_next) { if (rl->rl_start == offset && rl->rl_end == offset + length) break; } - assert(rl != NULL); + PJDLOG_ASSERT(rl != NULL); TAILQ_REMOVE(&rls->rls_locks, rl, rl_next); free(rl); } @@ -123,7 +129,7 @@ rangelock_islocked(struct rangelocks *rl { struct rlock *rl; - assert(rls->rls_magic == RANGELOCKS_MAGIC); + PJDLOG_ASSERT(rls->rls_magic == RANGELOCKS_MAGIC); TAILQ_FOREACH(rl, &rls->rls_locks, rl_next) { if (rl->rl_start >= offset && rl->rl_start < offset + length) Modified: head/sbin/hastd/synch.h ============================================================================== --- head/sbin/hastd/synch.h Tue Sep 27 08:26:09 2011 (r225786) +++ head/sbin/hastd/synch.h Tue Sep 27 08:50:37 2011 (r225787) @@ -32,20 +32,26 @@ #ifndef _SYNCH_H_ #define _SYNCH_H_ -#include #include #include #include #include #include +#include + +#ifndef PJDLOG_ASSERT *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***