FreeBSD/sys/fs/nandfs/nandfs_subr.c
/* Translate index to a file block number and an entry */
Translate index to a file block number and an entry
Translate index to a file block number and an entry
void
nandfs_mdt_trans(struct nandfs_mdt *mdt, uint64_t index,
    nandfs_lbn_t *blocknr, uint32_t *entry_in_block)
{
	uint64_t blknr;
	uint64_t group, group_offset, blocknr_in_group;
	uint64_t desc_block, desc_offset;
	group = index / mdt->entries_per_group;
	group_offset = index % mdt->entries_per_group;
	desc_block = group / mdt->groups_per_desc_block;
	desc_offset = group % mdt->groups_per_desc_block;
	blocknr_in_group = group_offset / mdt->entries_per_block;
	blknr = 1 + desc_block * mdt->blocks_per_desc_block;
	blknr += desc_offset * mdt->blocks_per_group;
	blknr += 1 + blocknr_in_group;
	*blocknr = blknr;
	*entry_in_block = group_offset % mdt->entries_per_block;
}
void nandfs_mdt_trans ( struct nandfs_mdt * mdt , uint64_t index , nandfs_lbn_t * blocknr , uint32_t * entry_in_block ) { uint64_t blknr ; uint64_t group , group_offset , blocknr_in_group ; uint64_t desc_block , desc_offset ; group = index / mdt -> entries_per_group ; group_offset = index % mdt -> entries_per_group ; desc_block = group / mdt -> groups_per_desc_block ; desc_offset = group % mdt -> groups_per_desc_block ; blocknr_in_group = group_offset / mdt -> entries_per_block ; blknr = 1 + desc_block * mdt -> blocks_per_desc_block ; blknr += desc_offset * mdt -> blocks_per_group ; blknr += 1 + blocknr_in_group ; * blocknr = blknr ; * entry_in_block = group_offset % mdt -> entries_per_block ; }
Translate index to a file block number and an entry
Translate index to a file block number and an entry
/* Calculate our offset in the file */ /* To descgroup offset */ /* To group offset */ /* To actual file block */