Commit 71803d3b authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] ext2_new_block() cleanup

in ext2_new_block() inode->i_sb can't be NULL.  Dead code removed.

merged returns in ext2_new_block()

in ext2_new_block() added a local variable (sbi) for sb->u.ext2_sb;
users converted. 

calculation of prealloc_goal moved into beginning of function. 

new local variable (block).  Initialized to 0, set to the number of
allocated block only when we are known to be successful. 
ext2_new_block() returns the value of 'block' now.  As the result, out:
is gone - it's identical to out_unlock now. 

check for block being chosen past the end of disk had been moved up No
sense to check that after we had done the preallocations... 

quota allocation taken into the beginning of ext2_new_block().  we put
the number of blocks we'd reserved into dq_alloc and then decrement it
each time old code would do DQUOT_ALLOC/increment when it would do
DQUOT_FREE.  On the exit we release dq_alloc blocks I.e.  all
allocations are pushed into the beginning and all freeing - to the end. 

now that we had moved the last possible point of failure up, we can do
the same with assignment of final result to block. 

code that does allocation within a group had been taken out into a
helper - grab_block(map, size, goal). 

decrementing fs-wide free blocks count moved into the beginning of
function.  We try to reserve up to dq_alloc blocks - amount we _can_
grab is limited by the actual free space and root-reserved percentage. 
That logics had been taken into a helper - reserve_blocks(sb, amount). 
Number of blocks we had managed to reserve is put into es_alloc.  When
we actually grab a block, es_alloc is decremented.  Upon the exit we
release the leftovers.  Old code didn't honor 'reserved for root' limit
when doing prealloc - now that had been fixed. 

EXT2_BLOCKS_PER_GROUP(sb) put into a local variable (group_size)

similar "reserve and release leftovers in the end" scheme for group
(i.e.  we try to reserve as much as we want in the group, then count how
much had been used up and release the leftovers in the end). 

cleaned up the preallocation loop. 
parent f1228ed7
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment