2008-12-22 19:51:07

by Rohit Sharma

[permalink] [raw]
Subject: find_group_orlov()

This is a code snippet from find_group_orlov() in ialloc.c of ext2 fs

I am not able to figure out the percpu counters, why it is used.


if (ndirs == 0)
ndirs = 1; /* percpu_counters are approximate... */

blocks_per_dir = (le32_to_cpu(es->s_blocks_count)-free_blocks) / ndirs;

max_dirs = ndirs / ngroups + inodes_per_group / 16;
// Why 16??
min_inodes = avefreei - inodes_per_group / 4;
// Why 4 ??
min_blocks = avefreeb - EXT2_BLOCKS_PER_GROUP(sb) / 4;
// Why 4 ??

max_debt = EXT2_BLOCKS_PER_GROUP(sb) / max(blocks_per_dir, BLOCK_COST);
if (max_debt * INODE_COST > inodes_per_group)
max_debt = inodes_per_group / INODE_COST;
if (max_debt > 255)
max_debt = 255;
if (max_debt == 0)
max_debt = 1;

What is the use of debts in allocation. ??

Is it done to make efficient use of free disk space ??