patch-2.4.10 linux/fs/ext2/dir.c
Next file: linux/fs/ext2/fsync.c
Previous file: linux/fs/exec.c
Back to the patch index
Back to the overall index
- Lines: 54
- Date:
Mon Sep 17 13:16:30 2001
- Orig file:
v2.4.9/linux/fs/ext2/dir.c
- Orig date:
Wed Jul 25 17:10:24 2001
diff -u --recursive --new-file v2.4.9/linux/fs/ext2/dir.c linux/fs/ext2/dir.c
@@ -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;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)