Commit ec1528b0 authored by Hirofumi Ogawa's avatar Hirofumi Ogawa Committed by Linus Torvalds

[PATCH] FAT: cache lock from per sb to per inode

Signed-off-by: default avatarOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f93a1734
...@@ -85,11 +85,10 @@ static int fat_cache_lookup(struct inode *inode, int fclus, ...@@ -85,11 +85,10 @@ static int fat_cache_lookup(struct inode *inode, int fclus,
{ {
static struct fat_cache nohit = { .fcluster = 0, }; static struct fat_cache nohit = { .fcluster = 0, };
struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
struct fat_cache *hit = &nohit, *p; struct fat_cache *hit = &nohit, *p;
int offset = -1; int offset = -1;
spin_lock(&sbi->cache_lock); spin_lock(&MSDOS_I(inode)->cache_lru_lock);
debug_pr("FAT: %s, fclus %d", __FUNCTION__, fclus); debug_pr("FAT: %s, fclus %d", __FUNCTION__, fclus);
list_for_each_entry(p, &MSDOS_I(inode)->cache_lru, cache_list) { list_for_each_entry(p, &MSDOS_I(inode)->cache_lru, cache_list) {
if (p->fcluster <= fclus && hit->fcluster < p->fcluster) { if (p->fcluster <= fclus && hit->fcluster < p->fcluster) {
...@@ -113,7 +112,7 @@ static int fat_cache_lookup(struct inode *inode, int fclus, ...@@ -113,7 +112,7 @@ static int fat_cache_lookup(struct inode *inode, int fclus,
*cached_dclus = cache->dcluster + offset; *cached_dclus = cache->dcluster + offset;
} }
debug_pr("\n"); debug_pr("\n");
spin_unlock(&sbi->cache_lock); spin_unlock(&MSDOS_I(inode)->cache_lru_lock);
return offset; return offset;
} }
...@@ -141,7 +140,6 @@ static struct fat_cache *fat_cache_merge(struct inode *inode, ...@@ -141,7 +140,6 @@ static struct fat_cache *fat_cache_merge(struct inode *inode,
static void fat_cache_add(struct inode *inode, struct fat_cache *new) 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; struct fat_cache *cache, *tmp;
debug_pr("FAT: %s: fclus %d, dclus %d, cont %d\n", __FUNCTION__, debug_pr("FAT: %s: fclus %d, dclus %d, cont %d\n", __FUNCTION__,
...@@ -150,15 +148,15 @@ static void fat_cache_add(struct inode *inode, struct fat_cache *new) ...@@ -150,15 +148,15 @@ static void fat_cache_add(struct inode *inode, struct fat_cache *new)
if (new->fcluster == -1) /* dummy cache */ if (new->fcluster == -1) /* dummy cache */
return; return;
spin_lock(&sbi->cache_lock); spin_lock(&MSDOS_I(inode)->cache_lru_lock);
cache = fat_cache_merge(inode, new); cache = fat_cache_merge(inode, new);
if (cache == NULL) { if (cache == NULL) {
if (MSDOS_I(inode)->nr_caches < fat_max_cache(inode)) { if (MSDOS_I(inode)->nr_caches < fat_max_cache(inode)) {
MSDOS_I(inode)->nr_caches++; MSDOS_I(inode)->nr_caches++;
spin_unlock(&sbi->cache_lock); spin_unlock(&MSDOS_I(inode)->cache_lru_lock);
tmp = fat_cache_alloc(inode); tmp = fat_cache_alloc(inode);
spin_lock(&sbi->cache_lock); spin_lock(&MSDOS_I(inode)->cache_lru_lock);
cache = fat_cache_merge(inode, new); cache = fat_cache_merge(inode, new);
if (cache != NULL) { if (cache != NULL) {
MSDOS_I(inode)->nr_caches--; MSDOS_I(inode)->nr_caches--;
...@@ -183,7 +181,7 @@ static void fat_cache_add(struct inode *inode, struct fat_cache *new) ...@@ -183,7 +181,7 @@ static void fat_cache_add(struct inode *inode, struct fat_cache *new)
cache->fcluster, cache->dcluster, cache->nr_contig); cache->fcluster, cache->dcluster, cache->nr_contig);
} }
debug_pr("\n"); 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(struct inode *inode) ...@@ -205,9 +203,9 @@ static void __fat_cache_inval_inode(struct inode *inode)
void fat_cache_inval_inode(struct inode *inode) 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); __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) int __fat_access(struct super_block *sb, int nr, int new_value)
......
...@@ -735,6 +735,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) ...@@ -735,6 +735,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
SLAB_CTOR_CONSTRUCTOR) { SLAB_CTOR_CONSTRUCTOR) {
spin_lock_init(&ei->cache_lru_lock);
ei->nr_caches = 0; ei->nr_caches = 0;
INIT_LIST_HEAD(&ei->cache_lru); INIT_LIST_HEAD(&ei->cache_lru);
INIT_HLIST_NODE(&ei->i_fat_hash); INIT_HLIST_NODE(&ei->i_fat_hash);
...@@ -820,7 +821,6 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, ...@@ -820,7 +821,6 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
if (error) if (error)
goto out_fail; goto out_fail;
spin_lock_init(&MSDOS_SB(sb)->cache_lock);
/* set up enough so that it can read an inode */ /* set up enough so that it can read an inode */
init_MUTEX(&sbi->fat_lock); init_MUTEX(&sbi->fat_lock);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
struct msdos_inode_info { struct msdos_inode_info {
spinlock_t cache_lru_lock;
struct list_head cache_lru; struct list_head cache_lru;
int nr_caches; int nr_caches;
......
...@@ -48,8 +48,6 @@ struct msdos_sb_info { ...@@ -48,8 +48,6 @@ struct msdos_sb_info {
void *dir_ops; /* Opaque; default directory operations */ void *dir_ops; /* Opaque; default directory operations */
int dir_per_block; /* dir entries per block */ int dir_per_block; /* dir entries per block */
int dir_per_block_bits; /* log2(dir_per_block) */ int dir_per_block_bits; /* log2(dir_per_block) */
spinlock_t cache_lock;
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment