]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/free.c
tdb2: simplify logging levels, rename TDB_DEBUG_* to TDB_LOG_*
[ccan] / ccan / tdb2 / free.c
index 5d1bd3c6d1360d7c2a1b3498a58e3d7443ec0d18..70a7b6703434b32af5aee81f82db5f439255d0e0 100644 (file)
@@ -1,7 +1,7 @@
- /* 
+ /*
    Trivial Database 2: free list/block handling
    Copyright (C) Rusty Russell 2010
-   
+
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
@@ -116,9 +116,9 @@ static int remove_from_list(struct tdb_context *tdb,
                off = frec_prev(r) + offsetof(struct tdb_free_record, next);
        }
 
-#ifdef DEBUG
+#ifdef CCAN_TDB2_DEBUG
        if (tdb_read_off(tdb, off) != r_off) {
-               tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_DEBUG_FATAL,
+               tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_LOG_ERROR,
                         "remove_from_list: %llu bad prev in list %llu",
                         (long long)r_off, (long long)b_off);
                return -1;
@@ -134,9 +134,9 @@ static int remove_from_list(struct tdb_context *tdb,
                off = r->next + offsetof(struct tdb_free_record,magic_and_prev);
                /* r->next->prev = r->prev */
 
-#ifdef DEBUG
+#ifdef CCAN_TDB2_DEBUG
                if (tdb_read_off(tdb, off) & TDB_OFF_MASK != r_off) {
-                       tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_DEBUG_FATAL,
+                       tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_LOG_ERROR,
                                   "remove_from_list: %llu bad list %llu",
                                   (long long)r_off, (long long)b_off);
                        return -1;
@@ -171,12 +171,12 @@ static int enqueue_in_free(struct tdb_context *tdb,
                return -1;
 
        if (new.next) {
-#ifdef DEBUG
+#ifdef CCAN_TDB2_DEBUG
                if (tdb_read_off(tdb,
                                 new.next + offsetof(struct tdb_free_record,
                                                     magic_and_prev))
                    != magic) {
-                       tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_DEBUG_FATAL,
+                       tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_LOG_ERROR,
                                   "enqueue_in_free: %llu bad head"
                                   " prev %llu",
                                   (long long)new.next, (long long)b_off);
@@ -333,7 +333,7 @@ static int coalesce(struct tdb_context *tdb,
                goto err;
 
        if (frec_len(&rec) != data_len) {
-               tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_DEBUG_FATAL,
+               tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_LOG_ERROR,
                           "coalesce: expected data len %zu not %zu",
                           (size_t)data_len, (size_t)frec_len(&rec));
                goto err;
@@ -414,7 +414,7 @@ again:
 
                if (frec_magic(r) != TDB_FREE_MAGIC) {
                        tdb_access_release(tdb, r);
-                       tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_DEBUG_FATAL,
+                       tdb_logerr(tdb, TDB_ERR_CORRUPT, TDB_LOG_ERROR,
                                 "lock_and_alloc: %llu non-free 0x%llx",
                                 (long long)off, (long long)r->magic_and_prev);
                        goto unlock_err;
@@ -567,7 +567,7 @@ int set_header(struct tdb_context *tdb,
        if (rec_key_length(rec) != keylen
            || rec_data_length(rec) != datalen
            || rec_extra_padding(rec) != actuallen - (keylen + datalen)) {
-               tdb_logerr(tdb, TDB_ERR_IO, TDB_DEBUG_ERROR,
+               tdb_logerr(tdb, TDB_ERR_IO, TDB_LOG_ERROR,
                         "Could not encode k=%llu,d=%llu,a=%llu",
                         (long long)keylen, (long long)datalen,
                         (long long)actuallen);
@@ -588,7 +588,7 @@ static int tdb_expand(struct tdb_context *tdb, tdb_len_t size)
        /* Need to hold a hash lock to expand DB: transactions rely on it. */
        if (!(tdb->flags & TDB_NOLOCK)
            && !tdb->allrecord_lock.count && !tdb_has_hash_locks(tdb)) {
-               tdb_logerr(tdb, TDB_ERR_LOCK, TDB_DEBUG_ERROR,
+               tdb_logerr(tdb, TDB_ERR_LOCK, TDB_LOG_ERROR,
                           "tdb_expand: must hold lock during expand");
                return -1;
        }