LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: <jaegeuk@kernel.org>
Cc: <linux-f2fs-devel@lists.sourceforge.net>,
	<linux-kernel@vger.kernel.org>, <chao@kernel.org>,
	Chao Yu <yuchao0@huawei.com>
Subject: [PATCH 2/3] f2fs: introduce {create,destroy}_discard_caches for cleanup
Date: Wed, 25 Apr 2018 17:38:30 +0800	[thread overview]
Message-ID: <20180425093831.124591-2-yuchao0@huawei.com> (raw)
In-Reply-To: <20180425093831.124591-1-yuchao0@huawei.com>

Split discard slab cache related initial/release codes into separated
function {create,destroy}_discard_caches, later we can maintain those
independent functions in separated discard.c

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/f2fs.h    |  2 ++
 fs/f2fs/segment.c | 24 ++++++++++++++++--------
 fs/f2fs/super.c   |  8 +++++++-
 3 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 9416669b7105..c8d6d27384f1 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2856,6 +2856,8 @@ int lookup_journal_in_cursum(struct f2fs_journal *journal, int type,
 void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc);
 int build_segment_manager(struct f2fs_sb_info *sbi);
 void destroy_segment_manager(struct f2fs_sb_info *sbi);
+int __init create_discard_caches(void);
+void destroy_discard_caches(void);
 int __init create_segment_manager_caches(void);
 void destroy_segment_manager_caches(void);
 int rw_hint_to_seg_type(enum rw_hint hint);
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index d5627195aa8e..187f957747be 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3993,7 +3993,7 @@ void destroy_segment_manager(struct f2fs_sb_info *sbi)
 	kfree(sm_info);
 }
 
-int __init create_segment_manager_caches(void)
+int __init create_discard_caches(void)
 {
 	discard_entry_slab = f2fs_kmem_cache_create("discard_entry",
 			sizeof(struct discard_entry));
@@ -4004,11 +4004,25 @@ int __init create_segment_manager_caches(void)
 			sizeof(struct discard_cmd));
 	if (!discard_cmd_slab)
 		goto destroy_discard_entry;
+	return 0;
+destroy_discard_entry:
+	kmem_cache_destroy(discard_entry_slab);
+fail:
+	return -ENOMEM;
+}
+
+void destroy_discard_caches(void)
+{
+	kmem_cache_destroy(discard_cmd_slab);
+	kmem_cache_destroy(discard_entry_slab);
+}
 
+int __init create_segment_manager_caches(void)
+{
 	sit_entry_set_slab = f2fs_kmem_cache_create("sit_entry_set",
 			sizeof(struct sit_entry_set));
 	if (!sit_entry_set_slab)
-		goto destroy_discard_cmd;
+		goto fail;
 
 	inmem_entry_slab = f2fs_kmem_cache_create("inmem_page_entry",
 			sizeof(struct inmem_pages));
@@ -4018,10 +4032,6 @@ int __init create_segment_manager_caches(void)
 
 destroy_sit_entry_set:
 	kmem_cache_destroy(sit_entry_set_slab);
-destroy_discard_cmd:
-	kmem_cache_destroy(discard_cmd_slab);
-destroy_discard_entry:
-	kmem_cache_destroy(discard_entry_slab);
 fail:
 	return -ENOMEM;
 }
@@ -4029,7 +4039,5 @@ int __init create_segment_manager_caches(void)
 void destroy_segment_manager_caches(void)
 {
 	kmem_cache_destroy(sit_entry_set_slab);
-	kmem_cache_destroy(discard_cmd_slab);
-	kmem_cache_destroy(discard_entry_slab);
 	kmem_cache_destroy(inmem_entry_slab);
 }
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 7e6fab673073..252133f5d110 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3084,9 +3084,12 @@ static int __init init_f2fs_fs(void)
 	err = create_segment_manager_caches();
 	if (err)
 		goto free_node_manager_caches;
-	err = create_checkpoint_caches();
+	err = create_discard_caches();
 	if (err)
 		goto free_segment_manager_caches;
+	err = create_checkpoint_caches();
+	if (err)
+		goto free_discard_caches;
 	err = create_extent_cache();
 	if (err)
 		goto free_checkpoint_caches;
@@ -3119,6 +3122,8 @@ static int __init init_f2fs_fs(void)
 	destroy_extent_cache();
 free_checkpoint_caches:
 	destroy_checkpoint_caches();
+free_discard_caches:
+	destroy_discard_caches();
 free_segment_manager_caches:
 	destroy_segment_manager_caches();
 free_node_manager_caches:
@@ -3138,6 +3143,7 @@ static void __exit exit_f2fs_fs(void)
 	f2fs_exit_sysfs();
 	destroy_extent_cache();
 	destroy_checkpoint_caches();
+	destroy_discard_caches();
 	destroy_segment_manager_caches();
 	destroy_node_manager_caches();
 	destroy_inodecache();
-- 
2.15.0.55.gc2ece9dc4de6

  reply	other threads:[~2018-04-25  9:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-25  9:38 [PATCH 1/3] f2fs: introduce release_discard_addr() " Chao Yu
2018-04-25  9:38 ` Chao Yu [this message]
2018-04-26 16:08   ` [PATCH 2/3] f2fs: introduce {create,destroy}_discard_caches " Jaegeuk Kim
2018-04-25  9:38 ` [PATCH 3/3] f2fs: maintain discard interface separately Chao Yu
2018-04-26 16:08   ` Jaegeuk Kim

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=20180425093831.124591-2-yuchao0@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 2/3] f2fs: introduce {create,destroy}_discard_caches for cleanup' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).