Commit 71f73bd1 authored by Alexander Viro's avatar Alexander Viro Committed by James Bottomley

[PATCH] presto cache keyed by superblock instead of kdev_t

parent 4d466c1f
......@@ -58,16 +58,15 @@ extern kmem_cache_t * presto_dentry_slab;
#define CACHES_MASK CACHES_SIZE - 1
static struct list_head presto_caches[CACHES_SIZE];
static inline int presto_cache_hash(kdev_t dev)
static inline int presto_cache_hash(struct super_block *s)
{
return (CACHES_MASK) & ((0x000F & (major(dev)) << 8) + (0x000F & minor(dev)));
return (CACHES_MASK) & ((unsigned long)s >> L1_CACHE_SHIFT);
}
inline void presto_cache_add(struct presto_cache *cache, kdev_t dev)
inline void presto_cache_add(struct presto_cache *cache)
{
list_add(&cache->cache_chain,
&presto_caches[presto_cache_hash(dev)]);
cache->cache_dev = dev;
&presto_caches[presto_cache_hash(cache->cache_sb)]);
}
inline void presto_cache_init_hash(void)
......@@ -79,17 +78,16 @@ inline void presto_cache_init_hash(void)
}
/* map a device to a cache */
struct presto_cache *presto_cache_find(kdev_t dev)
struct presto_cache *presto_cache_find(struct super_block *s)
{
struct presto_cache *cache;
struct list_head *lh, *tmp;
lh = tmp = &(presto_caches[presto_cache_hash(dev)]);
lh = tmp = &(presto_caches[presto_cache_hash(s)]);
while ( (tmp = lh->next) != lh ) {
cache = list_entry(tmp, struct presto_cache, cache_chain);
if ( kdev_same(cache->cache_dev, dev) ) {
if (cache->cache_sb == s)
return cache;
}
}
return NULL;
}
......@@ -101,10 +99,10 @@ struct presto_cache *presto_get_cache(struct inode *inode)
struct presto_cache *cache;
ENTRY;
/* find the correct presto_cache here, based on the device */
cache = presto_cache_find(to_kdev_t(inode->i_dev));
cache = presto_cache_find(inode->i_sb);
if ( !cache ) {
CERROR("WARNING: no presto cache for dev %x, ino %ld\n",
inode->i_dev, inode->i_ino);
CERROR("WARNING: no presto cache for %s, ino %ld\n",
inode->i_sb->s_id, inode->i_ino);
EXIT;
return NULL;
}
......@@ -122,7 +120,7 @@ int presto_ispresto(struct inode *inode)
cache = presto_get_cache(inode);
if ( !cache )
return 0;
return kdev_same(to_kdev_t(inode->i_dev), cache->cache_dev);
return inode->i_sb == cache->cache_sb;
}
/* setup a cache structure when we need one */
......
......@@ -118,7 +118,7 @@ static void presto_put_super(struct super_block *sb)
int err;
ENTRY;
cache = presto_cache_find(to_kdev_t(sb->s_dev));
cache = presto_cache_find(sb);
if (!cache) {
EXIT;
goto exit;
......
......@@ -285,7 +285,7 @@ struct super_block * presto_get_sb(struct file_system_type *izo_type,
cache->cache_root = dget(sb->s_root);
/* we now know the dev of the cache: hash the cache */
presto_cache_add(cache, to_kdev_t(sb->s_dev));
presto_cache_add(cache);
err = izo_prepare_fileset(sb->s_root, fileset);
filter_setup_journal_ops(cache->cache_filter, cache->cache_type);
......
......@@ -223,8 +223,6 @@ struct presto_cache {
int cache_flags;
kdev_t cache_dev; /* underlying block device */
char *cache_type; /* filesystem type of cache */
struct filter_fs *cache_filter;
......@@ -425,10 +423,10 @@ int presto_prep(struct dentry *, struct presto_cache **,
struct presto_file_set **);
/* cache.c */
extern struct presto_cache *presto_cache_init(void);
extern inline void presto_cache_add(struct presto_cache *cache, kdev_t dev);
extern inline void presto_cache_add(struct presto_cache *cache);
extern inline void presto_cache_init_hash(void);
struct presto_cache *presto_cache_find(kdev_t dev);
struct presto_cache *presto_cache_find(struct super_block *sb);
#define PRESTO_REQLOW (3 * 4096)
#define PRESTO_REQHIGH (6 * 4096)
......
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