new_cap = NULL;
} else {
spin_unlock(&inode->i_lock);
- new_cap = kmalloc(sizeof(*cap), GFP_NOFS);
+ new_cap = kmem_cache_alloc(ceph_cap_cachep, GFP_NOFS);
if (new_cap == NULL)
return -ENOMEM;
goto retry;
__ceph_get_fmode(ci, fmode);
spin_unlock(&inode->i_lock);
wake_up(&ci->i_cap_wq);
- kfree(new_cap);
+ if (new_cap)
+ kmem_cache_free(ceph_cap_cachep, new_cap);
return 0;
}
if (ci->i_auth_cap == cap)
ci->i_auth_cap = NULL;
- kfree(cap);
+ kmem_cache_free(ceph_cap_cachep, cap);
if (!__ceph_is_any_caps(ci)) {
list_del_init(&ci->i_snap_realm_item);
return 0;
}
-
/*
- * inode cache
+ * caches
*/
struct kmem_cache *ceph_inode_cachep;
+struct kmem_cache *ceph_cap_cachep;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
-static void init_once(void *foo)
+static void ceph_inode_init_once(void *foo)
#else
-static void init_once(struct kmem_cache *cachep, void *foo)
+static void ceph_inode_init_once(struct kmem_cache *cachep, void *foo)
#endif
{
struct ceph_inode_info *ci = foo;
inode_init_once(&ci->vfs_inode);
}
-static int init_inodecache(void)
+static int init_caches(void)
{
ceph_inode_cachep = kmem_cache_create("ceph_inode_cache",
sizeof(struct ceph_inode_info),
0, (SLAB_RECLAIM_ACCOUNT|
SLAB_MEM_SPREAD),
- init_once);
+ ceph_inode_init_once);
if (ceph_inode_cachep == NULL)
return -ENOMEM;
+
+ ceph_cap_cachep = kmem_cache_create("ceph_caps_cache",
+ sizeof(struct ceph_cap),
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
+ NULL);
+ if (ceph_cap_cachep == NULL) {
+ kmem_cache_destroy(ceph_inode_cachep);
+ return -ENOMEM;
+ }
+
return 0;
}
static void destroy_inodecache(void)
{
kmem_cache_destroy(ceph_inode_cachep);
+ kmem_cache_destroy(ceph_cap_cachep);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
if (ret < 0)
goto out_debugfs;
- ret = init_inodecache();
+ ret = init_caches();
if (ret)
goto out_msgr;
/* inode.c */
extern const struct inode_operations ceph_file_iops;
extern struct kmem_cache *ceph_inode_cachep;
+extern struct kmem_cache *ceph_cap_cachep;
extern struct inode *ceph_alloc_inode(struct super_block *sb);
extern void ceph_destroy_inode(struct inode *inode);