Linux-EROFS Archive on lore.kernel.org
 help / color / Atom feed
From: Gao Xiang <gaoxiang25@huawei.com>
To: Chao Yu <yuchao0@huawei.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Christoph Hellwig <hch@infradead.org>,
	Joe Perches <joe@perches.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	<devel@driverdev.osuosl.org>
Cc: linux-erofs@lists.ozlabs.org, LKML <linux-kernel@vger.kernel.org>,
	weidu.du@huawei.com, Miao Xie <miaoxie@huawei.com>
Subject: [PATCH v3 5/7] erofs: kill erofs_{init,exit}_inode_cache
Date: Fri, 30 Aug 2019 11:36:41 +0800
Message-ID: <20190830033643.51019-5-gaoxiang25@huawei.com> (raw)
In-Reply-To: <20190830033643.51019-1-gaoxiang25@huawei.com>

As Christoph said [1] "having this function
seems entirely pointless", I have to kill those.

filesystem                              function name
ext2,f2fs,ext4,isofs,squashfs,cifs,...  init_inodecache

In addition, add a "rcu_barrier()" when exit_fs();

[1] https://lore.kernel.org/r/20190829101545.GC20598@infradead.org/
Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
---
no change.

 fs/erofs/super.c | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 6d3a9bcb8daa..556aae5426d6 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -23,21 +23,6 @@ static void init_once(void *ptr)
 	inode_init_once(&vi->vfs_inode);
 }
 
-static int __init erofs_init_inode_cache(void)
-{
-	erofs_inode_cachep = kmem_cache_create("erofs_inode",
-					       sizeof(struct erofs_vnode), 0,
-					       SLAB_RECLAIM_ACCOUNT,
-					       init_once);
-
-	return erofs_inode_cachep ? 0 : -ENOMEM;
-}
-
-static void erofs_exit_inode_cache(void)
-{
-	kmem_cache_destroy(erofs_inode_cachep);
-}
-
 static struct inode *alloc_inode(struct super_block *sb)
 {
 	struct erofs_vnode *vi =
@@ -531,9 +516,14 @@ static int __init erofs_module_init(void)
 	erofs_check_ondisk_layout_definitions();
 	infoln("initializing erofs " EROFS_VERSION);
 
-	err = erofs_init_inode_cache();
-	if (err)
+	erofs_inode_cachep = kmem_cache_create("erofs_inode",
+					       sizeof(struct erofs_vnode), 0,
+					       SLAB_RECLAIM_ACCOUNT,
+					       init_once);
+	if (!erofs_inode_cachep) {
+		err = -ENOMEM;
 		goto icache_err;
+	}
 
 	err = erofs_init_shrinker();
 	if (err)
@@ -555,7 +545,7 @@ static int __init erofs_module_init(void)
 zip_err:
 	erofs_exit_shrinker();
 shrinker_err:
-	erofs_exit_inode_cache();
+	kmem_cache_destroy(erofs_inode_cachep);
 icache_err:
 	return err;
 }
@@ -565,7 +555,10 @@ static void __exit erofs_module_exit(void)
 	unregister_filesystem(&erofs_fs_type);
 	z_erofs_exit_zip_subsystem();
 	erofs_exit_shrinker();
-	erofs_exit_inode_cache();
+
+	/* Ensure all RCU free inodes are safe before cache is destroyed. */
+	rcu_barrier();
+	kmem_cache_destroy(erofs_inode_cachep);
 	infoln("successfully finalize erofs");
 }
 
-- 
2.17.1


  parent reply index

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-30  3:00 [PATCH v2 1/7] erofs: on-disk format should have explicitly assigned numbers Gao Xiang
2019-08-30  3:00 ` [PATCH v2 2/7] erofs: some marcos are much more readable as a function Gao Xiang
2019-08-30  3:16   ` Joe Perches
2019-08-30  3:20     ` Gao Xiang
2019-08-30  3:36       ` [PATCH v3 1/7] erofs: on-disk format should have explicitly assigned numbers Gao Xiang
2019-08-30  3:36         ` [PATCH v3 2/7] erofs: some macros are much more readable as a function Gao Xiang
2019-08-30  3:38           ` [PATCH v4 " Gao Xiang
2019-08-30  6:11           ` [PATCH v3 " Chao Yu
2019-08-30  3:36         ` [PATCH v3 3/7] erofs: use a better form for complicated on-disk fields Gao Xiang
2019-08-30  3:36         ` [PATCH v3 4/7] erofs: kill __packed for on-disk structures Gao Xiang
2019-08-30  6:16           ` Chao Yu
2019-08-30  3:36         ` Gao Xiang [this message]
2019-08-30  6:17           ` [PATCH v3 5/7] erofs: kill erofs_{init,exit}_inode_cache Chao Yu
2019-08-30  3:36         ` [PATCH v3 6/7] erofs: remove all likely/unlikely annotations Gao Xiang
2019-08-30  6:25           ` Chao Yu
2019-08-30  6:31             ` Gao Xiang
2019-08-30  6:43               ` Chao Yu
2019-08-30 11:55             ` Dan Carpenter
2019-08-30 11:30           ` Dan Carpenter
2019-08-30 12:06             ` Gao Xiang via Linux-erofs
2019-08-30 15:46           ` Christoph Hellwig
2019-08-30 16:04             ` Gao Xiang
2019-08-31 10:57               ` Dan Carpenter
2019-08-30  3:36         ` [PATCH v3 7/7] erofs: redundant assignment in __erofs_get_meta_page() Gao Xiang
2019-08-30  6:25           ` Chao Yu
2019-08-30 16:28           ` Christoph Hellwig
2019-08-30 16:48             ` Gao Xiang
2019-08-30 15:25         ` [PATCH v3 1/7] erofs: on-disk format should have explicitly assigned numbers Gao Xiang
2019-08-30 15:45     ` [PATCH v2 2/7] erofs: some marcos are much more readable as a function Christoph Hellwig
2019-08-30 15:52       ` Gao Xiang
2019-08-30 15:56         ` Gao Xiang
2019-08-30  3:00 ` [PATCH v2 3/7] erofs: use a better form for complicated on-disk fields Gao Xiang
2019-08-30  3:29   ` Chao Yu
2019-08-30  3:00 ` [PATCH v2 4/7] erofs: kill __packed for on-disk structures Gao Xiang
2019-08-30  3:00 ` [PATCH v2 5/7] erofs: kill erofs_{init,exit}_inode_cache Gao Xiang
2019-08-30  3:00 ` [PATCH v2 6/7] erofs: remove all likely/unlikely annotations Gao Xiang
2019-08-30  3:00 ` [PATCH v2 7/7] erofs: reduntant assignment in __erofs_get_meta_page() Gao Xiang
2019-08-30  3:28 ` [PATCH v2 1/7] erofs: on-disk format should have explicitly assigned numbers Chao Yu

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=20190830033643.51019-5-gaoxiang25@huawei.com \
    --to=gaoxiang25@huawei.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=joe@perches.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=weidu.du@huawei.com \
    --cc=yuchao0@huawei.com \
    /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

Linux-EROFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-erofs/0 linux-erofs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-erofs linux-erofs/ https://lore.kernel.org/linux-erofs \
		linux-erofs@lists.ozlabs.org linux-erofs@ozlabs.org
	public-inbox-index linux-erofs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linux-erofs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git