All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabian Frederick <fabf@skynet.be>
To: linux-fsdevel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	Fabian Frederick <fabf@skynet.be>
Subject: [RFC 1/1 linux-next] FS: consolidate inode cache initialization
Date: Mon, 22 Jun 2015 23:08:25 +0200	[thread overview]
Message-ID: <1435007305-19129-1-git-send-email-fabf@skynet.be> (raw)

Currently, all filesystems directly call kmem_cache_create() through
static init_inodecache() and generally use the same slab
flags with <fsname>_inode_cache.

This patch declares _init_inode_cache() in libfs which uses
file_system_fs name to forge cache name and applies the update on AFFS
as an example.

If the idea is interesting, should I send 1 patch for _init_inode_cache()
addition and 1 patch for each FS update ? 

Regards,
Fabian

Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 fs/affs/super.c    | 17 ++++-------------
 fs/libfs.c         | 15 +++++++++++++++
 include/linux/fs.h |  3 +++
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/fs/affs/super.c b/fs/affs/super.c
index 3f89c9e..e7068d6 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -126,18 +126,6 @@ static void init_once(void *foo)
 	inode_init_once(&ei->vfs_inode);
 }
 
-static int __init init_inodecache(void)
-{
-	affs_inode_cachep = kmem_cache_create("affs_inode_cache",
-					     sizeof(struct affs_inode_info),
-					     0, (SLAB_RECLAIM_ACCOUNT|
-						SLAB_MEM_SPREAD),
-					     init_once);
-	if (affs_inode_cachep == NULL)
-		return -ENOMEM;
-	return 0;
-}
-
 static void destroy_inodecache(void)
 {
 	/*
@@ -623,7 +611,10 @@ MODULE_ALIAS_FS("affs");
 
 static int __init init_affs_fs(void)
 {
-	int err = init_inodecache();
+	int err;
+
+	err = _init_inodecache(&affs_inode_cachep, &affs_fs_type,
+			       sizeof(struct affs_inode_info), init_once);
 	if (err)
 		goto out1;
 	err = register_filesystem(&affs_fs_type);
diff --git a/fs/libfs.c b/fs/libfs.c
index 88a4cb4..84531a9 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1203,3 +1203,18 @@ bool is_empty_dir_inode(struct inode *inode)
 	return (inode->i_fop == &empty_dir_operations) &&
 		(inode->i_op == &empty_dir_inode_operations);
 }
+
+int _init_inodecache(struct kmem_cache **cachep, struct file_system_type *fs,
+		     size_t fs_inodeinfo_len, void *init_once)
+{
+	char buf[32];
+
+	sprintf(buf, "%s_inode_cache", fs->name);
+	*cachep = kmem_cache_create(buf, fs_inodeinfo_len, 0,
+				    (SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD),
+				    init_once);
+	if (!*cachep)
+		return -ENOMEM;
+	return 0;
+}
+EXPORT_SYMBOL(_init_inodecache);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 8a81fcb..036a8a2 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2834,6 +2834,9 @@ extern int generic_file_fsync(struct file *, loff_t, loff_t, int);
 
 extern int generic_check_addressable(unsigned, u64);
 
+extern int _init_inodecache(struct kmem_cache **, struct file_system_type *,
+			    size_t, void *);
+
 #ifdef CONFIG_MIGRATION
 extern int buffer_migrate_page(struct address_space *,
 				struct page *, struct page *,
-- 
2.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in

                 reply	other threads:[~2015-06-22 21:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435007305-19129-1-git-send-email-fabf@skynet.be \
    --to=fabf@skynet.be \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.