diff -urN 2.4.8ac7/fs/ext2/dir.c 2.4.8ac8/fs/ext2/dir.c --- 2.4.8ac7/fs/ext2/dir.c Sat Jul 21 00:04:27 2001 +++ 2.4.8ac8/fs/ext2/dir.c Tue Aug 21 22:17:18 2001 @@ -303,7 +303,7 @@ const char *name = dentry->d_name.name; int namelen = dentry->d_name.len; unsigned reclen = EXT2_DIR_REC_LEN(namelen); - unsigned long n; + unsigned long start, n; unsigned long npages = dir_pages(dir); struct page *page = NULL; ext2_dirent * de; @@ -311,24 +311,32 @@ /* OFFSET_CACHE */ *res_page = NULL; - for (n = 0; n < npages; n++) { + start = dir->u.ext2_i.i_dir_start_lookup; + if (start >= npages) + start = 0; + n = start; + do { char *kaddr; page = ext2_get_page(dir, n); - if (IS_ERR(page)) - continue; - - kaddr = page_address(page); - de = (ext2_dirent *) kaddr; - kaddr += PAGE_CACHE_SIZE - reclen; - for ( ; (char *) de <= kaddr ; de = ext2_next_entry(de)) - if (ext2_match (namelen, name, de)) - goto found; - ext2_put_page(page); - } + if (!IS_ERR(page)) { + kaddr = page_address(page); + de = (ext2_dirent *) kaddr; + kaddr += PAGE_CACHE_SIZE - reclen; + while ((char *) de <= kaddr) { + if (ext2_match (namelen, name, de)) + goto found; + de = ext2_next_entry(de); + } + ext2_put_page(page); + } + if (++n >= npages) + n = 0; + } while (n != start); return NULL; found: *res_page = page; + dir->u.ext2_i.i_dir_start_lookup = n; return de; } diff -urN 2.4.8ac7/include/linux/ext2_fs_i.h 2.4.8ac8/include/linux/ext2_fs_i.h --- 2.4.8ac7/include/linux/ext2_fs_i.h Sat Jul 21 00:04:31 2001 +++ 2.4.8ac8/include/linux/ext2_fs_i.h Tue Aug 21 22:17:26 2001 @@ -34,6 +34,7 @@ __u32 i_next_alloc_goal; __u32 i_prealloc_block; __u32 i_prealloc_count; + __u32 i_dir_start_lookup; int i_new_inode:1; /* Is a freshly allocated inode */ };