Hi In ext3_get_parent(), quick string (struct qstr) can do the job, in place of declaring a dentry on stack. Following patch does this and saves few bytes on kernel stack. Thanks, Maneesh namei.c | 69 ++++++++++++++++++++++++++++++---------------------------------- 1 files changed, 33 insertions(+), 36 deletions(-) diff -urN linux-2.5.58-base/fs/ext3/namei.c linux-2.5.58-ext3/fs/ext3/namei.c --- linux-2.5.58-base/fs/ext3/namei.c Tue Jan 14 11:28:57 2003 +++ linux-2.5.58-ext3/fs/ext3/namei.c Tue Jan 14 18:29:07 2003 @@ -155,7 +155,7 @@ static void dx_set_limit (struct dx_entry *entries, unsigned value); static unsigned dx_root_limit (struct inode *dir, unsigned infosize); static unsigned dx_node_limit (struct inode *dir); -static struct dx_frame *dx_probe(struct dentry *dentry, +static struct dx_frame *dx_probe(struct qstr *entry, struct inode *dir, struct dx_hash_info *hinfo, struct dx_frame *frame, @@ -172,8 +172,9 @@ struct dx_frame *frame, struct dx_frame *frames, int *err, __u32 *start_hash); -static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry, - struct ext3_dir_entry_2 **res_dir, int *err); +static struct buffer_head * ext3_dx_find_entry(struct inode * dir, + struct qstr *entry, + struct ext3_dir_entry_2 **res_dir, int *err); static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry, struct inode *inode); @@ -317,7 +318,7 @@ * back to userspace. */ static struct dx_frame * -dx_probe(struct dentry *dentry, struct inode *dir, +dx_probe(struct qstr *entry, struct inode *dir, struct dx_hash_info *hinfo, struct dx_frame *frame_in, int *err) { unsigned count, indirect; @@ -328,8 +329,6 @@ u32 hash; frame->bh = NULL; - if (dentry) - dir = dentry->d_parent->d_inode; if (!(bh = ext3_bread (NULL,dir, 0, 0, err))) goto fail; root = (struct dx_root *) bh->b_data; @@ -345,8 +344,8 @@ } hinfo->hash_version = root->info.hash_version; hinfo->seed = EXT3_SB(dir->i_sb)->s_hash_seed; - if (dentry) - ext3fs_dirhash(dentry->d_name.name, dentry->d_name.len, hinfo); + if (entry) + ext3fs_dirhash(entry->name, entry->len, hinfo); hash = hinfo->hash; if (root->info.unused_flags & 1) { @@ -706,15 +705,15 @@ */ static inline int search_dirblock(struct buffer_head * bh, struct inode *dir, - struct dentry *dentry, + struct qstr *entry, unsigned long offset, struct ext3_dir_entry_2 ** res_dir) { struct ext3_dir_entry_2 * de; char * dlimit; int de_len; - const char *name = dentry->d_name.name; - int namelen = dentry->d_name.len; + const char *name = entry->name; + int namelen = entry->len; de = (struct ext3_dir_entry_2 *) bh->b_data; dlimit = bh->b_data + dir->i_sb->s_blocksize; @@ -755,8 +754,8 @@ */ -static struct buffer_head * ext3_find_entry (struct dentry *dentry, - struct ext3_dir_entry_2 ** res_dir) +static struct buffer_head * ext3_find_entry (struct inode *dir, + struct qstr *entry, struct ext3_dir_entry_2 ** res_dir) { struct super_block * sb; struct buffer_head * bh_use[NAMEI_RA_SIZE]; @@ -768,7 +767,6 @@ buffer */ int num = 0; int nblocks, i, err; - struct inode *dir = dentry->d_parent->d_inode; int namelen; const u8 *name; unsigned blocksize; @@ -776,13 +774,13 @@ *res_dir = NULL; sb = dir->i_sb; blocksize = sb->s_blocksize; - namelen = dentry->d_name.len; - name = dentry->d_name.name; + namelen = entry->len; + name = entry->name; if (namelen > EXT3_NAME_LEN) return NULL; #ifdef CONFIG_EXT3_INDEX if (is_dx(dir)) { - bh = ext3_dx_find_entry(dentry, res_dir, &err); + bh = ext3_dx_find_entry(dir, entry, res_dir, &err); /* * On success, or if the error was file not found, * return. Otherwise, fall back to doing a search the @@ -832,7 +830,7 @@ brelse(bh); goto next; } - i = search_dirblock(bh, dir, dentry, + i = search_dirblock(bh, dir, entry, block << EXT3_BLOCK_SIZE_BITS(sb), res_dir); if (i == 1) { EXT3_I(dir)->i_dir_start_lookup = block; @@ -867,8 +865,9 @@ } #ifdef CONFIG_EXT3_INDEX -static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry, - struct ext3_dir_entry_2 **res_dir, int *err) +static struct buffer_head * +ext3_dx_find_entry(struct inode *dir, struct qstr *entry, + struct ext3_dir_entry_2 **res_dir, int *err) { struct super_block * sb; struct dx_hash_info hinfo; @@ -878,12 +877,11 @@ struct buffer_head *bh; unsigned long block; int retval; - int namelen = dentry->d_name.len; - const u8 *name = dentry->d_name.name; - struct inode *dir = dentry->d_parent->d_inode; + int namelen = entry->len; + const u8 *name = entry->name; sb = dir->i_sb; - if (!(frame = dx_probe (dentry, 0, &hinfo, frames, err))) + if (!(frame = dx_probe (entry, dir, &hinfo, frames, err))) return NULL; hash = hinfo.hash; do { @@ -936,7 +934,7 @@ return ERR_PTR(-ENAMETOOLONG); lock_kernel(); - bh = ext3_find_entry(dentry, &de); + bh = ext3_find_entry(dir, &dentry->d_name, &de); inode = NULL; if (bh) { unsigned long ino = le32_to_cpu(de->inode); @@ -961,16 +959,15 @@ unsigned long ino; struct dentry *parent; struct inode *inode; - struct dentry dotdot; + struct qstr dotdot; struct ext3_dir_entry_2 * de; struct buffer_head *bh; - dotdot.d_name.name = ".."; - dotdot.d_name.len = 2; - dotdot.d_parent = child; /* confusing, isn't it! */ + dotdot.name = ".."; + dotdot.len = 2; lock_kernel(); - bh = ext3_find_entry(&dotdot, &de); + bh = ext3_find_entry(child->d_inode, &dotdot, &de); inode = NULL; if (!bh) { unlock_kernel(); @@ -1387,7 +1384,7 @@ struct ext3_dir_entry_2 *de; int err; - frame = dx_probe(dentry, 0, &hinfo, frames, &err); + frame = dx_probe(&dentry->d_name, dir, &hinfo, frames, &err); if (!frame) return err; entries = frame->entries; @@ -1955,7 +1952,7 @@ } retval = -ENOENT; - bh = ext3_find_entry (dentry, &de); + bh = ext3_find_entry (dir, &dentry->d_name, &de); if (!bh) goto end_rmdir; @@ -2019,7 +2016,7 @@ handle->h_sync = 1; retval = -ENOENT; - bh = ext3_find_entry (dentry, &de); + bh = ext3_find_entry (dir, &dentry->d_name, &de); if (!bh) goto end_unlink; @@ -2177,7 +2174,7 @@ if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) handle->h_sync = 1; - old_bh = ext3_find_entry (old_dentry, &old_de); + old_bh = ext3_find_entry (old_dir, &old_dentry->d_name, &old_de); /* * Check for inode number is _not_ due to possible IO errors. * We might rmdir the source, keep it as pwd of some process @@ -2190,7 +2187,7 @@ goto end_rename; new_inode = new_dentry->d_inode; - new_bh = ext3_find_entry (new_dentry, &new_de); + new_bh = ext3_find_entry (new_dir, &new_dentry->d_name, &new_de); if (new_bh) { if (!new_inode) { brelse (new_bh); @@ -2253,7 +2250,7 @@ struct buffer_head *old_bh2; struct ext3_dir_entry_2 *old_de2; - old_bh2 = ext3_find_entry(old_dentry, &old_de2); + old_bh2 = ext3_find_entry(old_dir, &old_dentry->d_name, &old_de2); if (old_bh2) { retval = ext3_delete_entry(handle, old_dir, old_de2, old_bh2); -- Maneesh Soni IBM Linux Technology Center, IBM India Software Lab, Bangalore. Phone: +91-80-5044999 email: maneesh@in.ibm.com http://lse.sourceforge.net/