Lines Matching full:block
25 static int get_level_offsets(struct ext2_data *fs, uint32_t block, uint32_t offsets[4]);
29 /* Array of zeros to be used in inode block calculation */
242 /* Check if block group is cached */ in ext2_fetch_block_group()
257 uint32_t block = group / groups_per_block; in ext2_fetch_block_group() local
259 uint32_t global_block = fs->sblock.s_first_data_block + 1 + block; in ext2_fetch_block_group()
271 /* Drop unused block */ in ext2_fetch_block_group()
293 int ext2_fetch_bg_itable(struct ext2_bgroup *bg, uint32_t block) in ext2_fetch_bg_itable() argument
295 if (bg->inode_table && bg->inode_table_block == block) { in ext2_fetch_bg_itable()
300 uint32_t global_block = bg->bg_inode_table + block; in ext2_fetch_bg_itable()
308 bg->inode_table_block = block; in ext2_fetch_bg_itable()
345 * @brief Fetch block group and inode table of given inode.
347 * @return Offset of inode in currently fetched inode table block.
403 * block on that level. If they match then it is the block we are looking for.
408 uint32_t block; in fetch_level_blocks() local
416 /* If already fetched block matches desired one we can use it and move to the next level. */ in fetch_level_blocks()
418 /* Fetched block on current level was wrong. in fetch_level_blocks()
426 block = inode->i_block[offsets[0]]; in fetch_level_blocks()
430 block = sys_le32_to_cpu(list[offsets[lvl]]); in fetch_level_blocks()
433 if (block == 0) { in fetch_level_blocks()
436 inode->blocks[lvl] = ext2_get_block(inode->i_fs, block); in fetch_level_blocks()
442 LOG_DBG("[fetch] lvl:%d off:%d num:%d", lvl, offsets[lvl], block); in fetch_level_blocks()
447 int ext2_fetch_inode_block(struct ext2_inode *inode, uint32_t block) in ext2_fetch_inode_block() argument
449 /* Check if correct inode block is cached. */ in ext2_fetch_inode_block()
450 if (inode->flags & INODE_FETCHED_BLOCK && inode->block_num == block) { in ext2_fetch_inode_block()
454 LOG_DBG("inode:%d cur_blk:%d fetch_blk:%d", inode->i_id, inode->block_num, block); in ext2_fetch_inode_block()
461 max_lvl = get_level_offsets(fs, block, offsets); in ext2_fetch_inode_block()
471 inode->block_num = block; in ext2_fetch_inode_block()
500 __ASSERT(block_num != 0, "Can't delete zero block"); in delete_blocks()
512 /* If we got here we will remove this block in delete_blocks()
513 * and it is also a block with actual inode data, hence we count it. in delete_blocks()
518 /* Current block holds a list of blocks. */ in delete_blocks()
527 /* We remove all blocks that are referenced by current block, hence current in delete_blocks()
528 * block isn't needed anymore. in delete_blocks()
534 /* We are on one before last layer of inode block table. The next layer are in delete_blocks()
544 /* We don't remove all blocks referenced by current block. We have to use in delete_blocks()
545 * offsets to decide which part of next block we want to remove. in delete_blocks()
548 LOG_ERR("Inode block that references other blocks must be nonzero"); in delete_blocks()
554 /* We will start removing whole blocks from next block on this level */ in delete_blocks()
557 /* Remove desired part of lower level block. */ in delete_blocks()
585 LOG_DBG("free block %d (lvl %d)", block_num, lvl); in delete_blocks()
587 /* If we remove current block, we don't have to write it's updated content. */ in delete_blocks()
610 static int get_level_offsets(struct ext2_data *fs, uint32_t block, uint32_t offsets[4]) in get_level_offsets() argument
619 if (block < lvl0_blks) { in get_level_offsets()
620 offsets[0] = block; in get_level_offsets()
625 block -= lvl0_blks; in get_level_offsets()
626 if (block < lvl1_blks) { in get_level_offsets()
628 offsets[1] = block; in get_level_offsets()
633 block -= lvl1_blks; in get_level_offsets()
634 if (block < lvl2_blks) { in get_level_offsets()
636 offsets[1] = block / B; in get_level_offsets()
637 offsets[2] = block % B; in get_level_offsets()
642 if (block < lvl3_blks) { in get_level_offsets()
643 block -= lvl2_blks; in get_level_offsets()
645 offsets[1] = block / (B * B); in get_level_offsets()
646 offsets[2] = (block % (B * B)) / B; in get_level_offsets()
647 offsets[3] = (block % (B * B)) % B; in get_level_offsets()
650 /* Block number is too large */ in get_level_offsets()
654 static int block0_level(uint32_t block) in block0_level() argument
656 if (block >= EXT2_INODE_BLOCK_1LVL) { in block0_level()
657 return block - EXT2_INODE_BLOCK_1LVL + 1; in block0_level()
673 /* The first block to remove is either: in ext2_inode_remove_blocks()
675 * - the first referenced block in the indirect block list; in ext2_inode_remove_blocks()
676 * we remove also the indirect block in ext2_inode_remove_blocks()
680 /* There will be some blocks referenced from first affected block hence we can't in ext2_inode_remove_blocks()
684 LOG_ERR("Inode block that references other blocks must be nonzero"); in ext2_inode_remove_blocks()
715 uint32_t *block; in alloc_level_blocks() local
721 block = &inode->i_block[inode->offsets[lvl]]; in alloc_level_blocks()
723 block = &((uint32_t *)inode->blocks[lvl - 1]->data)[inode->offsets[lvl]]; in alloc_level_blocks()
724 *block = sys_le32_to_cpu(*block); in alloc_level_blocks()
727 if (*block == 0) { in alloc_level_blocks()
733 /* Update block from higher level. */ in alloc_level_blocks()
734 *block = sys_cpu_to_le32(inode->blocks[lvl]->num); in alloc_level_blocks()
742 /* Allocating block on that level implies that blocks on lower levels will in alloc_level_blocks()
745 LOG_DBG("Alloc lvl:%d (num: %d) %s", lvl, *block, in alloc_level_blocks()
795 uint32_t block = bg->num / groups_per_block; in ext2_commit_bg() local
797 uint32_t global_block = fs->sblock.s_first_data_block + 1 + block; in ext2_commit_bg()
827 /* get pointer to proper inode in fetched block */ in ext2_commit_inode()
899 LOG_WRN("Cannot find free block in group %d (rc: %d)", group, bitmap_slot); in ext2_alloc_block()
906 LOG_DBG("Found free block %d in group %d (total: %d)", bitmap_slot, group, total); in ext2_alloc_block()
925 LOG_DBG("super block write returned: %d", rc); in ext2_alloc_block()
930 LOG_DBG("block group write returned: %d", rc); in ext2_alloc_block()
935 LOG_DBG("block bitmap write returned: %d", rc); in ext2_alloc_block()
1022 LOG_DBG("super block write returned: %d", rc); in ext2_alloc_inode()
1027 LOG_DBG("block group write returned: %d", rc); in ext2_alloc_inode()
1032 LOG_DBG("block bitmap write returned: %d", rc); in ext2_alloc_inode()
1042 int ext2_free_block(struct ext2_data *fs, uint32_t block) in ext2_free_block() argument
1044 LOG_DBG("Free block %d", block); in ext2_free_block()
1046 /* Block bitmaps tracks blocks starting from s_first_data_block. */ in ext2_free_block()
1047 block -= fs->sblock.s_first_data_block; in ext2_free_block()
1050 uint32_t group = block / fs->sblock.s_blocks_per_group; in ext2_free_block()
1051 uint32_t off = block % fs->sblock.s_blocks_per_group; in ext2_free_block()
1081 LOG_DBG("super block write returned: %d", rc); in ext2_free_block()
1086 LOG_DBG("block group write returned: %d", rc); in ext2_free_block()
1091 LOG_DBG("block bitmap write returned: %d", rc); in ext2_free_block()
1144 LOG_DBG("super block write returned: %d", rc); in ext2_free_inode()
1149 LOG_DBG("block group write returned: %d", rc); in ext2_free_inode()
1154 LOG_DBG("block bitmap write returned: %d", rc); in ext2_free_inode()