ecksum: Limited NULL => not-ecksum to lfs3_gbmap_set_

This mostly reverts the previous commit, and makes non-NULL ecksums the
consistent API.

Non-NULL ecksums are what the original rbyd-level ecksum API expects,
and enforcing this avoids the ifdef mess required to minimize unused
code impact.

This unfortunately clutters up lfs3_gbmap_set_'s logic with NULL checks,
but at least keeps the mess constrained to lfs3_gbmap_set_.
lfs3_gbmap_set_ is really the only function that uses NULL ecksums, so
they should probably be lfs3_gbmap_set_'s problem to deal with.

Code changes:

                    code          stack          ctx
  before:          35144           2136          660
  after:           35144 (+0.0%)   2136 (+0.0%)  660 (+0.0%)

                    code          stack          ctx
  gbmap+np before: 38296           2144          776
  gbmap+np after:  38272 (-0.1%)   2144 (+0.0%)  776 (+0.0%)

                    code          stack          ctx
  gbmap+yp before: 38908           2168          796
  gbmap+yp after:  38940 (+0.1%)   2168 (+0.0%)  796 (+0.0%)
This commit is contained in:
Christopher Haster
2025-12-29 23:41:21 -06:00
parent 99d0e59589
commit 8de1903172
2 changed files with 38 additions and 45 deletions
+16 -16
View File
@@ -437,7 +437,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 5);
assert(weight_ == 6);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 6,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 6);
@@ -447,7 +447,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 7);
assert(weight_ == 1);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 8,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 8);
@@ -457,7 +457,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 9);
assert(weight_ == 1);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 10,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 10);
@@ -467,7 +467,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == BLOCK_COUNT-1);
assert(weight_ == BLOCK_COUNT-11);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_unmount(&lfs3) => 0;
'''
@@ -515,7 +515,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 5);
assert(weight_ == 6);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 6,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 6);
@@ -525,7 +525,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 7);
assert(weight_ == 1);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 8,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 8);
@@ -535,7 +535,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 9);
assert(weight_ == 1);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 10,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 10);
@@ -545,7 +545,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == BLOCK_COUNT-1);
assert(weight_ == BLOCK_COUNT-11);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_unmount(&lfs3) => 0;
'''
@@ -593,7 +593,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 4);
assert(weight_ == 5);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 5,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 6);
@@ -603,7 +603,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 7);
assert(weight_ == 1);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 8,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 10);
@@ -613,7 +613,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 11);
assert(weight_ == 1);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 12,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 13);
@@ -623,7 +623,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == BLOCK_COUNT-1);
assert(weight_ == BLOCK_COUNT-14);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_unmount(&lfs3) => 0;
'''
@@ -673,7 +673,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 4);
assert(weight_ == 5);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 5,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 5);
@@ -688,7 +688,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 7);
assert(weight_ == 1);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 8,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 8);
@@ -708,7 +708,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == 11);
assert(weight_ == 1);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_gbmap_lookupnext(&lfs3, &gbmap, 12,
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMERASED;
assert(bid_ == 12);
@@ -723,7 +723,7 @@ code = '''
&bid_, &weight_, &ecksum_) => LFS3_TAG_BMFREE;
assert(bid_ == BLOCK_COUNT-1);
assert(weight_ == BLOCK_COUNT-14);
assert(lfs3_ecksum_cmp(&ecksum_, NULL) == 0);
assert(!lfs3_ecksum_isecksum(&ecksum_));
lfs3_unmount(&lfs3) => 0;
'''