From f93a17341607ea8e03c047ca123871989b1da280 Mon Sep 17 00:00:00 2001 From: Hirofumi Ogawa Date: Tue, 19 Oct 2004 18:15:04 -0700 Subject: [PATCH] FAT: rewrite the cache for file allocation table lookup This rewrites the cache stuff for file allocation table (FAT). This cache stocks the more pieces of FAT-chain by counting the number of contiguous data blocks. And if cache hit, since a block number can calculate without looking FAT-chain up, fat_get_block() become more fast. But if data blocks was fragmenting, unfortunately this cache is unuseful. read from block device [1st]# time dd if=/dev/hda6 of=/dev/null bs=1M count=2048 2147483648 bytes transferred in 229.524189 seconds (9356241 bytes/sec) real 3m49.557s, user 0m0.026s, sys 1m20.414s [2nd]# time dd if=/dev/hda6 of=/dev/null bs=1M count=2048 2147483648 bytes transferred in 229.539358 seconds (9355623 bytes/sec) real 3m49.647s, user 0m0.036s, sys 1m20.144s read from full contiguous file with this patch [1st]# time dd if=data of=/dev/null bs=1M count=2048 2147483648 bytes transferred in 337.959477 seconds (6354264 bytes/sec) real 5m37.970s, user 0m0.031s, sys 1m21.915s [2nd]# time dd if=data of=/dev/null bs=1M count=2048 2147483648 bytes transferred in 225.401699 seconds (9527362 bytes/sec) real 3m45.476s, user 0m0.027s, sys 1m19.286s read from full fragmented file with this patch [1st]# time dd if=data of=/dev/null bs=1M count=2048 2147483647 bytes transferred in 1146.529081 seconds (1873030 bytes/sec) real 19m6.538s, user 0m0.020s, sys 1m32.774s [2nd]# time dd if=data of=/dev/null bs=1M count=2048 2147483647 bytes transferred in 1045.084822 seconds (2054841 bytes/sec) real 17m25.152s, user 0m0.022s, sys 1m34.801s read from full contiguous file without this patch [1st]# time dd if=data of=/dev/null bs=1M count=2048 2147483648 bytes transferred in 348.144707 seconds (6168365 bytes/sec) real 5m48.169s, user 0m0.019s, sys 1m29.962s [2nd]# time dd if=data of=/dev/null bs=1M count=2048 2147483648 bytes transferred in 324.017361 seconds (6627681 bytes/sec) real 5m24.038s, user 0m0.023s, sys 1m20.602s read from full fragmented file without this patch [1st]# time dd if=data of=/dev/null bs=1M count=2048 2147483647 bytes transferred in 1156.845693 seconds (1856327 bytes/sec) real 19m16.855s, user 0m0.031s, sys 1m32.172s [2nd]# time dd if=data of=/dev/null bs=1M count=2048 2147483647 bytes transferred in 1066.518713 seconds (2013545 bytes/sec) real 17m46.526s, user 0m0.023s, sys 1m33.630s Signed-off-by: OGAWA Hirofumi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/msdos_fs.h | 2 -- include/linux/msdos_fs_i.h | 5 ++--- include/linux/msdos_fs_sb.h | 10 ---------- 3 files changed, 2 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h index 812b01fe3bbe..d1f429b41d4c 100644 --- a/include/linux/msdos_fs.h +++ b/include/linux/msdos_fs.h @@ -232,8 +232,6 @@ static inline void fatwchar_to16(__u8 *dst, const wchar_t *src, size_t len) extern int fat_access(struct super_block *sb, int nr, int new_value); extern int __fat_access(struct super_block *sb, int nr, int new_value); extern int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys); -extern void fat_cache_init(struct super_block *sb); -extern void fat_cache_add(struct inode *inode, int f_clu, int d_clu); extern void fat_cache_inval_inode(struct inode *inode); extern int fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus); diff --git a/include/linux/msdos_fs_i.h b/include/linux/msdos_fs_i.h index 13717b437be0..a29b7d993e3f 100644 --- a/include/linux/msdos_fs_i.h +++ b/include/linux/msdos_fs_i.h @@ -8,9 +8,8 @@ */ struct msdos_inode_info { - /* cache of lastest accessed cluster */ - int file_cluster; /* cluster number in the file. */ - int disk_cluster; /* cluster number on disk. */ + struct list_head cache_lru; + int nr_caches; loff_t mmu_private; int i_start; /* first cluster or 0 */ diff --git a/include/linux/msdos_fs_sb.h b/include/linux/msdos_fs_sb.h index c79a172225d3..3c69d6f36075 100644 --- a/include/linux/msdos_fs_sb.h +++ b/include/linux/msdos_fs_sb.h @@ -26,15 +26,6 @@ struct fat_mount_options { nocase:1; /* Does this need case conversion? 0=need case conversion*/ }; -#define FAT_CACHE_NR 8 /* number of FAT cache */ - -struct fat_cache { - int start_cluster; /* first cluster of the chain. */ - int file_cluster; /* cluster number in the file. */ - int disk_cluster; /* cluster number on disk. */ - struct fat_cache *next; /* next cache entry */ -}; - struct msdos_sb_info { unsigned short sec_per_clus; /* sectors/cluster */ unsigned short cluster_bits; /* log2(cluster_size) */ @@ -59,7 +50,6 @@ struct msdos_sb_info { int dir_per_block_bits; /* log2(dir_per_block) */ spinlock_t cache_lock; - struct fat_cache cache_array[FAT_CACHE_NR], *cache; }; #endif -- cgit v1.2.3