]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: use kmem_cache for caps
authorYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 1 Apr 2009 17:52:41 +0000 (10:52 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 1 Apr 2009 17:52:41 +0000 (10:52 -0700)
src/kernel/caps.c
src/kernel/mds_client.c
src/kernel/super.c
src/kernel/super.h

index b5dd750f2df4ef612531e1d3722070cc8926bc93..d26f663a95cefd4e90a0e82d53ca72690eeccea2 100644 (file)
@@ -245,7 +245,7 @@ retry:
                        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;
@@ -320,7 +320,8 @@ 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;
 }
 
@@ -471,7 +472,7 @@ static void __ceph_remove_cap(struct ceph_cap *cap)
        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);
index f3ebf3b506fd1ae221ff2bdcfe155f06babc4d0a..3426cc185293bb1f0d34791ab38cb46bfb292f3e 100644 (file)
@@ -1128,10 +1128,10 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
 
 out_free2:
        if (freepath2)
-               kfree(path2);
+               kfree((char *)path2);
 out_free1:
        if (freepath1)
-               kfree(path1);
+               kfree((char *)path1);
 out:
        return msg;
 }
index 2eae58e55ff863d86ccec27e0eb9b3b57e70b373..12aa9af45cf53deb3fde83a4fc2d3a551618c881 100644 (file)
@@ -143,37 +143,49 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt)
        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)
@@ -1154,7 +1166,7 @@ static int __init init_ceph(void)
        if (ret < 0)
                goto out_debugfs;
 
-       ret = init_inodecache();
+       ret = init_caches();
        if (ret)
                goto out_msgr;
 
index a89ddc25b2fdf40804b1856330d88678715ae1fe..2a0c68d8a6d354d0014ae93158ca63f04f29379a 100644 (file)
@@ -698,6 +698,7 @@ static inline void __ceph_fsid_set_major(ceph_fsid_t *fsid, __le64 val)
 /* 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);