Some small tweaks
- Updated LFSR_BTREE_INLINESIZE to properly include the overhead for mdir pointers, which need 2 block addresses instead of 1. This adds 4 bytes to the lfsr_btree_t struct. - Changed code that marks rbyds as "needing compaction" to use -1 instead of block_size. This can use a cheaper constant and helps debugging. - Changed the mid representation of root to 0.0 from ?.-1. The mid 0.0 is always reserved for the roots dstart, so it shouldn't be used for any actual file. This disambiguates root vs special metadata mids and is a step towards making mids unsigned. It also saves a tiny bit of code since 0 comparisons are generally cheaper and we can leverage the order-preserving conversion of mid to an integer.
This commit is contained in:
@@ -52,6 +52,11 @@ typedef int16_t lfsr_smbid_t;
|
||||
typedef uint16_t lfsr_mrid_t;
|
||||
typedef int16_t lfsr_smrid_t;
|
||||
|
||||
typedef struct lfsr_mid {
|
||||
lfsr_smbid_t bid;
|
||||
lfsr_smrid_t rid;
|
||||
} lfsr_mid_t;
|
||||
|
||||
// Maximum name size in bytes, may be redefined to reduce the size of the
|
||||
// info struct. Limited to <= 1022. Stored in superblock and must be
|
||||
// respected by other littlefs drivers.
|
||||
@@ -342,8 +347,8 @@ typedef struct lfsr_rbyd {
|
||||
// off=0, trunk=0 => not yet committed
|
||||
// off=0, trunk>0 => not yet fetched
|
||||
// off=block_size => rbyd not erased/needs compaction
|
||||
lfs_off_t off;
|
||||
lfs_off_t trunk;
|
||||
lfs_off_t off;
|
||||
uint32_t crc;
|
||||
} lfsr_rbyd_t;
|
||||
|
||||
@@ -353,7 +358,8 @@ typedef struct lfsr_rbyd {
|
||||
//
|
||||
// Pointers we store:
|
||||
// - block addresses => 1 leb128 => 5 bytes (worst case)
|
||||
#define LFSR_BTREE_INLINESIZE 5
|
||||
// - mdir addresses => 2 leb128 => 10 bytes (worst case)
|
||||
#define LFSR_BTREE_INLINESIZE 10
|
||||
|
||||
typedef union lfsr_btree {
|
||||
// note this lines up with weight in lfsr_rbyd_t
|
||||
@@ -373,11 +379,6 @@ typedef union lfsr_btree {
|
||||
} inlined;
|
||||
} lfsr_btree_t;
|
||||
|
||||
typedef struct lfsr_mid {
|
||||
lfsr_smbid_t bid;
|
||||
lfsr_smrid_t rid;
|
||||
} lfsr_mid_t;
|
||||
|
||||
typedef struct lfsr_mdir {
|
||||
lfsr_mid_t mid;
|
||||
struct {
|
||||
|
||||
Reference in New Issue
Block a user