From: Evgeniy Ivanov Date: Thu, 11 Aug 2011 15:12:07 +0000 (+0400) Subject: MFS: optimize dentry acllocation. X-Git-Tag: v3.2.0~358 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/doxygen.png?a=commitdiff_plain;h=bc434254ea5f25ce6cadaa81c722995c199f510d;p=minix.git 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. --- diff --git a/servers/mfs/inode.c b/servers/mfs/inode.c index 31a2777cc..210ea844e 100644 --- a/servers/mfs/inode.c +++ b/servers/mfs/inode.c @@ -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); diff --git a/servers/mfs/inode.h b/servers/mfs/inode.h index c3ddbbd75..f66532c3a 100644 --- a/servers/mfs/inode.h +++ b/servers/mfs/inode.h @@ -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 */ diff --git a/servers/mfs/path.c b/servers/mfs/path.c index 8d32dd641..3a3f42e33 100644 --- a/servers/mfs/path.c +++ b/servers/mfs/path.c @@ -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. */