Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


By what criteria does the kernel update the reservation window? Observe the allocation loop:


fs/etc2/balloc.c
static ext2_grpblk_t
ext2_try_to_allocate_with_rsv(struct super_block *sb, unsigned int group,
struct buffer_head *bitmap_bh, ext2_grpblk_t grp_goal,
struct ext2_reserve_window_node * my_rsv,
unsigned long *count)
{
...
group_first_block = ext2_group_first_block_no(sb, group);
group_last_block = group_first_block + (EXT2_BLOCKS_PER_GROUP(sb) - 1);
...
while (1) {
if (rsv_is_empty(&my_rsv->rsv_window) || (ret < 0) ||
!goal_in_my_reservation(&my_rsv->rsv_window,
grp_goal, group, sb)) {
if (my_rsv->rsv_goal_size < *count)
my_rsv->rsv_goal_size = *count;
ret = alloc_new_reservation(my_rsv, grp_goal, sb,
group, bitmap_bh);

if (!goal_in_my_reservation(&my_rsv->rsv_window,
grp_goal, group, sb))
grp_goal = -1;
} else if (grp_goal >= 0) {
int curr = my_rsv->rsv_end -
(grp_goal + group_first_block) + 1;

if (curr < *count)
try_to_extend_reservation(my_rsv, sb,
*count - curr);
}

...
ret = ext2_try_to_allocate(sb, group, bitmap_bh, grp_goal,
&num, &my_rsv->rsv_window);
if (ret >= 0) {
my_rsv->rsv_alloc_hit += num;
*count = num;
break; /* succeed */
}
num = *count;
}
return ret;
}

If either there is no reservation associated with the file (checked byrsv_is_empty)orthedesired
goal block is not within the current reservation window (checked bygoal_in_my_reservation), the
kernel needs to create a new reservation window. This task is delegated toalloc_new_reservation,
which contains the goal block. A more detailed discussion of the function follows below. Although
alloc_new_reservationwill try to find a region that contains the goal block, this might not be possible.
In this case,grp_goalis set toβˆ’1, which signifies that no desired goal should be used.

Free download pdf