mirror of
https://github.com/torvalds/linux.git
synced 2024-11-16 00:52:01 +00:00
5565b8e0ad
[BACKGROUND] In theory init_btrfs_fs() and exit_btrfs_fs() should match their sequence, thus normally they should look like this: init_btrfs_fs() | exit_btrfs_fs() ----------------------+------------------------ init_A(); | init_B(); | init_C(); | | exit_C(); | exit_B(); | exit_A(); So is for the error path of init_btrfs_fs(). But it's not the case, some exit functions don't match their init functions sequence in init_btrfs_fs(). Furthermore in init_btrfs_fs(), we need to have a new error label for each new init function we added. This is not really expandable, especially recently we may add several new functions to init_btrfs_fs(). [ENHANCEMENT] The patch will introduce the following things to enhance the situation: - struct init_sequence Just a wrapper of init and exit function pointers. The init function must use int type as return value, thus some init functions need to be updated to return 0. The exit function can be NULL, as there are some init sequence just outputting a message. - struct mod_init_seq[] array This is a const array, recording all the initialization we need to do in init_btrfs_fs(), and the order follows the old init_btrfs_fs(). - bool mod_init_result[] array This is a bool array, recording if we have initialized one entry in mod_init_seq[]. The reason to split mod_init_seq[] and mod_init_result[] is to avoid section mismatch in reference. All init function are in .init.text, but if mod_init_seq[] records the @initialized member it can no longer be const, thus will be put into .data section, and cause modpost warning. For init_btrfs_fs() we just call all init functions in their order in mod_init_seq[] array, and after each call, setting corresponding mod_init_result[] to true. For exit_btrfs_fs() and error handling path of init_btrfs_fs(), we just iterate mod_init_seq[] in reverse order, and skip all uninitialized entry. With this patch, init_btrfs_fs()/exit_btrfs_fs() will be much easier to expand and will always follow the strict order. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
27 lines
766 B
C
27 lines
766 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright (C) 2014 Filipe David Borba Manana <fdmanana@gmail.com>
|
|
*/
|
|
|
|
#ifndef BTRFS_PROPS_H
|
|
#define BTRFS_PROPS_H
|
|
|
|
#include "ctree.h"
|
|
|
|
int __init btrfs_props_init(void);
|
|
|
|
int btrfs_set_prop(struct btrfs_trans_handle *trans, struct inode *inode,
|
|
const char *name, const char *value, size_t value_len,
|
|
int flags);
|
|
int btrfs_validate_prop(const struct btrfs_inode *inode, const char *name,
|
|
const char *value, size_t value_len);
|
|
bool btrfs_ignore_prop(const struct btrfs_inode *inode, const char *name);
|
|
|
|
int btrfs_load_inode_props(struct inode *inode, struct btrfs_path *path);
|
|
|
|
int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
|
|
struct inode *inode,
|
|
struct inode *dir);
|
|
|
|
#endif
|