Lines Matching refs:lvl

405 static int fetch_level_blocks(struct ext2_inode *inode, uint32_t offsets[4], int lvl, int max_lvl,  in fetch_level_blocks()  argument
409 bool already_fetched = try_current && (offsets[lvl] == inode->offsets[lvl]); in fetch_level_blocks()
412 if (lvl > max_lvl) { in fetch_level_blocks()
423 ext2_drop_block(inode->blocks[lvl]); in fetch_level_blocks()
425 if (lvl == 0) { in fetch_level_blocks()
428 uint32_t *list = (uint32_t *)inode->blocks[lvl - 1]->data; in fetch_level_blocks()
430 block = sys_le32_to_cpu(list[offsets[lvl]]); in fetch_level_blocks()
434 inode->blocks[lvl] = ext2_get_empty_block(inode->i_fs); in fetch_level_blocks()
436 inode->blocks[lvl] = ext2_get_block(inode->i_fs, block); in fetch_level_blocks()
439 if (inode->blocks[lvl] == NULL) { in fetch_level_blocks()
442 LOG_DBG("[fetch] lvl:%d off:%d num:%d", lvl, offsets[lvl], block); in fetch_level_blocks()
444 return fetch_level_blocks(inode, offsets, lvl + 1, max_lvl, try_current); in fetch_level_blocks()
479 static bool all_zero(const uint32_t *offsets, int lvl) in all_zero() argument
481 for (int i = 0; i < lvl; ++i) { in all_zero()
497 static int64_t delete_blocks(struct ext2_data *fs, uint32_t block_num, int lvl, in delete_blocks() argument
501 __ASSERT(lvl >= 0 && lvl < MAX_OFFSETS_SIZE, in delete_blocks()
502 "Expected 0 <= lvl < %d (got: lvl=%d)", lvl, MAX_OFFSETS_SIZE); in delete_blocks()
511 if (lvl == 0) { in delete_blocks()
526 if (all_zero(offsets, lvl)) { in delete_blocks()
533 } else if (lvl == 1) { in delete_blocks()
558 rem = delete_blocks(fs, block_num2, lvl - 1, &offsets[1]); in delete_blocks()
573 rem = delete_blocks(fs, block_num2, lvl - 1, zero_offsets); in delete_blocks()
585 LOG_DBG("free block %d (lvl %d)", block_num, lvl); in delete_blocks()
719 for (int lvl = 0; lvl <= inode->block_lvl; ++lvl) { in alloc_level_blocks() local
720 if (lvl == 0) { in alloc_level_blocks()
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()
728 ret = ext2_assign_block_num(fs, inode->blocks[lvl]); in alloc_level_blocks()
734 *block = sys_cpu_to_le32(inode->blocks[lvl]->num); in alloc_level_blocks()
735 if (lvl > 0) { in alloc_level_blocks()
736 ret = ext2_write_block(fs, inode->blocks[lvl-1]); in alloc_level_blocks()
745 LOG_DBG("Alloc lvl:%d (num: %d) %s", lvl, *block, in alloc_level_blocks()
746 lvl == inode->block_lvl ? "data" : "indirect"); in alloc_level_blocks()