@@ -2478,13 +2478,6 @@ static void unregister_btrfs(void)
unregister_filesystem(&btrfs_fs_type);
}
-/* Helper structure for long init/exit functions. */
-struct init_sequence {
- int (*init_func)(void);
- /* Can be NULL if the init_func doesn't need cleanup. */
- void (*exit_func)(void);
-};
-
static const struct init_sequence mod_init_seq[] = {
{
.init_func = btrfs_props_init,
@@ -2551,40 +2544,15 @@ static const struct init_sequence mod_init_seq[] = {
static bool mod_init_result[ARRAY_SIZE(mod_init_seq)];
-static __always_inline void btrfs_exit_btrfs_fs(void)
-{
- int i;
-
- 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;
- }
-}
-
static void __exit exit_btrfs_fs(void)
{
- btrfs_exit_btrfs_fs();
+ exit_sequence_fs(mod_init_seq, mod_init_result, ARRAY_SIZE(mod_init_seq));
btrfs_cleanup_fs_uuids();
}
static int __init init_btrfs_fs(void)
{
- int ret;
- int i;
-
- 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) {
- btrfs_exit_btrfs_fs();
- return ret;
- }
- mod_init_result[i] = true;
- }
- return 0;
+ return init_sequence_fs(mod_init_seq, mod_init_result, ARRAY_SIZE(mod_init_seq));
}
late_initcall(init_btrfs_fs);
@@ -7328,13 +7328,6 @@ static void unregister_ext(void)
unregister_filesystem(&ext4_fs_type);
}
-/* Helper structure for long init/exit functions. */
-struct init_sequence {
- int (*init_func)(void);
- /* Can be NULL if the init_func doesn't need cleanup. */
- void (*exit_func)(void);
-};
-
static const struct init_sequence mod_init_seq[] = {
{
.init_func = ext4_init_es,
@@ -7371,40 +7364,10 @@ static const struct init_sequence mod_init_seq[] = {
static bool mod_init_result[ARRAY_SIZE(mod_init_seq)];
-static __always_inline void ext4_exit_ext4_fs(void)
-{
- int i;
-
- 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;
- }
-}
-
static void __exit ext4_exit_fs(void)
{
ext4_destroy_lazyinit_thread();
- ext4_exit_ext4_fs();
-}
-
-static __always_inline int ext4_init_ext4_fs(void)
-{
- int ret;
- int i;
-
- 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) {
- ext4_exit_ext4_fs();
- return ret;
- }
- mod_init_result[i] = true;
- }
- return 0;
+ exit_sequence_fs(mod_init_seq, mod_init_result, ARRAY_SIZE(mod_init_seq));
}
/* Shared across all ext4 file systems */
@@ -7421,7 +7384,7 @@ static int __init ext4_init_fs(void)
for (int i = 0; i < EXT4_WQ_HASH_SZ; i++)
init_waitqueue_head(&ext4__ioend_wq[i]);
- return ext4_init_ext4_fs();
+ return init_sequence_fs(mod_init_seq, mod_init_result, ARRAY_SIZE(mod_init_seq));
}
MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
@@ -4950,13 +4950,6 @@ static void unregister_f2fs(void)
unregister_filesystem(&f2fs_fs_type);
}
-/* Helper structure for long init/exit functions. */
-struct init_sequence {
- int (*init_func)(void);
- /* Can be NULL if the init_func doesn't need cleanup. */
- void (*exit_func)(void);
-};
-
static const struct init_sequence mod_init_seq[] = {
{
.init_func = init_inodecache,
@@ -5017,39 +5010,14 @@ static const struct init_sequence mod_init_seq[] = {
static bool mod_init_result[ARRAY_SIZE(mod_init_seq)];
-static __always_inline void f2fs_exit_f2fs_fs(void)
-{
- int i;
-
- 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;
- }
-}
-
static void __exit exit_f2fs_fs(void)
{
- f2fs_exit_f2fs_fs();
+ exit_sequence_fs(mod_init_seq, mod_init_result, ARRAY_SIZE(mod_init_seq));
}
static int __init init_f2fs_fs(void)
{
- int ret;
- int i;
-
- for (i = 0; i < ARRAY_SIZE(mod_init_seq); i++) {
- BUG_ON(mod_init_result[i]);
- ret = mod_init_seq[i].init_func();
- if (ret < 0) {
- f2fs_exit_f2fs_fs();
- return ret;
- }
- mod_init_result[i] = true;
- }
- return 0;
+ return init_sequence_fs(mod_init_seq, mod_init_result, ARRAY_SIZE(mod_init_seq));
}
module_init(init_f2fs_fs)
@@ -2598,6 +2598,44 @@ extern void iput(struct inode *);
int inode_update_timestamps(struct inode *inode, int flags);
int generic_update_time(struct inode *, int);
+/* Helper structure for long init/exit functions. */
+struct init_sequence {
+ int (*init_func)(void);
+ /* Can be NULL if the init_func doesn't need cleanup. */
+ void (*exit_func)(void);
+};
+
+static __always_inline void exit_sequence_fs(const struct init_sequence *mod_init_seq,
+ bool *mod_init_result, int num)
+{
+ int i;
+
+ for (i = num - 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;
+ }
+}
+
+static __always_inline int init_sequence_fs(const struct init_sequence *mod_init_seq,
+ bool *mod_init_result, int num)
+{
+ int ret, i;
+
+ for (i = 0; i < num; i++) {
+ BUG_ON(mod_init_result[i]);
+ ret = mod_init_seq[i].init_func();
+ if (ret < 0) {
+ exit_sequence_fs(mod_init_seq, mod_init_result, num);
+ return ret;
+ }
+ mod_init_result[i] = true;
+ }
+ return 0;
+}
+
/* /sys/fs */
extern struct kobject *fs_kobj;