From: OGAWA Hirofumi Signed-off-by: OGAWA Hirofumi Signed-off-by: Andrew Morton --- 25-akpm/fs/fat/cache.c | 18 ++++++++---------- 25-akpm/fs/fat/inode.c | 2 +- 25-akpm/include/linux/msdos_fs_i.h | 1 + 25-akpm/include/linux/msdos_fs_sb.h | 2 -- 4 files changed, 10 insertions(+), 13 deletions(-) diff -puN fs/fat/cache.c~fat-cache-lock-from-per-sb-to-per-inode-3-6 fs/fat/cache.c --- 25/fs/fat/cache.c~fat-cache-lock-from-per-sb-to-per-inode-3-6 2004-09-11 17:07:36.015465856 -0700 +++ 25-akpm/fs/fat/cache.c 2004-09-11 17:07:36.025464336 -0700 @@ -85,11 +85,10 @@ static int fat_cache_lookup(struct inode { static struct fat_cache nohit = { .fcluster = 0, }; - struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); struct fat_cache *hit = &nohit, *p; int offset = -1; - spin_lock(&sbi->cache_lock); + spin_lock(&MSDOS_I(inode)->cache_lru_lock); debug_pr("FAT: %s, fclus %d", __FUNCTION__, fclus); list_for_each_entry(p, &MSDOS_I(inode)->cache_lru, cache_list) { if (p->fcluster <= fclus && hit->fcluster < p->fcluster) { @@ -113,7 +112,7 @@ static int fat_cache_lookup(struct inode *cached_dclus = cache->dcluster + offset; } debug_pr("\n"); - spin_unlock(&sbi->cache_lock); + spin_unlock(&MSDOS_I(inode)->cache_lru_lock); return offset; } @@ -141,7 +140,6 @@ static struct fat_cache *fat_cache_merge static void fat_cache_add(struct inode *inode, struct fat_cache *new) { - struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); struct fat_cache *cache, *tmp; debug_pr("FAT: %s: fclus %d, dclus %d, cont %d\n", __FUNCTION__, @@ -150,15 +148,15 @@ static void fat_cache_add(struct inode * if (new->fcluster == -1) /* dummy cache */ return; - spin_lock(&sbi->cache_lock); + spin_lock(&MSDOS_I(inode)->cache_lru_lock); cache = fat_cache_merge(inode, new); if (cache == NULL) { if (MSDOS_I(inode)->nr_caches < fat_max_cache(inode)) { MSDOS_I(inode)->nr_caches++; - spin_unlock(&sbi->cache_lock); + spin_unlock(&MSDOS_I(inode)->cache_lru_lock); tmp = fat_cache_alloc(inode); - spin_lock(&sbi->cache_lock); + spin_lock(&MSDOS_I(inode)->cache_lru_lock); cache = fat_cache_merge(inode, new); if (cache != NULL) { MSDOS_I(inode)->nr_caches--; @@ -183,7 +181,7 @@ out: cache->fcluster, cache->dcluster, cache->nr_contig); } debug_pr("\n"); - spin_unlock(&sbi->cache_lock); + spin_unlock(&MSDOS_I(inode)->cache_lru_lock); } /* @@ -205,9 +203,9 @@ static void __fat_cache_inval_inode(stru void fat_cache_inval_inode(struct inode *inode) { - spin_lock(&MSDOS_SB(inode->i_sb)->cache_lock); + spin_lock(&MSDOS_I(inode)->cache_lru_lock); __fat_cache_inval_inode(inode); - spin_unlock(&MSDOS_SB(inode->i_sb)->cache_lock); + spin_unlock(&MSDOS_I(inode)->cache_lru_lock); } int __fat_access(struct super_block *sb, int nr, int new_value) diff -puN fs/fat/inode.c~fat-cache-lock-from-per-sb-to-per-inode-3-6 fs/fat/inode.c --- 25/fs/fat/inode.c~fat-cache-lock-from-per-sb-to-per-inode-3-6 2004-09-11 17:07:36.017465552 -0700 +++ 25-akpm/fs/fat/inode.c 2004-09-11 17:07:36.027464032 -0700 @@ -735,6 +735,7 @@ static void init_once(void * foo, kmem_c if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == SLAB_CTOR_CONSTRUCTOR) { + spin_lock_init(&ei->cache_lru_lock); ei->nr_caches = 0; INIT_LIST_HEAD(&ei->cache_lru); INIT_HLIST_NODE(&ei->i_fat_hash); @@ -820,7 +821,6 @@ int fat_fill_super(struct super_block *s if (error) goto out_fail; - spin_lock_init(&MSDOS_SB(sb)->cache_lock); /* set up enough so that it can read an inode */ init_MUTEX(&sbi->fat_lock); diff -puN include/linux/msdos_fs_i.h~fat-cache-lock-from-per-sb-to-per-inode-3-6 include/linux/msdos_fs_i.h --- 25/include/linux/msdos_fs_i.h~fat-cache-lock-from-per-sb-to-per-inode-3-6 2004-09-11 17:07:36.018465400 -0700 +++ 25-akpm/include/linux/msdos_fs_i.h 2004-09-11 17:07:36.027464032 -0700 @@ -8,6 +8,7 @@ */ struct msdos_inode_info { + spinlock_t cache_lru_lock; struct list_head cache_lru; int nr_caches; diff -puN include/linux/msdos_fs_sb.h~fat-cache-lock-from-per-sb-to-per-inode-3-6 include/linux/msdos_fs_sb.h --- 25/include/linux/msdos_fs_sb.h~fat-cache-lock-from-per-sb-to-per-inode-3-6 2004-09-11 17:07:36.020465096 -0700 +++ 25-akpm/include/linux/msdos_fs_sb.h 2004-09-11 17:07:36.027464032 -0700 @@ -48,8 +48,6 @@ struct msdos_sb_info { void *dir_ops; /* Opaque; default directory operations */ int dir_per_block; /* dir entries per block */ int dir_per_block_bits; /* log2(dir_per_block) */ - - spinlock_t cache_lock; }; #endif _