public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 13/17] btrfs: move trans_handle_cachep out of ctree.h
Date: Wed, 14 Sep 2022 11:06:37 -0400	[thread overview]
Message-ID: <68e9b87432b738ef6547294d9e5d307cfbdaf13d.1663167823.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1663167823.git.josef@toxicpanda.com>

This is local to the transaction code, remove it from ctree.h and
inode.c, create new helpers in the transaction to handle the init work
and move the cachep locally to transaction.c.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/ctree.h       |  1 -
 fs/btrfs/inode.c       |  8 --------
 fs/btrfs/super.c       |  9 ++++++++-
 fs/btrfs/transaction.c | 17 +++++++++++++++++
 fs/btrfs/transaction.h |  2 ++
 5 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index d99720cf4835..439b205f4207 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -41,7 +41,6 @@ struct btrfs_pending_snapshot;
 struct btrfs_delayed_ref_root;
 struct btrfs_space_info;
 struct btrfs_block_group;
-extern struct kmem_cache *btrfs_trans_handle_cachep;
 extern struct kmem_cache *btrfs_path_cachep;
 extern struct kmem_cache *btrfs_free_space_cachep;
 extern struct kmem_cache *btrfs_free_space_bitmap_cachep;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 998d1c7134ff..78e7f5397d58 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -107,7 +107,6 @@ static const struct address_space_operations btrfs_aops;
 static const struct file_operations btrfs_dir_file_operations;
 
 static struct kmem_cache *btrfs_inode_cachep;
-struct kmem_cache *btrfs_trans_handle_cachep;
 struct kmem_cache *btrfs_path_cachep;
 struct kmem_cache *btrfs_free_space_cachep;
 struct kmem_cache *btrfs_free_space_bitmap_cachep;
@@ -8938,7 +8937,6 @@ void __cold btrfs_destroy_cachep(void)
 	rcu_barrier();
 	bioset_exit(&btrfs_dio_bioset);
 	kmem_cache_destroy(btrfs_inode_cachep);
-	kmem_cache_destroy(btrfs_trans_handle_cachep);
 	kmem_cache_destroy(btrfs_path_cachep);
 	kmem_cache_destroy(btrfs_free_space_cachep);
 	kmem_cache_destroy(btrfs_free_space_bitmap_cachep);
@@ -8953,12 +8951,6 @@ int __init btrfs_init_cachep(void)
 	if (!btrfs_inode_cachep)
 		goto fail;
 
-	btrfs_trans_handle_cachep = kmem_cache_create("btrfs_trans_handle",
-			sizeof(struct btrfs_trans_handle), 0,
-			SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL);
-	if (!btrfs_trans_handle_cachep)
-		goto fail;
-
 	btrfs_path_cachep = kmem_cache_create("btrfs_path",
 			sizeof(struct btrfs_path), 0,
 			SLAB_MEM_SPREAD, NULL);
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 2add5b23c476..9f7fc1c71148 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2737,10 +2737,14 @@ static int __init init_btrfs_fs(void)
 	if (err)
 		goto free_compress;
 
-	err = extent_state_init_cachep();
+	err = btrfs_transaction_init();
 	if (err)
 		goto free_cachep;
 
+	err = extent_state_init_cachep();
+	if (err)
+		goto free_transaction;
+
 	err = extent_buffer_init_cachep();
 	if (err)
 		goto free_extent_cachep;
@@ -2809,6 +2813,8 @@ static int __init init_btrfs_fs(void)
 	extent_buffer_free_cachep();
 free_extent_cachep:
 	extent_state_free_cachep();
+free_transaction:
+	btrfs_transaction_exit();
 free_cachep:
 	btrfs_destroy_cachep();
 free_compress:
@@ -2820,6 +2826,7 @@ static int __init init_btrfs_fs(void)
 
 static void __exit exit_btrfs_fs(void)
 {
+	btrfs_transaction_exit();
 	btrfs_destroy_cachep();
 	btrfs_delayed_ref_exit();
 	btrfs_auto_defrag_exit();
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index d1f1da6820fb..ae7d4aca771d 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -24,6 +24,8 @@
 #include "space-info.h"
 #include "zoned.h"
 
+static struct kmem_cache *btrfs_trans_handle_cachep;
+
 #define BTRFS_ROOT_TRANS_TAG 0
 
 /*
@@ -2600,3 +2602,18 @@ void btrfs_apply_pending_changes(struct btrfs_fs_info *fs_info)
 		btrfs_warn(fs_info,
 			"unknown pending changes left 0x%lx, ignoring", prev);
 }
+
+int __init btrfs_transaction_init(void)
+{
+	btrfs_trans_handle_cachep = kmem_cache_create("btrfs_trans_handle",
+			sizeof(struct btrfs_trans_handle), 0,
+			SLAB_TEMPORARY | SLAB_MEM_SPREAD, NULL);
+	if (!btrfs_trans_handle_cachep)
+		return -ENOMEM;
+	return 0;
+}
+
+void __cold btrfs_transaction_exit(void)
+{
+	kmem_cache_destroy(btrfs_trans_handle_cachep);
+}
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 970ff316069d..b5651c372946 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -236,4 +236,6 @@ void btrfs_add_dropped_root(struct btrfs_trans_handle *trans,
 			    struct btrfs_root *root);
 void btrfs_trans_release_chunk_metadata(struct btrfs_trans_handle *trans);
 
+int __init btrfs_transaction_init(void);
+void __cold btrfs_transaction_exit(void);
 #endif
-- 
2.26.3


  parent reply	other threads:[~2022-09-14 15:07 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 15:06 [PATCH 00/17] btrfs: initial ctree.h cleanups, simple stuff Josef Bacik
2022-09-14 15:06 ` [PATCH 01/17] btrfs: remove set/clear_pending_info helpers Josef Bacik
2022-09-15  9:03   ` Qu Wenruo
2022-09-15 14:11   ` Johannes Thumshirn
2022-10-07 16:51   ` David Sterba
2022-09-14 15:06 ` [PATCH 02/17] btrfs: remove BTRFS_TOTAL_BYTES_PINNED_BATCH Josef Bacik
2022-09-15  9:03   ` Qu Wenruo
2022-09-15 14:11   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 03/17] btrfs: remove BTRFS_IOPRIO_READA Josef Bacik
2022-09-15  9:03   ` Qu Wenruo
2022-09-15 14:12   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 04/17] btrfs: move btrfs on disk definitions out of ctree.h Josef Bacik
2022-09-15  9:07   ` Qu Wenruo
2022-10-07 17:07     ` David Sterba
2022-10-07 23:50       ` Qu Wenruo
2022-09-14 15:06 ` [PATCH 05/17] btrfs: move btrfs_get_block_group helper out of disk-io.h Josef Bacik
2022-09-15  9:10   ` Qu Wenruo
2022-09-15 14:14   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 06/17] btrfs: move maximum limits to btrfs_tree.h Josef Bacik
2022-09-15  9:10   ` Qu Wenruo
2022-09-15 14:15   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 07/17] btrfs: move BTRFS_MAX_MIRRORS into scrub.c Josef Bacik
2022-09-15  9:11   ` Qu Wenruo
2022-09-15 14:16   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 08/17] btrfs: move discard stat defs to free-space-cache.h Josef Bacik
2022-09-15  9:13   ` Qu Wenruo
2022-09-15 14:18   ` Johannes Thumshirn
2022-10-07 17:17     ` David Sterba
2022-10-07 17:16   ` David Sterba
2022-09-14 15:06 ` [PATCH 09/17] btrfs: move btrfs_chunk_item_size out of ctree.h Josef Bacik
2022-09-15  9:14   ` Qu Wenruo
2022-10-07 17:23     ` David Sterba
2022-09-15 14:19   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 10/17] btrfs: move btrfs_should_fragment_free_space into block-group.c Josef Bacik
2022-09-15  9:16   ` Qu Wenruo
2022-09-15 14:21   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 11/17] btrfs: move flush related definitions to space-info.h Josef Bacik
2022-09-15  9:21   ` Qu Wenruo
2022-10-07 17:28     ` David Sterba
2022-09-15 14:21   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 12/17] btrfs: move btrfs_print_data_csum_error into inode.c Josef Bacik
2022-09-15  9:22   ` Qu Wenruo
2022-10-07 17:31     ` David Sterba
2022-09-15 14:23   ` Johannes Thumshirn
2022-09-14 15:06 ` Josef Bacik [this message]
2022-09-15  9:23   ` [PATCH 13/17] btrfs: move trans_handle_cachep out of ctree.h Qu Wenruo
2022-09-15 14:24   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 14/17] btrfs: move btrfs_path_cachep " Josef Bacik
2022-09-15  9:27   ` Qu Wenruo
2022-09-15 14:27   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 15/17] btrfs: move free space cachep's " Josef Bacik
2022-09-15  9:27   ` Qu Wenruo
2022-09-15 14:27   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 16/17] btrfs: move btrfs_next_old_item into ctree.c Josef Bacik
2022-09-15  9:29   ` Qu Wenruo
2022-09-15 14:29   ` Johannes Thumshirn
2022-09-14 15:06 ` [PATCH 17/17] btrfs: move the btrfs_verity_descriptor_item defs up in ctree.h Josef Bacik
2022-09-15  9:30   ` Qu Wenruo
2022-09-15 14:30   ` Johannes Thumshirn
2022-09-15  9:47 ` [PATCH 00/17] btrfs: initial ctree.h cleanups, simple stuff Qu Wenruo
2022-10-07 17:51   ` David Sterba

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=68e9b87432b738ef6547294d9e5d307cfbdaf13d.1663167823.git.josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox