Do not write an empty main wbtree
@@ -834,7 +834,7 @@ static merr_t
kblock_finish(struct kblock_builder *bld, struct wbb *ptree)
{
struct bloom_hdr_omf blm_hdr;
- struct wbt_hdr_omf wbt_hdr;
+ struct wbt_hdr_omf wbt_hdr = { 0 };
struct wbt_hdr_omf pt_hdr = { 0 };
struct mblock_props mbprop;
@@ -885,6 +885,7 @@ kblock_finish(struct kblock_builder *bld, struct wbb *ptree)
/* Finalize the wbtree. May increase kblk->wbt_pgc. */
wbb_hdr_init(kblk->wbtree, &wbt_hdr);
+ if (kblk->wbtree && wbb_entries(kblk->wbtree)) {
err = wbb_freeze(
kblk->wbtree,
&wbt_hdr,
@@ -896,6 +897,9 @@ kblock_finish(struct kblock_builder *bld, struct wbb *ptree)
if (ev(err))
goto errout;
iov_cnt += i;
+ } else {
+ kblk->wbt_pgc = 0;
+ }
/* Finalize Bloom filter. */
err = _kblock_finish_bloom(kblk, &blm_hdr);
