Lines Matching defs:block
29 /// Caching block device operations ///
35 rcache->block = LFS_BLOCK_NULL;
41 pcache->block = LFS_BLOCK_NULL;
46 lfs_block_t block, lfs_off_t off,
50 || (lfs->block_count && block >= lfs->block_count)) {
57 if (pcache && block == pcache->block &&
74 if (block == rcache->block &&
95 int err = lfs->cfg->read(lfs->cfg, block, off, data, diff);
107 LFS_ASSERT(!lfs->block_count || block < lfs->block_count);
108 rcache->block = block;
116 int err = lfs->cfg->read(lfs->cfg, rcache->block,
129 lfs_block_t block, lfs_off_t off,
140 block, off+i, &dat, diff);
156 lfs_block_t block, lfs_off_t off, lfs_size_t size, uint32_t *crc) {
164 block, off+i, &dat, diff);
178 if (pcache->block != LFS_BLOCK_NULL && pcache->block != LFS_BLOCK_INLINE) {
179 LFS_ASSERT(pcache->block < lfs->block_count);
181 int err = lfs->cfg->prog(lfs->cfg, pcache->block,
193 pcache->block, pcache->off, pcache->buffer, diff);
229 lfs_block_t block, lfs_off_t off,
232 LFS_ASSERT(block == LFS_BLOCK_INLINE || block < lfs->block_count);
236 if (block == pcache->block &&
261 // entire block or manually flushing the pcache
262 LFS_ASSERT(pcache->block == LFS_BLOCK_NULL);
265 pcache->block = block;
275 static int lfs_bd_erase(lfs_t *lfs, lfs_block_t block) {
276 LFS_ASSERT(block < lfs->block_count);
277 int err = lfs->cfg->erase(lfs->cfg, block);
285 // operations on block pairs
382 lfs_block_t block;
588 int (*cb)(void *data, lfs_block_t block), void *data,
597 static int lfs_alloc_lookahead(void *p, lfs_block_t block) {
599 lfs_block_t off = ((block - lfs->free.off)
627 // Move free offset at the first unused block (lfs->free.i)
646 static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
654 // found a free block
655 *block = (lfs->free.off + off) % lfs->block_count;
700 // iterate over dir block backwards (for faster lookups)
767 if (pcache && pcache->block == LFS_BLOCK_INLINE &&
784 if (rcache->block == LFS_BLOCK_INLINE &&
802 rcache->block = LFS_BLOCK_INLINE;
905 disk.block = dir->pair[0];
1080 // if either block address is invalid we return LFS_ERR_CORRUPT here,
1087 // find the block with the most recent revision
1285 // try the other block?
1291 // did we end on a valid commit? we may have an erased block
1427 disk->block, disk->off, name->name, diff);
1543 lfs_block_t block;
1557 commit->block, commit->off ,
1599 disk->block, disk->off+i, &dat, 1);
1622 // - 5-word crc with fcrc to check following prog (middle of block)
1623 // - 2-word crc with no following prog (end of block)
1650 commit->block, noff, &eperturb, 1);
1671 commit->block, noff, fcrc.size, &fcrc.crc);
1700 commit->block, commit->off, &ccrc, sizeof(ccrc));
1736 commit->block, off, off1-off, &crc);
1747 // up an unrelated crc (frozen block?)
1750 commit->block, off1, sizeof(uint32_t), &crc);
1765 // allocate pair of dir blocks (backwards, so we write block 1 first)
1773 // zero for reproducibility in case initial block is unreadable
1894 // one metadata block in the pair, effectively making this useless
1904 // save some state in case block is bad
1933 .block = dir->pair[1],
1943 // erase block to write to
2045 // commit was corrupted, drop caches and prepare to relocate block
2049 LFS_DEBUG("Bad block at 0x%"PRIx32, dir->pair[1]);
2105 // And we cap at half a block to avoid degenerate cases with
2135 // we can't allocate a new block, try to compact with degraded
2202 // should we actually drop the directory block?
2219 .block = dir->pair[0],
2614 // current block not end of list?
2646 // now insert into our parent block
2831 lfs_size_t pos, lfs_block_t *block, lfs_off_t *off) {
2833 *block = LFS_BLOCK_NULL;
2857 *block = head;
2866 lfs_block_t *block, lfs_off_t *off) {
2868 // go ahead and grab a block
2885 *block = nblock;
2894 // just copy out the last block if it is incomplete
2916 *block = nblock;
2921 // append block
2948 *block = nblock;
2954 LFS_DEBUG("Bad block at 0x%"PRIx32, nblock);
2956 // just clear cache and try a new block
3066 // not fit in a 128 byte block.
3144 file->cache.block = file->ctz.head;
3204 // just relocate what exists into new block
3235 file->block, i, &data, 1);
3254 file->cache.block = lfs->pcache.block;
3259 file->block = nblock;
3264 LFS_DEBUG("Bad block at 0x%"PRIx32, nblock);
3266 // just clear cache and try a new block
3324 if (lfs->rcache.block != LFS_BLOCK_NULL) {
3343 LFS_DEBUG("Bad block at 0x%"PRIx32, file->block);
3354 file->ctz.head = file->block;
3433 // check if we need a new block
3439 file->pos, &file->block, &file->off);
3444 file->block = LFS_BLOCK_INLINE;
3451 // read as much as we can in current block
3465 file->block, file->off, data, diff);
3519 // check if we need a new block
3524 // find out which block we're extending from
3527 file->pos-1, &file->block, &(lfs_off_t){0});
3540 file->block, file->pos,
3541 &file->block, &file->off);
3547 file->block = LFS_BLOCK_INLINE;
3554 // program as much as we can in current block
3558 file->block, file->off, data, diff);
3727 file->cache.block = file->ctz.head;
3742 size-1, &file->block, &(lfs_off_t){0});
3747 // need to set pos/block/off consistently so seeking back to
3750 file->ctz.head = file->block;
4135 // check that block size is a multiple of cache size is a multiple
4141 // check that the block size is large enough to fit all ctz pointers
4152 // range of 100-1000, or set block_cycles to -1 to disable block-level
4350 // fetch next block in tail list
4446 LFS_ERROR("Invalid block count (%"PRIu32" != %"PRIu32")",
4455 LFS_ERROR("Invalid block size (%"PRIu32" != %"PRIu32")",
4538 int (*cb)(void *data, lfs_block_t block), void *data,
4633 f->block, f->pos, cb, data);
4699 disk->block, disk->off, &child, sizeof(child));
5031 static int lfs_fs_size_count(void *p, lfs_block_t block) {
5032 (void)block;
5175 static int lfs1_bd_read(lfs_t *lfs, lfs_block_t block,
5180 block, off, buffer, size);
5183 static int lfs1_bd_crc(lfs_t *lfs, lfs_block_t block,
5187 int err = lfs1_bd_read(lfs, block, off+i, &c, 1);
5619 // find last block and update tail to thread into fs
5641 // Copy over first block to thread into fs. Unfortunately