X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Fsummary.c;h=4a22f2e56a9b20ff3cce4111cabbe386f18babd7;hb=20f3b260313fb4d5566aeb0d0c5439574e914e2d;hp=26cdd3e4fe2cbe7d171b0a190e11dc0148f0991a;hpb=63e80faf9b42fbe73e25c804dd734b6179e42c24;p=ccan diff --git a/ccan/tdb2/summary.c b/ccan/tdb2/summary.c index 26cdd3e4..4a22f2e5 100644 --- a/ccan/tdb2/summary.c +++ b/ccan/tdb2/summary.c @@ -28,7 +28,7 @@ static tdb_off_t count_hash(struct tdb_context *tdb, h = tdb_access_read(tdb, hash_off, sizeof(*h) << bits, true); if (TDB_PTR_IS_ERR(h)) { - return TDB_PTR_ERR(h); + return TDB_ERR_TO_OFF(TDB_PTR_ERR(h)); } for (i = 0; i < (1 << bits); i++) count += (h[i] != 0); @@ -93,7 +93,7 @@ static enum TDB_ERROR summarize(struct tdb_context *tdb, off + sizeof(p->u), TDB_SUBLEVEL_HASH_BITS); if (TDB_OFF_IS_ERR(count)) { - return count; + return TDB_OFF_TO_ERR(count); } tally_add(hashes, count); tally_add(extra, rec_extra_padding(&p->u)); @@ -115,7 +115,7 @@ static enum TDB_ERROR summarize(struct tdb_context *tdb, } else { len = dead_space(tdb, off); if (TDB_OFF_IS_ERR(len)) { - return len; + return TDB_OFF_TO_ERR(len); } } tdb_access_release(tdb, p); @@ -161,6 +161,14 @@ enum TDB_ERROR tdb_summary(struct tdb_context *tdb, char *hashesg, *freeg, *keysg, *datag, *extrag, *uncoalg; enum TDB_ERROR ecode; + if (tdb->flags & TDB_VERSION1) { + /* tdb1 doesn't do graphs. */ + *summary = tdb1_summary(tdb); + if (!*summary) + return tdb->last_error; + return TDB_SUCCESS; + } + hashesg = freeg = keysg = datag = extrag = uncoalg = NULL; ecode = tdb_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, false);