Implicitly set the rm-bit in generic grow tags
Our rbyds support changing the weight of a tag without knowing the actual tag. This is useful for btrees, which always make weight changes without knowing if the leading tag is a name or a branch (it depends on the type of btree). But to make this work, it needs the rm-bit to be set. This is because internally the rm-bit indicates we don't want to write-out a tag. Which we don't for grow tags, because, well, they're not real tags. Previously this was done by putting LFSR_TAG_GROW(RM) everywhere a generic grow as needed, but since this is so common we might as well just set the rm-bit in LFSR_TAG_GROW. Note that LFSR_TAG_GROW(tag) (the macro) does not set the rm-bit. This makes the code a bit more readable at the risk of an unintuitive relationship between LFSR_TAG_GROW and LFSR_TAG_GROW(tag).
This commit is contained in:
@@ -619,7 +619,7 @@ enum lfsr_tag_type {
|
||||
// some tag modifiers
|
||||
// in-device only
|
||||
LFSR_TAG_WIDE = 0x4000,
|
||||
LFSR_TAG_GROW = 0x2000,
|
||||
LFSR_TAG_GROW = 0x3000, // note generic grows need the rm-bit
|
||||
LFSR_TAG_RM = 0x1000,
|
||||
|
||||
// in-device only
|
||||
@@ -632,8 +632,9 @@ enum lfsr_tag_type {
|
||||
|
||||
// some tag modifiers
|
||||
#define LFSR_TAG_WIDE(tag) (LFSR_TAG_WIDE | LFSR_TAG_##tag)
|
||||
#define LFSR_TAG_GROW(tag) (LFSR_TAG_GROW | LFSR_TAG_##tag)
|
||||
#define LFSR_TAG_RM(tag) (LFSR_TAG_RM | LFSR_TAG_##tag)
|
||||
// if we're growing an explict tag, we don't need the rm-bit
|
||||
#define LFSR_TAG_GROW(tag) ((LFSR_TAG_GROW & ~LFSR_TAG_RM) | LFSR_TAG_##tag)
|
||||
#define LFSR_TAG_RM(tag) (LFSR_TAG_RM | LFSR_TAG_##tag)
|
||||
|
||||
// some other tag encodings with their own subfields
|
||||
#define LFSR_TAG_ALT(d, c, key) \
|
||||
@@ -4090,7 +4091,7 @@ static int lfsr_btree_commit(lfs_t *lfs, lfsr_btree_t *btree,
|
||||
bid+rid, BRANCH, 0,
|
||||
BUF(scratch_buf, scratch_dsize));
|
||||
scratch_attrs[1] = LFSR_ATTR(
|
||||
bid+rid, GROW(RM), -rbyd.weight + rbyd_.weight,
|
||||
bid+rid, GROW, -rbyd.weight + rbyd_.weight,
|
||||
NULL);
|
||||
attrs = scratch_attrs;
|
||||
attr_count = 2;
|
||||
@@ -4228,7 +4229,7 @@ static int lfsr_btree_commit(lfs_t *lfs, lfsr_btree_t *btree,
|
||||
bid+rid, BRANCH, 0,
|
||||
BUF(scratch1_buf, scratch1_dsize));
|
||||
scratch_attrs[1] = LFSR_ATTR(
|
||||
bid+rid, GROW(RM), -rbyd.weight + rbyd_.weight,
|
||||
bid+rid, GROW, -rbyd.weight + rbyd_.weight,
|
||||
NULL);
|
||||
}
|
||||
scratch_attrs[2] = LFSR_ATTR(
|
||||
@@ -4333,7 +4334,7 @@ static int lfsr_btree_commit(lfs_t *lfs, lfsr_btree_t *btree,
|
||||
bid+rid, BRANCH, 0,
|
||||
BUF(scratch_buf, scratch_dsize));
|
||||
scratch_attrs[2] = LFSR_ATTR(
|
||||
bid+rid, GROW(RM), -rbyd.weight + rbyd_.weight,
|
||||
bid+rid, GROW, -rbyd.weight + rbyd_.weight,
|
||||
NULL);
|
||||
attrs = scratch_attrs;
|
||||
attr_count = 3;
|
||||
|
||||
Reference in New Issue
Block a user