Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


Iterate until atleast the number
of blocks requiredfor indirection hasbeen allocated

ext2_alloc_branch

ext2_alloc_blocks

ext2_alloc_blocks

ext2_new_blocks

Set up indirection structures

Figure 9-12: Code flow diagram for
ext2_alloc_branch.

Decide if reservations should be used

ext2_new_blocks

ext2_has_free_blocks

ext2_get_group_desc

ext2_try_to_allocate_with_rsv

Disable preallocation if not enough free blocks are available

Allocation successsful? Update statistics and return

Allocation successsful?

Try different block groups

Update statistics and return

Retry from beginning without reservations

Yes

No

Yes

No

Figure 9-13: Code flow diagram forext2_new_blocks.

Recall that Ext2 supports pre-allocation, and this needs to be partly handled inext2_new_blocks.Since
the mechanism is already complicated enough without the details of pre-allocation, let’s first consider it
without this extra complexity. We will come back to how pre-allocation works exactly afterward.

Consider the prototype ofext2_new_blocks(note thatext2_fsblk_tistypedef’d tounsigned longand
represents a block number).

fs/ext2/balloc.c
ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal,
unsigned long *count, int *errp)
{
...
Free download pdf