From 27e3e10634f893d2126b34e1580e0560d3ac4985 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 30 Jul 2025 11:44:36 -0500 Subject: [PATCH] bmap: Added error propagation to ckpoints and cleaned up test TODOs The main change is error propagation in lfs3_alloc_ckpoint. Since lfs3_alloc_ckpoint writes to disk during bmap rebuilds, it can now fail in all sorts of ways. Fortunately lfs3_alloc_ckpoint should only ever be called by write operations, where these errors are be expected. With bmap rebuild errors now reported correctly, this unblocks most of the remaining test TODOs: - Passing test_badblocks - Passing test_ck - Passing test_trvs With this, LFS3_YES_BMAP is now passing all but two tests, which are still ifndef-disabled as a temporary measure: - test_btree - We make some low-level assumptions about the lookahead allocator when testing btrees. It's probably not worth trying to get this passing with the bmap allocator. - test_grow - This one does need fixing! We currently don't update on-disk bmaps correctly when growing the filesystem. Code changes minimal: code stack ctx before: 36912 2368 684 after: 36912 (+0.0%) 2368 (+0.0%) 684 (+0.0%) code stack ctx bmap before: 38456 2400 812 bmap after: 38512 (+0.1%) 2400 (+0.0%) 812 (+0.0%) --- lfs3.c | 172 ++++++++++---- tests/test_alloc.toml | 14 +- tests/test_badblocks.toml | 73 +++--- tests/test_ck.toml | 23 +- tests/test_grow.toml | 2 +- tests/test_trvs.toml | 468 ++++++++++++++++++++++++++++++++------ 6 files changed, 580 insertions(+), 172 deletions(-) diff --git a/lfs3.c b/lfs3.c index 5936b1d5..dd5b57fd 100644 --- a/lfs3.c +++ b/lfs3.c @@ -2380,7 +2380,7 @@ static inline bool lfs3_alloc_iserase(uint32_t flags) { // blocks are allocated at most once, and never reallocated, between // checkpoints #if !defined(LFS3_RDONLY) -static inline void lfs3_alloc_ckpoint(lfs3_t *lfs3); +static inline int lfs3_alloc_ckpoint(lfs3_t *lfs3); #endif // discard any lookahead state, this is necessary if block_count changes @@ -10494,7 +10494,11 @@ dropped:; : lfs3->cfg->block_size - lfs3->cfg->block_size/8); // checkpoint the allocator - lfs3_alloc_ckpoint(lfs3); + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // compact the mdir err = lfs3_mdir_compact(lfs3, mdir); if (err) { @@ -10810,7 +10814,7 @@ static int lfs3_alloc_rebuildbmap(lfs3_t *lfs3); // blocks are allocated at most once, and never reallocated, between // checkpoints #if !defined(LFS3_RDONLY) -static inline void lfs3_alloc_ckpoint(lfs3_t *lfs3) { +static inline int lfs3_alloc_ckpoint(lfs3_t *lfs3) { #ifndef LFS3_2BONLY // checkpoint the allocator lfs3->lookahead.ckpoint = lfs3->block_count; @@ -10820,14 +10824,15 @@ static inline void lfs3_alloc_ckpoint(lfs3_t *lfs3) { lfs3->cfg->bmap_scan_thresh, lfs3->block_count)) { int err = lfs3_alloc_rebuildbmap(lfs3); - // TODO lfs3_alloc_ckpoint should propagate errors - LFS3_ASSERT(!err); -// // checkpoint the allocator again after rebuilding the bmap -// lfs3->lookahead.ckpoint = lfs3->block_count; + if (err) { + return err; + } } #endif + return 0; #else (void)lfs3; + return 0; #endif } #endif @@ -11477,8 +11482,13 @@ int lfs3_mkdir(lfs3_t *lfs3, const char *path) { // This is done automatically by lfs3_mdir_commit to avoid issues with // mid updates, since the mid technically doesn't exist yet... + // checkpoint the allocator + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // commit our bookmark and a grm to self-remove in case of powerloss - lfs3_alloc_ckpoint(lfs3); err = lfs3_mdir_commit(lfs3, &mdir, LFS3_RATTRS( LFS3_RATTR_NAME( LFS3_TAG_BOOKMARK, +1, did_, NULL, 0), @@ -11500,10 +11510,15 @@ int lfs3_mkdir(lfs3_t *lfs3, const char *path) { ? tag_ >= 0 : tag_ == LFS3_ERR_NOENT); + // checkpoint the allocator + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // commit our new directory into our parent, zeroing the grm in the // process lfs3_grm_pop(lfs3); - lfs3_alloc_ckpoint(lfs3); err = lfs3_mdir_commit(lfs3, &mdir, LFS3_RATTRS( LFS3_RATTR_NAME( LFS3_TAG_MASK12 | LFS3_TAG_DIR, @@ -11648,8 +11663,13 @@ int lfs3_remove(lfs3_t *lfs3, const char *path) { // are we removing an opened file? bool zombie = lfs3_mid_isopen(lfs3, mdir.mid, -1); + // checkpoint the allocator + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // remove the metadata entry - lfs3_alloc_ckpoint(lfs3); err = lfs3_mdir_commit(lfs3, &mdir, LFS3_RATTRS( // create a stickynote if zombied // @@ -11828,9 +11848,14 @@ int lfs3_rename(lfs3_t *lfs3, const char *old_path, const char *new_path) { // mark old entry for removal with a grm lfs3_grm_push(lfs3, old_mdir.mid); + // checkpoint the allocator + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // rename our entry, copying all tags associated with the old rid to the // new rid, while also marking the old rid for removal - lfs3_alloc_ckpoint(lfs3); err = lfs3_mdir_commit(lfs3, &new_mdir, LFS3_RATTRS( LFS3_RATTR_NAME( LFS3_TAG_MASK12 | old_tag, @@ -12269,8 +12294,13 @@ int lfs3_setattr(lfs3_t *lfs3, const char *path, uint8_t type, return err; } + // checkpoint the allocator + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // commit our attr - lfs3_alloc_ckpoint(lfs3); err = lfs3_mdir_commit(lfs3, &mdir, LFS3_RATTRS( LFS3_RATTR_DATA( LFS3_TAG_ATTR(type), 0, @@ -12325,8 +12355,13 @@ int lfs3_removeattr(lfs3_t *lfs3, const char *path, uint8_t type) { return err; } + // checkpoint the allocator + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // commit our removal - lfs3_alloc_ckpoint(lfs3); err = lfs3_mdir_commit(lfs3, &mdir, LFS3_RATTRS( LFS3_RATTR( LFS3_TAG_RM | LFS3_TAG_ATTR(type), 0))); @@ -12623,9 +12658,14 @@ int lfs3_file_opencfg_(lfs3_t *lfs3, lfs3_file_t *file, } } else { + // checkpoint the allocator + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // create a stickynote entry if we don't have one, this // reserves the mid until first sync - lfs3_alloc_ckpoint(lfs3); err = lfs3_mdir_commit(lfs3, &file->b.h.mdir, LFS3_RATTRS( LFS3_RATTR_NAME( LFS3_TAG_STICKYNOTE, +1, @@ -13578,9 +13618,13 @@ static int lfs3_file_crystallize(lfs3_t *lfs3, lfs3_file_t *file) { LFS3_ASSERT(lfs3_o_isunsync(file->b.h.flags)); // checkpoint the allocator - lfs3_alloc_ckpoint(lfs3); + int err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // finish crystallizing - int err = lfs3_file_crystallize_(lfs3, file, + err = lfs3_file_crystallize_(lfs3, file, file->leaf.pos - lfs3_bptr_off(&file->leaf.bptr), -1, -1, 0, NULL, 0); if (err) { @@ -13600,7 +13644,10 @@ static int lfs3_file_flushset_(lfs3_t *lfs3, lfs3_file_t *file, lfs3_off_t pos = 0; while (size > 0) { // checkpoint the allocator - lfs3_alloc_ckpoint(lfs3); + int err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } // enough data for a block? #ifndef LFS3_2BONLY @@ -13619,7 +13666,7 @@ static int lfs3_file_flushset_(lfs3_t *lfs3, lfs3_file_t *file, // write our data uint32_t cksum = 0; - int err = lfs3_bd_prog(lfs3, block, 0, buffer, d, + err = lfs3_bd_prog(lfs3, block, 0, buffer, d, &cksum, true); if (err) { // bad prog? try another block @@ -13665,7 +13712,7 @@ static int lfs3_file_flushset_(lfs3_t *lfs3, lfs3_file_t *file, lfs3_ssize_t d = lfs3_min(size, lfs3->cfg->fragment_size); // commit to bshrub/btree - int err = lfs3_file_commit(lfs3, file, pos, LFS3_RATTRS( + err = lfs3_file_commit(lfs3, file, pos, LFS3_RATTRS( LFS3_RATTR_DATA( LFS3_TAG_DATA, +d, &LFS3_DATA_BUF(buffer, d)))); @@ -13700,7 +13747,10 @@ static int lfs3_file_flush_(lfs3_t *lfs3, lfs3_file_t *file, #ifndef LFS3_2BONLY while (size > 0) { // checkpoint the allocator - lfs3_alloc_ckpoint(lfs3); + int err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } // mid-crystallization? can we just resume crystallizing? // @@ -13721,7 +13771,7 @@ static int lfs3_file_flush_(lfs3_t *lfs3, lfs3_file_t *file, // mark as uncrystallized file->b.h.flags |= LFS3_o_UNCRYST; // crystallize - int err = lfs3_file_crystallize_(lfs3, file, + err = lfs3_file_crystallize_(lfs3, file, block_start, -1, (pos + size) - block_start, pos, buffer, size); if (err) { @@ -13769,7 +13819,7 @@ static int lfs3_file_flush_(lfs3_t *lfs3, lfs3_file_t *file, lfs3_bid_t bid; lfs3_bid_t weight; lfs3_bptr_t bptr; - int err = lfs3_file_lookupnext(lfs3, file, poke, + err = lfs3_file_lookupnext(lfs3, file, poke, &bid, &weight, &bptr); if (err) { LFS3_ASSERT(err != LFS3_ERR_NOENT); @@ -13802,7 +13852,7 @@ static int lfs3_file_flush_(lfs3_t *lfs3, lfs3_file_t *file, lfs3_bid_t bid; lfs3_bid_t weight; lfs3_bptr_t bptr; - int err = lfs3_file_lookupnext(lfs3, file, poke, + err = lfs3_file_lookupnext(lfs3, file, poke, &bid, &weight, &bptr); if (err) { LFS3_ASSERT(err != LFS3_ERR_NOENT); @@ -13850,7 +13900,7 @@ static int lfs3_file_flush_(lfs3_t *lfs3, lfs3_file_t *file, // mark as uncrystallized file->b.h.flags |= LFS3_o_UNCRYST; // crystallize - int err = lfs3_file_crystallize_(lfs3, file, + err = lfs3_file_crystallize_(lfs3, file, block_start, -1, crystal_end - block_start, pos, buffer, size); if (err) { @@ -13874,7 +13924,7 @@ static int lfs3_file_flush_(lfs3_t *lfs3, lfs3_file_t *file, // and graft it into our bshrub/btree if (lfs3_o_isuncryst(file->b.h.flags)) { // finish crystallizing - int err = lfs3_file_crystallize_(lfs3, file, + err = lfs3_file_crystallize_(lfs3, file, file->leaf.pos - lfs3_bptr_off(&file->leaf.bptr), -1, -1, 0, NULL, 0); if (err) { @@ -13895,7 +13945,7 @@ static int lfs3_file_flush_(lfs3_t *lfs3, lfs3_file_t *file, lfs3_bid_t bid; lfs3_bid_t weight; lfs3_bptr_t bptr; - int err = lfs3_file_lookupnext(lfs3, file, + err = lfs3_file_lookupnext(lfs3, file, lfs3_min( crystal_start-1, file->b.shrub.r.weight-1), @@ -13923,7 +13973,7 @@ static int lfs3_file_flush_(lfs3_t *lfs3, lfs3_file_t *file, // start crystallizing! // // lfs3_file_crystallize_ handles block allocation/relocation - int err = lfs3_file_crystallize_(lfs3, file, + err = lfs3_file_crystallize_(lfs3, file, crystal_start, -1, crystal_end - crystal_start, pos, buffer, size); if (err) { @@ -13949,7 +13999,10 @@ fragment:; // iteratively write fragments (inlined leaves) while (size > 0) { // checkpoint the allocator - lfs3_alloc_ckpoint(lfs3); + int err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } // do we need to discard our leaf? we need to discard fragments // in case the underlying rbyd compacts, and we need to discard @@ -13986,7 +14039,7 @@ fragment:; lfs3_bid_t bid; lfs3_bid_t weight; lfs3_bptr_t bptr; - int err = lfs3_file_lookupnext(lfs3, file, + err = lfs3_file_lookupnext(lfs3, file, fragment_start-1, &bid, &weight, &bptr); if (err) { @@ -14020,7 +14073,7 @@ fragment:; lfs3_bid_t bid; lfs3_bid_t weight; lfs3_bptr_t bptr; - int err = lfs3_file_lookupnext(lfs3, file, + err = lfs3_file_lookupnext(lfs3, file, fragment_end, &bid, &weight, &bptr); if (err) { @@ -14046,7 +14099,7 @@ fragment:; // once we've figured out what fragment to write, graft it into // our tree - int err = lfs3_file_graft_(lfs3, file, + err = lfs3_file_graft_(lfs3, file, fragment_start, fragment_end - fragment_start, 0, datas, data_count); if (err) { @@ -14446,10 +14499,15 @@ static int lfs3_file_sync_(lfs3_t *lfs3, lfs3_file_t *file, if (rattr_count > 0) { // make sure we don't overflow our rattr buffer LFS3_ASSERT(rattr_count <= sizeof(rattrs)/sizeof(lfs3_rattr_t)); + // checkpoint the allocator - lfs3_alloc_ckpoint(lfs3); + int err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // and commit! - int err = lfs3_mdir_commit(lfs3, &file->b.h.mdir, + err = lfs3_mdir_commit(lfs3, &file->b.h.mdir, rattrs, rattr_count); if (err) { return err; @@ -14743,7 +14801,11 @@ int lfs3_file_truncate(lfs3_t *lfs3, lfs3_file_t *file, lfs3_off_t size_) { file->b.h.flags |= LFS3_o_UNSYNC; // checkpoint the allocator - lfs3_alloc_ckpoint(lfs3); + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // truncate our btree err = lfs3_file_graft_(lfs3, file, lfs3_min(size, size_), size - lfs3_min(size, size_), @@ -14825,7 +14887,11 @@ int lfs3_file_fruncate(lfs3_t *lfs3, lfs3_file_t *file, lfs3_off_t size_) { file->b.h.flags |= LFS3_o_UNSYNC; // checkpoint the allocator - lfs3_alloc_ckpoint(lfs3); + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // fruncate our btree err = lfs3_file_graft_(lfs3, file, 0, lfs3_smax(size - size_, 0), @@ -16197,6 +16263,10 @@ static int lfs3_formatbmap(lfs3_t *lfs3) { #endif // TODO should we try multiple blocks? + // + // TODO if we try multiple blocks we should update test_badblocks + // to test block 3 when bmap is present + // // assume we can write bmap to block 2 lfs3->gbmap.window = 3; lfs3->gbmap.known = lfs3->cfg->block_count; @@ -16562,8 +16632,13 @@ static int lfs3_fs_fixgrm(lfs3_t *lfs3) { // mark grm as taken care of lfs3_grm_pop(lfs3); + // checkpoint the allocator - lfs3_alloc_ckpoint(lfs3); + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // remove the rid while atomically updating our grm err = lfs3_mdir_commit(lfs3, &mdir, LFS3_RATTRS( LFS3_RATTR(LFS3_TAG_RM, -1))); @@ -16616,7 +16691,11 @@ static int lfs3_mdir_mkconsistent(lfs3_t *lfs3, lfs3_mdir_t *mdir) { lfs3_dbgmrid(lfs3, mdir->mid)); // checkpoint the allocator - lfs3_alloc_ckpoint(lfs3); + err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // remove the orphaned stickynote err = lfs3_mdir_commit(lfs3, mdir, LFS3_RATTRS( LFS3_RATTR(LFS3_TAG_RM, -1))); @@ -16769,7 +16848,10 @@ static int lfs3_fs_gc_(lfs3_t *lfs3, lfs3_trv_t *trv, while (pending && (lfs3_off_t)steps > 0) { // checkpoint the allocator to maximize any lookahead scans #ifndef LFS3_RDONLY - lfs3_alloc_ckpoint(lfs3); + int err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } #endif // start a new traversal? @@ -16908,9 +16990,14 @@ int lfs3_fs_grow(lfs3_t *lfs3, lfs3_size_t block_count_) { // discard stale lookahead buffer lfs3_alloc_discard(lfs3); + // checkpoint the allocator + int err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } + // update our on-disk config - lfs3_alloc_ckpoint(lfs3); - int err = lfs3_mdir_commit(lfs3, &lfs3->mroot, LFS3_RATTRS( + err = lfs3_mdir_commit(lfs3, &lfs3->mroot, LFS3_RATTRS( LFS3_RATTR_GEOMETRY( LFS3_TAG_GEOMETRY, 0, (&(lfs3_geometry_t){ @@ -17008,7 +17095,10 @@ int lfs3_trv_read(lfs3_t *lfs3, lfs3_trv_t *trv, // checkpoint the allocator to maximize any lookahead scans #ifndef LFS3_RDONLY - lfs3_alloc_ckpoint(lfs3); + int err = lfs3_alloc_ckpoint(lfs3); + if (err) { + return err; + } #endif while (true) { diff --git a/tests/test_alloc.toml b/tests/test_alloc.toml index 69ac589f..a96a3fda 100644 --- a/tests/test_alloc.toml +++ b/tests/test_alloc.toml @@ -9,11 +9,7 @@ # after = ['test_mtree', 'test_bmap', 'test_dirs', 'test_files'] -# TODO should we rename these to test_lookahead? -# TODO or extend to test the bmap as well? -# -# these are really tuned to test the lookahead allocator -#ifndef = 'LFS3_BMAP' +defines.INIT_BLOCKS = 'LFS3_IFDEF_BMAP(3, 2)' # test that we can alloc [cases.test_alloc_alloc] @@ -26,7 +22,7 @@ defines.COUNT = [ '2', ] defines.ERASE = [false, true] -if = 'COUNT >= LFS3_IFDEF_BMAP(3, 2)' +if = 'COUNT >= INIT_BLOCKS' in = 'lfs3.c' code = ''' // test various block counts @@ -73,7 +69,7 @@ defines.COUNT = [ '2', ] defines.ERASE = [false, true] -if = 'COUNT >= LFS3_IFDEF_BMAP(3, 2)' +if = 'COUNT >= INIT_BLOCKS' in = 'lfs3.c' code = ''' // test various block counts @@ -659,7 +655,7 @@ defines.COUNT = [ '5', '2', ] -if = 'COUNT >= LFS3_IFDEF_BMAP(3, 2)' +if = 'COUNT >= INIT_BLOCKS' code = ''' // test various block counts struct lfs3_cfg cfg = *CFG; @@ -742,7 +738,7 @@ defines.SIZE = [ '2*BLOCK_SIZE', '8*BLOCK_SIZE', ] -if = 'COUNT >= LFS3_IFDEF_BMAP(3, 2)' +if = 'COUNT >= INIT_BLOCKS' code = ''' // test various block counts struct lfs3_cfg cfg = *CFG; diff --git a/tests/test_badblocks.toml b/tests/test_badblocks.toml index 16b79f06..43cd3179 100644 --- a/tests/test_badblocks.toml +++ b/tests/test_badblocks.toml @@ -11,8 +11,7 @@ after = [ 'test_compat', ] -# TODO bmap workaround? -ifndef = 'LFS3_BMAP' +defines.INIT_BLOCKS = 'LFS3_IFDEF_BMAP(3, 2)' ## Single-block badblock tests @@ -150,7 +149,7 @@ defines.N = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512] if = 'LFS3_IFDEF_CKPROGS(true, !CKPROGS)' code = ''' // test all possible bad blocks - for (lfs3_size_t i = 2; + for (lfs3_size_t i = INIT_BLOCKS; i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1); i++) { lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; @@ -268,7 +267,7 @@ fuzz = 'SEED' if = 'LFS3_IFDEF_CKPROGS(true, !CKPROGS)' code = ''' // test all possible bad blocks - for (lfs3_size_t i = 2; + for (lfs3_size_t i = INIT_BLOCKS; i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1); i++) { lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; @@ -463,7 +462,7 @@ if = [ ] code = ''' // test all possible bad blocks - for (lfs3_size_t i = 2; + for (lfs3_size_t i = INIT_BLOCKS; i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1); i++) { lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; @@ -577,7 +576,7 @@ if = [ ] code = ''' // test all possible bad blocks - for (lfs3_size_t i = 2; + for (lfs3_size_t i = INIT_BLOCKS; i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1); i++) { lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; @@ -834,7 +833,7 @@ if = [ ] code = ''' // test all possible bad blocks - for (lfs3_size_t i = 2; + for (lfs3_size_t i = INIT_BLOCKS; i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1); i++) { lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; @@ -997,7 +996,7 @@ if = [ ] code = ''' // test all possible bad blocks - for (lfs3_size_t i = 2; + for (lfs3_size_t i = INIT_BLOCKS; i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1); i++) { lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; @@ -1449,7 +1448,7 @@ if = [ ] code = ''' // test all possible bad blocks - for (lfs3_size_t i = 2; + for (lfs3_size_t i = INIT_BLOCKS; i < ((BADBLOCK == -1) ? BLOCK_COUNT : 1); i++) { lfs3_size_t badblock = (BADBLOCK == -1) ? i : BADBLOCK; @@ -2104,11 +2103,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (i >= 2) { + if (i >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i) => 0; } } else { - if (i+BLOCK_COUNT/2 >= 2) { + if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; } } @@ -2223,11 +2222,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (i >= 2) { + if (i >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i) => 0; } } else { - if (i+BLOCK_COUNT/2 >= 2) { + if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; } } @@ -2419,11 +2418,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (i >= 2) { + if (i >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i) => 0; } } else { - if (i+BLOCK_COUNT/2 >= 2) { + if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; } } @@ -2534,11 +2533,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (i >= 2) { + if (i >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i) => 0; } } else { - if (i+BLOCK_COUNT/2 >= 2) { + if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; } } @@ -2792,11 +2791,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (i >= 2) { + if (i >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i) => 0; } } else { - if (i+BLOCK_COUNT/2 >= 2) { + if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; } } @@ -2956,11 +2955,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (i >= 2) { + if (i >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i) => 0; } } else { - if (i+BLOCK_COUNT/2 >= 2) { + if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; } } @@ -3409,11 +3408,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (i >= 2) { + if (i >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i) => 0; } } else { - if (i+BLOCK_COUNT/2 >= 2) { + if (i+BLOCK_COUNT/2 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, i+BLOCK_COUNT/2) => 0; } } @@ -4061,11 +4060,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (2*i+0 >= 2) { + if (2*i+0 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+0) => 0; } } else { - if (2*i+1 >= 2) { + if (2*i+1 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+1) => 0; } } @@ -4180,11 +4179,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (2*i+0 >= 2) { + if (2*i+0 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+0) => 0; } } else { - if (2*i+1 >= 2) { + if (2*i+1 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+1) => 0; } } @@ -4376,11 +4375,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (2*i+0 >= 2) { + if (2*i+0 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+0) => 0; } } else { - if (2*i+1 >= 2) { + if (2*i+1 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+1) => 0; } } @@ -4491,11 +4490,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (2*i+0 >= 2) { + if (2*i+0 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+0) => 0; } } else { - if (2*i+1 >= 2) { + if (2*i+1 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+1) => 0; } } @@ -4749,11 +4748,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (2*i+0 >= 2) { + if (2*i+0 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+0) => 0; } } else { - if (2*i+1 >= 2) { + if (2*i+1 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+1) => 0; } } @@ -4911,11 +4910,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (2*i+0 >= 2) { + if (2*i+0 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+0) => 0; } } else { - if (2*i+1 >= 2) { + if (2*i+1 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+1) => 0; } } @@ -5364,11 +5363,11 @@ code = ''' for (lfs3_size_t i = 0; i < BLOCK_COUNT/2; i++) { // mark our badblock as bad if (!MIRROR) { - if (2*i+0 >= 2) { + if (2*i+0 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+0) => 0; } } else { - if (2*i+1 >= 2) { + if (2*i+1 >= INIT_BLOCKS) { lfs3_emubd_markbad(CFG, 2*i+1) => 0; } } diff --git a/tests/test_ck.toml b/tests/test_ck.toml index 695bedcf..53a0e0e3 100644 --- a/tests/test_ck.toml +++ b/tests/test_ck.toml @@ -1,9 +1,6 @@ # Test checksum validation things after = ['test_trvs', 'test_gc', 'test_mount'] -# TODO bmap workaround? -ifndef = 'LFS3_BMAP' - code = ''' // naive crc32c @@ -988,6 +985,7 @@ defines.SIZE = [ '2*BLOCK_SIZE', '8*BLOCK_SIZE', ] +in = 'lfs3.c' code = ''' for (lfs3_block_t i = 0;; i++) { // a bit hacky, but this catches infinite loops @@ -1026,7 +1024,8 @@ code = ''' goto done; } - if (tinfo.btype == LFS3_BTYPE_BTREE) { + if (tinfo.btype == LFS3_BTYPE_BTREE + && lfs3_t_tstate(trv.b.h.flags) != LFS3_TSTATE_BMAP) { if (k == i) { // clobber this block printf("clobbering 0x%x\n", tinfo.block); @@ -1085,6 +1084,7 @@ defines.SIZE = [ '2*BLOCK_SIZE', '8*BLOCK_SIZE', ] +in = 'lfs3.c' code = ''' for (lfs3_block_t i = 0;; i++) { // a bit hacky, but this catches infinite loops @@ -1123,8 +1123,9 @@ code = ''' goto done; } - if (tinfo.btype == LFS3_BTYPE_BTREE - || tinfo.btype == LFS3_BTYPE_DATA) { + if ((tinfo.btype == LFS3_BTYPE_BTREE + || tinfo.btype == LFS3_BTYPE_DATA) + && lfs3_t_tstate(trv.b.h.flags) != LFS3_TSTATE_BMAP) { if (k == i) { // clobber this block printf("clobbering 0x%x\n", tinfo.block); @@ -1188,6 +1189,7 @@ defines.SIZE = [ defines.SEED = 42 defines.M = 100 fuzz = 'SEED' +in = 'lfs3.c' code = ''' uint32_t prng_ = SEED; for (lfs3_block_t i = 0;; i++) { @@ -1228,7 +1230,8 @@ code = ''' goto done; } - if (tinfo.btype == LFS3_BTYPE_BTREE) { + if (tinfo.btype == LFS3_BTYPE_BTREE + && lfs3_t_tstate(trv.b.h.flags) != LFS3_TSTATE_BMAP) { // found an interesting block? if (k == i) { badblock = tinfo.block; @@ -1336,6 +1339,7 @@ defines.SIZE = [ defines.SEED = 42 defines.M = 100 fuzz = 'SEED' +in = 'lfs3.c' code = ''' uint32_t prng_ = SEED; for (lfs3_block_t i = 0;; i++) { @@ -1376,8 +1380,9 @@ code = ''' goto done; } - if (tinfo.btype == LFS3_BTYPE_BTREE - || tinfo.btype == LFS3_BTYPE_DATA) { + if ((tinfo.btype == LFS3_BTYPE_BTREE + || tinfo.btype == LFS3_BTYPE_DATA) + && lfs3_t_tstate(trv.b.h.flags) != LFS3_TSTATE_BMAP) { // found an interesting block? if (k == i) { badblock = tinfo.block; diff --git a/tests/test_grow.toml b/tests/test_grow.toml index 9efffc93..af89a42f 100644 --- a/tests/test_grow.toml +++ b/tests/test_grow.toml @@ -8,7 +8,7 @@ after = [ 'test_mount', ] -# TODO bmap workaround? +# TODO!! lfs3_fs_grow needs to be able to adjust an on-disk bmaps ifndef = 'LFS3_BMAP' diff --git a/tests/test_trvs.toml b/tests/test_trvs.toml index 425c5cd8..a7144def 100644 --- a/tests/test_trvs.toml +++ b/tests/test_trvs.toml @@ -7,9 +7,6 @@ after = [ 'test_alloc' ] -# TODO bmap workaround? -ifndef = 'LFS3_BMAP' - # a simple traversal test [cases.test_trvs_simple] defines.MKCONSISTENT = [false, true] @@ -38,6 +35,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); assert(tinfo.block == 0 || tinfo.block == 1); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -72,6 +74,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); assert(tinfo.block == 0 || tinfo.block == 1); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_rewind(&lfs3, &trv) => 0; @@ -81,6 +88,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); assert(tinfo.block == 0 || tinfo.block == 1); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -115,6 +127,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); assert(tinfo.block == 0 || tinfo.block == 1); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; @@ -1696,7 +1713,8 @@ code = ''' | LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing lfs3_trv_t trv; @@ -1714,6 +1732,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); assert(tinfo.block == 0 || tinfo.block == 1); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -1725,7 +1748,8 @@ code = ''' | ((!COMPACT) ? LFS3_I_COMPACT : 0) // note ckdata implies ckmeta | ((!CKMETA && !CKDATA) ? LFS3_I_CKMETA : 0) - | ((!CKDATA) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_unmount(&lfs3) => 0; ''' @@ -1779,6 +1803,11 @@ code = ''' lfs3_file_close(&lfs3, &file) => 0; } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -1789,7 +1818,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_unmount(&lfs3) => 0; ''' @@ -1825,6 +1855,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); assert(tinfo.block == 0 || tinfo.block == 1); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; @@ -1841,7 +1876,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try another mutation just for good measure lfs3_file_open(&lfs3, &file, "tarantula", @@ -1861,7 +1897,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_trv_close(&lfs3, &trv) => 0; @@ -1907,6 +1944,11 @@ code = ''' lfs3_mkdir(&lfs3, "spider") => 0; } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -1917,7 +1959,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_unmount(&lfs3) => 0; ''' @@ -1967,6 +2010,11 @@ code = ''' lfs3_remove(&lfs3, "spider") => 0; } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -1977,7 +2025,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_unmount(&lfs3) => 0; ''' @@ -2022,6 +2071,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); assert(tinfo.block == 0 || tinfo.block == 1); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif if (WHEN == 2) { lfs3_rename(&lfs3, "spider", "scorpion") => 0; @@ -2037,7 +2091,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_unmount(&lfs3) => 0; ''' @@ -2109,7 +2164,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -2192,7 +2248,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_rewind(&lfs3, &file) => 0; @@ -2276,6 +2333,11 @@ code = ''' lfs3_file_close(&lfs3, &file) => 0; // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -2286,7 +2348,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -2379,6 +2442,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -2389,7 +2457,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -2475,6 +2544,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -2483,9 +2557,10 @@ code = ''' lfs3_fs_stat(&lfs3, &fsinfo) => 0; assert(fsinfo.flags == ( LFS3_I_LOOKAHEAD - | LFS3_I_COMPACT + | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -2561,6 +2636,11 @@ code = ''' lfs3_file_flush(&lfs3, &file1) => 0; // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -2571,7 +2651,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_file_close(&lfs3, &file1) => 0; lfs3_file_close(&lfs3, &file2) => 0; @@ -2666,6 +2747,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -2676,7 +2762,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_file_close(&lfs3, &file1) => 0; lfs3_file_close(&lfs3, &file2) => 0; @@ -2764,6 +2851,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -2774,7 +2866,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_file_close(&lfs3, &file1) => 0; lfs3_file_close(&lfs3, &file2) => 0; @@ -2853,6 +2946,11 @@ code = ''' lfs3_file_close(&lfs3, &file1) => 0; // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -2867,7 +2965,8 @@ code = ''' | ((!(CKMETA && DESYNC) && !(CKDATA && DESYNC)) ? LFS3_I_CKMETA : 0) - | ((!(CKDATA && DESYNC)) ? LFS3_I_CKDATA : 0))); + | ((!(CKDATA && DESYNC)) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_file_close(&lfs3, &file2) => 0; @@ -2965,6 +3064,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -2979,7 +3083,8 @@ code = ''' | ((!(CKMETA && DESYNC) && !(CKDATA && DESYNC)) ? LFS3_I_CKMETA : 0) - | ((!(CKDATA && DESYNC)) ? LFS3_I_CKDATA : 0))); + | ((!(CKDATA && DESYNC)) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_file_close(&lfs3, &file2) => 0; @@ -3070,6 +3175,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -3084,7 +3194,8 @@ code = ''' | ((!(CKMETA && DESYNC) && !(CKDATA && DESYNC)) ? LFS3_I_CKMETA : 0) - | ((!(CKDATA && DESYNC)) ? LFS3_I_CKDATA : 0))); + | ((!(CKDATA && DESYNC)) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); lfs3_file_close(&lfs3, &file2) => 0; @@ -3170,6 +3281,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -3184,7 +3300,8 @@ code = ''' | ((!(CKMETA && DESYNC) && !(CKDATA && DESYNC)) ? LFS3_I_CKMETA : 0) - | ((!(CKDATA && DESYNC)) ? LFS3_I_CKDATA : 0))); + | ((!(CKDATA && DESYNC)) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => LFS3_ERR_NOENT; @@ -3273,6 +3390,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -3283,7 +3405,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => LFS3_ERR_NOENT; @@ -3372,6 +3495,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -3382,7 +3510,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -3479,6 +3608,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -3489,7 +3623,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -3597,6 +3732,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -3607,7 +3747,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -3715,6 +3856,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -3725,7 +3871,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -3820,6 +3967,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -3830,7 +3982,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -3919,6 +4072,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -3929,7 +4087,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -4033,6 +4192,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -4043,7 +4207,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -4146,6 +4311,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -4156,7 +4326,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -4312,6 +4483,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -4322,7 +4498,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -4495,6 +4672,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -4505,7 +4687,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -4672,6 +4855,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -4682,7 +4870,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -4846,6 +5035,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -4856,7 +5050,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -5027,6 +5222,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -5037,7 +5237,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -5207,6 +5408,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -5217,7 +5423,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -5398,6 +5605,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_DATA); // we should be at end of traversal now + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -5408,7 +5620,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check the file contents lfs3_file_open(&lfs3, &file, "spider", LFS3_O_RDONLY) => 0; @@ -5475,7 +5688,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing and compacting lfs3_trv_t trv; @@ -5493,6 +5707,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); assert(tinfo.block == 0 || tinfo.block == 1); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; // mdir should have been compacted @@ -5504,7 +5723,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // running another traversal should clear the uncompacted flag lfs3_trv_rewind(&lfs3, &trv) => 0; @@ -5526,7 +5746,8 @@ code = ''' ((!LOOKAHEAD) ? LFS3_I_LOOKAHEAD : 0) // note ckdata implies ckmeta | ((!CKMETA && !CKDATA) ? LFS3_I_CKMETA : 0) - | ((!CKDATA) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the file for (int remount = 0; remount < 2; remount++) { @@ -5606,7 +5827,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing and compacting lfs3_trv_t trv; @@ -5629,6 +5851,11 @@ code = ''' assert(tinfo.btype == LFS3_BTYPE_MDIR); lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; // mrootanchor should have been compacted @@ -5643,7 +5870,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // running another traversal should clear the uncompacted flag lfs3_trv_rewind(&lfs3, &trv) => 0; @@ -5667,7 +5895,8 @@ code = ''' ((!LOOKAHEAD) ? LFS3_I_LOOKAHEAD : 0) // note ckdata implies ckmeta | ((!CKMETA && !CKDATA) ? LFS3_I_CKMETA : 0) - | ((!CKDATA) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the file for (int remount = 0; remount < 2; remount++) { @@ -5729,7 +5958,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing and compacting lfs3_trv_t trv; @@ -5749,6 +5979,11 @@ code = ''' assert(tinfo.btype == LFS3_BTYPE_MDIR); lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; // mdir should have been compacted @@ -5760,7 +5995,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // running another traversal should clear the uncompacted flag lfs3_trv_rewind(&lfs3, &trv) => 0; @@ -5782,7 +6018,8 @@ code = ''' ((!LOOKAHEAD) ? LFS3_I_LOOKAHEAD : 0) // note ckdata implies ckmeta | ((!CKMETA && !CKDATA) ? LFS3_I_CKMETA : 0) - | ((!CKDATA) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the file for (int remount = 0; remount < 2; remount++) { @@ -5871,7 +6108,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing and compacting lfs3_trv_t trv; @@ -5902,6 +6140,11 @@ code = ''' assert(tinfo.btype == LFS3_BTYPE_MDIR); lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; // mdirs should have been compacted @@ -5914,7 +6157,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // running another traversal should clear the uncompacted flag lfs3_trv_rewind(&lfs3, &trv) => 0; @@ -5937,7 +6181,8 @@ code = ''' ((!LOOKAHEAD) ? LFS3_I_LOOKAHEAD : 0) // note ckdata implies ckmeta | ((!CKMETA && !CKDATA) ? LFS3_I_CKMETA : 0) - | ((!CKDATA) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) { @@ -6080,7 +6325,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing and compacting lfs3_trv_t trv; @@ -6116,6 +6362,11 @@ code = ''' assert(tinfo.btype == LFS3_BTYPE_MDIR); lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; if (COMPACTSET) { @@ -6130,7 +6381,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // running another traversal should clear the uncompacted flag lfs3_trv_rewind(&lfs3, &trv) => 0; @@ -6155,7 +6407,8 @@ code = ''' ((!LOOKAHEAD) ? LFS3_I_LOOKAHEAD : 0) // note ckdata implies ckmeta | ((!CKMETA && !CKDATA) ? LFS3_I_CKMETA : 0) - | ((!CKDATA) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) { @@ -6303,7 +6556,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing and compacting lfs3_trv_t trv; @@ -6344,6 +6598,11 @@ code = ''' assert(tinfo.btype == LFS3_BTYPE_MDIR); lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; // mdirs should have been compacted @@ -6358,7 +6617,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // running another traversal should clear the uncompacted flag lfs3_trv_rewind(&lfs3, &trv) => 0; @@ -6383,7 +6643,8 @@ code = ''' ((!LOOKAHEAD) ? LFS3_I_LOOKAHEAD : 0) // note ckdata implies ckmeta | ((!CKMETA && !CKDATA) ? LFS3_I_CKMETA : 0) - | ((!CKDATA) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) { @@ -6497,7 +6758,8 @@ code = ''' | LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing with mkconsistent lfs3_trv_t trv; @@ -6529,6 +6791,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -6549,7 +6816,8 @@ code = ''' | LFS3_I_COMPACT // note ckdata implies ckmeta | (((!CKMETA && !CKDATA) || ORPHANS > 0) ? LFS3_I_CKMETA : 0) - | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) { @@ -6621,7 +6889,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing with mkconsistent lfs3_trv_t trv; @@ -6675,6 +6944,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -6694,7 +6968,8 @@ code = ''' | LFS3_I_COMPACT // note ckdata implies ckmeta | (((!CKMETA && !CKDATA) || ORPHANS > 0) ? LFS3_I_CKMETA : 0) - | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) { @@ -6792,7 +7067,8 @@ code = ''' | LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing with mkconsistent lfs3_trv_t trv; @@ -6838,6 +7114,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_BTREE); } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -6858,7 +7139,8 @@ code = ''' | LFS3_I_COMPACT // note ckdata implies ckmeta | (((!CKMETA && !CKDATA) || ORPHANS > 0) ? LFS3_I_CKMETA : 0) - | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) { @@ -6956,7 +7238,8 @@ code = ''' | LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing with mkconsistent lfs3_trv_t trv; @@ -7002,6 +7285,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_BTREE); } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -7022,7 +7310,8 @@ code = ''' | LFS3_I_COMPACT // note ckdata implies ckmeta | (((!CKMETA && !CKDATA) || ORPHANS > 0) ? LFS3_I_CKMETA : 0) - | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) { @@ -7121,7 +7410,8 @@ code = ''' | LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing with mkconsistent lfs3_trv_t trv; @@ -7175,6 +7465,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_BTREE); } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -7195,7 +7490,8 @@ code = ''' | LFS3_I_COMPACT // note ckdata implies ckmeta | (((!CKMETA && !CKDATA) || ORPHANS > 0) ? LFS3_I_CKMETA : 0) - | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) { @@ -7294,7 +7590,8 @@ code = ''' | LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing with mkconsistent lfs3_trv_t trv; @@ -7348,6 +7645,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_BTREE); } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -7368,7 +7670,8 @@ code = ''' | LFS3_I_COMPACT // note ckdata implies ckmeta | (((!CKMETA && !CKDATA) || ORPHANS > 0) ? LFS3_I_CKMETA : 0) - | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA || ORPHANS > 0) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) { @@ -7485,7 +7788,8 @@ code = ''' | LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing with mkconsistent lfs3_trv_t trv; @@ -7518,6 +7822,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; // we should have cleaned up all grms/orphans @@ -7541,7 +7850,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // running another traversal should clear the uncompacted flag lfs3_trv_rewind(&lfs3, &trv) => 0; @@ -7564,7 +7874,8 @@ code = ''' ((!LOOKAHEAD) ? LFS3_I_LOOKAHEAD : 0) // note ckdata implies ckmeta | ((!CKMETA && !CKDATA) ? LFS3_I_CKMETA : 0) - | ((!CKDATA) ? LFS3_I_CKDATA : 0))); + | ((!CKDATA) ? LFS3_I_CKDATA : 0) + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) { @@ -7659,7 +7970,8 @@ code = ''' LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // try traversing with mkconsistent lfs3_trv_t trv; @@ -7714,6 +8026,11 @@ code = ''' lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; assert(tinfo.btype == LFS3_BTYPE_MDIR); } + #ifdef LFS3_BMAP + lfs3_trv_read(&lfs3, &trv, &tinfo) => 0; + assert(tinfo.btype == LFS3_BTYPE_BTREE); + assert(tinfo.block == 2); + #endif lfs3_trv_read(&lfs3, &trv, &tinfo) => LFS3_ERR_NOENT; lfs3_trv_close(&lfs3, &trv) => 0; @@ -7736,7 +8053,8 @@ code = ''' | LFS3_I_LOOKAHEAD | LFS3_I_COMPACT | LFS3_I_CKMETA - | LFS3_I_CKDATA)); + | LFS3_I_CKDATA + | LFS3_IFDEF_BMAP(LFS3_I_BMAPCACHE, 0))); // check we can still read the files for (int remount = 0; remount < 2; remount++) {