]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: use kmem_cache for ceph_dentry_info
authorSage Weil <sage@newdream.net>
Mon, 20 Jul 2009 18:37:27 +0000 (11:37 -0700)
committerSage Weil <sage@newdream.net>
Mon, 20 Jul 2009 18:37:27 +0000 (11:37 -0700)
We have tons (one per dentry), so use a separate cache.

src/kernel/dir.c
src/kernel/inode.c
src/kernel/super.c
src/kernel/super.h

index 13816b76e593e3f7d87381e446b0b2e1ab8129fb..e1ea029743c01329e9ee5927d0050dabfb1c726a 100644 (file)
@@ -930,7 +930,7 @@ static void ceph_dentry_release(struct dentry *dentry)
                ceph_dentry_lru_del(dentry);
                if (di->lease_session)
                        ceph_put_mds_session(di->lease_session);
-               kfree(di);
+               kmem_cache_free(ceph_dentry_cachep, di);
                dentry->d_fsdata = NULL;
        }
 }
index 6758f691a2f7db6b073c6ed4f8a2e52f055555ff..b81b7c45402d5286dcede9730bb1bd987c840a68 100644 (file)
@@ -699,8 +699,7 @@ int ceph_init_dentry_private(struct dentry *dentry)
 
        if (dentry->d_fsdata)
                return 0;
-       di = kmalloc(sizeof(struct ceph_dentry_info),
-                    GFP_NOFS);
+       di = kmem_cache_alloc(ceph_dentry_cachep, GFP_NOFS);
        if (!di)
                return -ENOMEM;          /* oh well */
 
index 46e33dddba127bd444e77a13380c4037aaeecaaa..53ca6c52ab8b44c6b9770e9887b164ba86499d7f 100644 (file)
@@ -153,6 +153,7 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt)
  */
 struct kmem_cache *ceph_inode_cachep;
 struct kmem_cache *ceph_cap_cachep;
+struct kmem_cache *ceph_dentry_cachep;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
 static void ceph_inode_init_once(void *foo)
@@ -179,20 +180,38 @@ static int init_caches(void)
                                              0, (SLAB_RECLAIM_ACCOUNT|
                                                  SLAB_MEM_SPREAD),
                                              NULL);
-       if (ceph_cap_cachep == NULL) {
-               kmem_cache_destroy(ceph_inode_cachep);
-               return -ENOMEM;
-       }
+       if (ceph_cap_cachep == NULL)
+               goto bad_cap;
+
+       ceph_dentry_cachep = kmem_cache_create("ceph_dentry_cache",
+                                             sizeof(struct ceph_dentry_info),
+                                             0, (SLAB_RECLAIM_ACCOUNT|
+                                                 SLAB_MEM_SPREAD),
+                                             NULL);
+       if (ceph_dentry_cachep == NULL)
+               goto bad_dentry;
 
        return 0;
+
+bad_dentry:
+       kmem_cache_destroy(ceph_cap_cachep);
+bad_cap:
+       kmem_cache_destroy(ceph_inode_cachep);
+       return -ENOMEM;
 }
 
 static void destroy_caches(void)
 {
        kmem_cache_destroy(ceph_inode_cachep);
        kmem_cache_destroy(ceph_cap_cachep);
+       kmem_cache_destroy(ceph_dentry_cachep);
 }
 
+
+/*
+ * ceph_umount_begin - initiate forced umount.  Tear down down the
+ * mount, skipping steps that may hang while waiting for server(s).
+ */
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
 static void ceph_umount_begin(struct vfsmount *vfsmnt, int flags)
 #else
index fa535df8fe23018e1a7216b743122d157ce9d3bc..76275060ed34cdabe10e2e3c0bca2806ecba9027 100644 (file)
@@ -763,6 +763,10 @@ static inline bool __ceph_have_pending_cap_snap(struct ceph_inode_info *ci)
 
 
 /* super.c */
+extern struct kmem_cache *ceph_inode_cachep;
+extern struct kmem_cache *ceph_cap_cachep;
+extern struct kmem_cache *ceph_dentry_cachep;
+
 extern const char *ceph_msg_type_name(int type);
 
 static inline __le64 __ceph_fsid_minor(ceph_fsid_t *fsid)
@@ -787,8 +791,6 @@ 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);