ckparity: Tweaked some comments
The main one being the lfsr_bd_readnext comment. lfsr_bd_readnext _can_ provide checked reads as long as we read the suffix first and use some crc32c xor tricks: 1. Calculate c_s = crc32c(suffix) 2. Calculate c_p = crc32c(prefix) 3. Calculate c_d = crc32c(c_p, data) 4. Calculate crc = crc32c(c_d, suffix-sized zeros) xor c_s There's probably some funny business with the init/fini xor, but you get the idea. Conveniently, we just never need to use a hypothetical lfsr_bd_readnextck. I was toying around with the idea of using lfsr_bd_readnextck to provide better caching in the case our rcache is big (~= block_size), but it was getting overly-complicated/problematic, so I'm dropping the idea for now.
This commit is contained in:
@@ -121,9 +121,6 @@ static inline void lfsr_bd_droppcache(lfs_t *lfs) {
|
|||||||
|
|
||||||
// caching read that lends you a buffer
|
// caching read that lends you a buffer
|
||||||
//
|
//
|
||||||
// this fundamentally can't provide checked reads, so we really should
|
|
||||||
// only use it to build other low-level bd functions
|
|
||||||
//
|
|
||||||
// note hint has two conveniences:
|
// note hint has two conveniences:
|
||||||
// 0 => minimal caching
|
// 0 => minimal caching
|
||||||
// -1 => maximal caching
|
// -1 => maximal caching
|
||||||
@@ -704,6 +701,7 @@ static int lfsr_bd_set(lfs_t *lfs, lfs_block_t block, lfs_size_t off,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// lfsr_ck_t stuff ///
|
/// lfsr_ck_t stuff ///
|
||||||
|
|
||||||
#ifdef LFS_CKPARITY
|
#ifdef LFS_CKPARITY
|
||||||
@@ -753,6 +751,7 @@ static inline lfs_size_t lfsr_ck_ckoff(lfsr_ck_t ck) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// lfsr_tailck_t stuff
|
// lfsr_tailck_t stuff
|
||||||
//
|
//
|
||||||
// tailck tracks the most recent trunk's parity so we can parity-check
|
// tailck tracks the most recent trunk's parity so we can parity-check
|
||||||
@@ -784,9 +783,9 @@ static lfs_sbool_t lfsr_bd_readparity(lfs_t *lfs,
|
|||||||
|
|
||||||
// _usually_, the byte following a tag contains the tag's parity
|
// _usually_, the byte following a tag contains the tag's parity
|
||||||
//
|
//
|
||||||
// but if we're in the middle of building a commit things get
|
// unless we're in the middle of building a commit, where things get
|
||||||
// tricky since we may not have written this bit yet... this is why
|
// tricky... to avoid problems with not-yet-written parity bits
|
||||||
// tailck exists, to track the most recent trunk's parity
|
// tailck tracks the most recent trunk's parity
|
||||||
//
|
//
|
||||||
|
|
||||||
// parity in in tailck?
|
// parity in in tailck?
|
||||||
@@ -808,6 +807,9 @@ static lfs_sbool_t lfsr_bd_readparity(lfs_t *lfs,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// checked read functions
|
||||||
|
|
||||||
#ifdef LFS_CKPARITY
|
#ifdef LFS_CKPARITY
|
||||||
static lfs_ssize_t lfsr_bd_ckprefix(lfs_t *lfs,
|
static lfs_ssize_t lfsr_bd_ckprefix(lfs_t *lfs,
|
||||||
lfs_block_t block, lfs_size_t off, lfs_size_t hint,
|
lfs_block_t block, lfs_size_t off, lfs_size_t hint,
|
||||||
|
|||||||
Reference in New Issue
Block a user