From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: add helper to exit_btrfs_fs
Date: Fri, 14 Oct 2022 20:17:26 +0800 [thread overview]
Message-ID: <a1e9999846422fc971c5bb5f79d517de6530a55a.1665745675.git.anand.jain@oracle.com> (raw)
The module exit function exit_btrfs_fs() is duplicating a section of code
in init_btrfs_fs(). So add a helper function to remove the duplicate code.
Also, remove the comment about the function's .text section, which
doesn't make sense.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
David,
This patch is on top of Qu's patch on the mailing list.
btrfs: make btrfs module init/exit match their sequence
This patch passed, make mrproper, compile with defconfig and Oracle Linux config.
and, Module load/unload.
I suggested this change in the review comment, but it wasn't going anywhere.
Instead, I found sending a patch is more productive. Please, keep my SOB.
fs/btrfs/super.c | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 2356b744828d..0c48bf562aa8 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2791,7 +2791,7 @@ static const struct init_sequence mod_init_seq[] = {
static bool mod_init_result[ARRAY_SIZE(mod_init_seq)];
-static void __exit exit_btrfs_fs(void)
+static void btrfs_exit_btrfs_fs(void)
{
int i;
@@ -2804,6 +2804,11 @@ static void __exit exit_btrfs_fs(void)
}
}
+static void __exit exit_btrfs_fs(void)
+{
+ btrfs_exit_btrfs_fs();
+}
+
static int __init init_btrfs_fs(void)
{
int ret;
@@ -2812,26 +2817,13 @@ static int __init init_btrfs_fs(void)
for (i = 0; i < ARRAY_SIZE(mod_init_seq); i++) {
ASSERT(!mod_init_result[i]);
ret = mod_init_seq[i].init_func();
- if (ret < 0)
- goto error;
+ if (ret < 0) {
+ btrfs_exit_btrfs_fs();
+ return ret;
+ }
mod_init_result[i] = true;
}
return 0;
-
-error:
- /*
- * If we call exit_btrfs_fs() it would cause section mismatch.
- * As init_btrfs_fs() belongs to .init.text, while exit_btrfs_fs()
- * belongs to .exit.text.
- */
- for (i = ARRAY_SIZE(mod_init_seq) - 1; i >= 0; i--) {
- if (!mod_init_result[i])
- continue;
- if (mod_init_seq[i].exit_func)
- mod_init_seq[i].exit_func();
- mod_init_result[i] = false;
- }
- return ret;
}
late_initcall(init_btrfs_fs);
--
2.33.1
next reply other threads:[~2022-10-14 12:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-14 12:17 Anand Jain [this message]
2022-10-17 17:59 ` [PATCH] btrfs: add helper to exit_btrfs_fs David Sterba
2022-10-19 16:27 ` Anand Jain
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=a1e9999846422fc971c5bb5f79d517de6530a55a.1665745675.git.anand.jain@oracle.com \
--to=anand.jain@oracle.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;
as well as URLs for NNTP newsgroup(s).