MFS: optimize dentry acllocation.

When search for free slot always cache position of last allocated slot,
so next time when need to allocate new slot, we can search from that
position.
This commit is contained in:
Evgeniy Ivanov 2011-08-11 19:12:07 +04:00 committed by Ben Gras
parent 164789226c
commit bc434254ea
3 changed files with 16 additions and 1 deletions

View file

@ -172,6 +172,7 @@ PUBLIC struct inode *get_inode(
rip->i_update = 0; /* all the times are initially up-to-date */
rip->i_zsearch = NO_ZONE; /* no zones searched for yet */
rip->i_mountpoint= FALSE;
rip->i_last_dpos = 0; /* no dentries searched for yet */
/* Add to hash */
addhash_inode(rip);

View file

@ -36,6 +36,7 @@ EXTERN struct inode {
struct super_block *i_sp; /* pointer to super block for inode's device */
char i_dirt; /* CLEAN or DIRTY */
zone_t i_zsearch; /* where to start search for new zones */
off_t i_last_dpos; /* where to start dentry search */
char i_mountpoint; /* true if mounted on */

View file

@ -519,7 +519,13 @@ int check_permissions; /* check permissions when flag is !IS_EMPTY */
e_hit = FALSE;
match = 0; /* set when a string match occurs */
for (pos = 0; pos < ldir_ptr->i_size; pos += ldir_ptr->i_sp->s_block_size) {
pos = 0;
if (flag == ENTER && ldir_ptr->i_last_dpos < ldir_ptr->i_size) {
pos = ldir_ptr->i_last_dpos;
new_slots = (unsigned) (pos/DIR_ENTRY_SIZE);
}
for (; pos < ldir_ptr->i_size; pos += ldir_ptr->i_sp->s_block_size) {
b = read_map(ldir_ptr, pos); /* get block number */
/* Since directories don't have holes, 'b' cannot be NO_BLOCK. */
@ -561,6 +567,8 @@ int check_permissions; /* check permissions when flag is !IS_EMPTY */
bp->b_dirt = DIRTY;
ldir_ptr->i_update |= CTIME | MTIME;
ldir_ptr->i_dirt = DIRTY;
if (pos < ldir_ptr->i_last_dpos)
ldir_ptr->i_last_dpos = pos;
} else {
sp = ldir_ptr->i_sp; /* 'flag' is LOOK_UP */
*numb = (ino_t) conv4(sp->s_native,
@ -587,6 +595,11 @@ int check_permissions; /* check permissions when flag is !IS_EMPTY */
return(flag == IS_EMPTY ? OK : ENOENT);
}
/* When ENTER next time, start searching for free slot from
* i_last_dpos. It gives some performance improvement (3-5%).
*/
ldir_ptr->i_last_dpos = pos;
/* This call is for ENTER. If no free slot has been found so far, try to
* extend directory.
*/