Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


main function used to allocate a new block and its reservation window.’’ We’re almost done! Note that
now might also be a good opportunity to remember the pre-allocation data structures introduced in
Section 9.2.2 since they form the core of the reservation window mechanism.

The code flow diagram forext2_try_to_allocate_rsvis shown in Figure 9-14. Basically, the
function handles some reservation window issues and passes the proper allocation down to
ext2_try_to_allocate, the last link in the chain.ext2_try_to_allocate_with_rsvhas no direct
connection with the inode for which the allocation is performed, but the reservation window is passed
as a parameter. If aNULLpointer is given instead, this means that the reservation mechanism is not
supposed to be used.

ext2_try_to_allocate_with_rsv

Reservation undesired?

ext2_try_to_allocate

ext2_try_to_allocate
explicitely
w/o reservation window

with reservation window

Uses alloc_new_reservation

Loop until allocationUpdate reservation hits
request if fulfilled

No

Yes

Create new reservation window
or extend existing reservation
window if necessary

ext2_try_to_allocate

compute preferred allocation range

No reservation window? Find first free block

find_next_usable_block

Try to reserve desired number of blocks

No target block within group?

Figure 9-14: Code flow diagram forext2_try_to_allocate_with_rsv.

Thus the first check is to determine whether using pre-allocation is desired or possible at all. Should this
not be the case, thenext2_try_to_allocatecan be called immediately. Likewise, the function also has a
parameter for the reservation information, and if aNULLpointer is passed instead, no pre-allocation will
be used. If a reservation window exists, the kernel checks if the pre-allocation information needs to be
updated, and does so if necessary. In this case,ext2_try_to_allocateis called with the order to use the
reservation window.

After callingext2_try_to_allocate, the reservation hit statistics need to be updated by
ext2_try_to_allocate_with_rcvin case an allocation could be performed in the allocation
window. If the required number of blocks could be allocated, we are finished. Otherwise, the reservation
window settings are readapted, andext2_try_to_allocateis called again.
Free download pdf