From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 15/16] btrfs: move qgroup init/exit code into open_ctree_seq[] array
Date: Thu, 22 Sep 2022 08:06:32 +0800 [thread overview]
Message-ID: <14e6387b6fef3f50b518e9d9eb8bc3edf81632c9.1663804335.git.wqu@suse.com> (raw)
In-Reply-To: <cover.1663804335.git.wqu@suse.com>
The qgroup related code is already extracted into two functions,
btrfs_read_qgroup_config() and btrfs_free_qgroup_config().
They are perfect matches for open_ctree_seq[], so just move them into
open_ctree_seq[] array.
And with the usage of open_ctree_seq[], there is no more need for @err
variable, just remove it.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/disk-io.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 7d46c9442b0f..14dcec9a23aa 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3897,6 +3897,9 @@ static const struct init_sequence open_ctree_seq[] = {
}, {
.init_func = open_ctree_kthread_init,
.exit_func = open_ctree_kthread_exit,
+ }, {
+ .init_func = btrfs_read_qgroup_config,
+ .exit_func = btrfs_free_qgroup_config,
}
};
@@ -3906,7 +3909,6 @@ int __cold open_ctree(struct super_block *sb, char *options)
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
bool open_ctree_res[ARRAY_SIZE(open_ctree_seq)] = {0};
int ret;
- int err = -EINVAL;
int i;
fs_info->sb = sb;
@@ -3922,10 +3924,6 @@ int __cold open_ctree(struct super_block *sb, char *options)
open_ctree_res[i] = true;
}
- ret = btrfs_read_qgroup_config(fs_info);
- if (ret)
- goto fail;
-
if (btrfs_build_ref_tree(fs_info))
btrfs_err(fs_info, "couldn't build ref tree");
@@ -3934,10 +3932,8 @@ int __cold open_ctree(struct super_block *sb, char *options)
!btrfs_test_opt(fs_info, NOLOGREPLAY)) {
btrfs_info(fs_info, "start tree-log replay");
ret = btrfs_replay_log(fs_info, fs_devices);
- if (ret) {
- err = ret;
- goto fail_qgroup;
- }
+ if (ret)
+ goto fail;
}
if (sb_rdonly(fs_info->sb))
@@ -3974,9 +3970,6 @@ int __cold open_ctree(struct super_block *sb, char *options)
btrfs_clear_oneshot_options(fs_info);
return 0;
-fail_qgroup:
- btrfs_free_qgroup_config(fs_info);
-
fail:
for (i = ARRAY_SIZE(open_ctree_seq) - 1; i >= 0; i--) {
if (!open_ctree_res[i] || !open_ctree_seq[i].exit_func)
@@ -3985,9 +3978,7 @@ int __cold open_ctree(struct super_block *sb, char *options)
open_ctree_res[i] = false;
}
btrfs_close_devices(fs_info->fs_devices);
- if (ret < 0)
- err = ret;
- return err;
+ return ret;
}
ALLOW_ERROR_INJECTION(open_ctree, ERRNO);
--
2.37.3
next prev parent reply other threads:[~2022-09-22 0:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-22 0:06 [PATCH 00/16] btrfs: make open_ctree() init/exit sequence strictly matched Qu Wenruo
2022-09-22 0:06 ` [PATCH 01/16] btrfs: make btrfs module init/exit match their sequence Qu Wenruo
2022-09-22 0:06 ` [PATCH 02/16] btrfs: initialize fs_info->sb at the very beginning of open_ctree() Qu Wenruo
2022-09-22 0:06 ` [PATCH 03/16] btrfs: remove @fs_devices argument from open_ctree() Qu Wenruo
2022-09-22 0:06 ` [PATCH 04/16] btrfs: extract btree inode init code into its own init/exit helpers Qu Wenruo
2022-09-22 0:06 ` [PATCH 05/16] btrfs: extract super block read code into its own init helper Qu Wenruo
2022-09-22 0:06 ` [PATCH 06/16] btrfs: extract mount options and features init " Qu Wenruo
2022-09-22 0:28 ` Qu Wenruo
2022-09-22 0:06 ` [PATCH 07/16] btrfs: move btrfs_init_workqueus() and btrfs_stop_all_workers() into open_ctree_seq[] Qu Wenruo
2022-09-22 0:06 ` [PATCH 08/16] btrfs: extract chunk tree read code into its own init/exit helpers Qu Wenruo
2022-09-22 0:06 ` [PATCH 09/16] btrfs: extract tree roots and zone info initialization into " Qu Wenruo
2022-09-22 0:06 ` [PATCH 10/16] btrfs: extract mount time checks and items load code into its init helper Qu Wenruo
2022-09-22 0:06 ` [PATCH 11/16] btrfs: extract sysfs init into its own helper Qu Wenruo
2022-09-22 0:06 ` [PATCH 12/16] btrfs: extra block groups read code into its own init/exit helpers Qu Wenruo
2022-09-22 0:06 ` [PATCH 13/16] btrfs: move the fs root related " Qu Wenruo
2022-09-22 0:06 ` [PATCH 14/16] btrfs: extract kthread " Qu Wenruo
2022-09-22 0:06 ` Qu Wenruo [this message]
2022-09-22 0:06 ` [PATCH 16/16] btrfs: introduce a debug mount option to do error injection for each stage of open_ctree() Qu Wenruo
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=14e6387b6fef3f50b518e9d9eb8bc3edf81632c9.1663804335.git.wqu@suse.com \
--to=wqu@suse.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).