Message ID | 512e1bb1572d5ffc3557a86a4ce3860420352214.1693900169.git.wqu@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs-progs: cmds/tune: add set/clear features | expand |
On 05/09/2023 15:51, Qu Wenruo wrote: > For the incoming "btrfs tune" subcommand, we will have different > features supported by that subcommand. > > Instead of bloating the runtime and mkfs features, here we just export > btrfs_feature, so each subcommand can have their own definition of > supported features. > Looks good. > And since we're here, also add needed headers for future users of > "fsfeatures.h". > I don't see anything added, missed? Thanks, Anand > Signed-off-by: Qu Wenruo <wqu@suse.com> > --- > common/fsfeatures.c | 53 --------------------------------------------- > common/fsfeatures.h | 50 ++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 50 insertions(+), 53 deletions(-) > > diff --git a/common/fsfeatures.c b/common/fsfeatures.c > index 9ee392d3a8a6..f8eeea7695c1 100644 > --- a/common/fsfeatures.c > +++ b/common/fsfeatures.c > @@ -32,64 +32,11 @@ > #include "common/sysfs-utils.h" > #include "common/messages.h" > > -/* > - * Insert a root item for temporary tree root > - * > - * Only used in make_btrfs_v2(). > - */ > -#define VERSION_TO_STRING3(name, a,b,c) \ > - .name ## _str = #a "." #b "." #c, \ > - .name ## _ver = KERNEL_VERSION(a,b,c) > -#define VERSION_TO_STRING2(name, a,b) \ > - .name ## _str = #a "." #b, \ > - .name ## _ver = KERNEL_VERSION(a,b,0) > -#define VERSION_NULL(name) \ > - .name ## _str = NULL, \ > - .name ## _ver = 0 > - > enum feature_source { > FS_FEATURES, > RUNTIME_FEATURES, > }; > > -/* > - * Feature stability status and versions: compat <= safe <= default > - */ > -struct btrfs_feature { > - const char *name; > - > - /* > - * At least one of the bit must be set in the following *_flag member. > - * > - * For features like list-all and quota which don't have any > - * incompat/compat_ro bit set, it go to runtime_flag. > - */ > - u64 incompat_flag; > - u64 compat_ro_flag; > - u64 runtime_flag; > - > - const char *sysfs_name; > - /* > - * Compatibility with kernel of given version. Filesystem can be > - * mounted. > - */ > - const char *compat_str; > - u32 compat_ver; > - /* > - * Considered safe for use, but is not on by default, even if the > - * kernel supports the feature. > - */ > - const char *safe_str; > - u32 safe_ver; > - /* > - * Considered safe for use and will be turned on by default if > - * supported by the running kernel. > - */ > - const char *default_str; > - u32 default_ver; > - const char *desc; > -}; > - > static const struct btrfs_feature mkfs_features[] = { > { > .name = "mixed-bg", > diff --git a/common/fsfeatures.h b/common/fsfeatures.h > index c4ab704862cd..c9fb489d2d79 100644 > --- a/common/fsfeatures.h > +++ b/common/fsfeatures.h > @@ -19,7 +19,9 @@ > > #include "kerncompat.h" > #include <stdio.h> > +#include <linux/version.h> > #include "kernel-lib/sizes.h" > +#include "kernel-shared/uapi/btrfs.h" > > #define BTRFS_MKFS_DEFAULT_NODE_SIZE SZ_16K > > @@ -43,6 +45,54 @@ struct btrfs_mkfs_features { > */ > #define BTRFS_FEATURE_STRING_BUF_SIZE (160) > > +#define VERSION_TO_STRING3(name, a,b,c) \ > + .name ## _str = #a "." #b "." #c, \ > + .name ## _ver = KERNEL_VERSION(a,b,c) > +#define VERSION_TO_STRING2(name, a,b) \ > + .name ## _str = #a "." #b, \ > + .name ## _ver = KERNEL_VERSION(a,b,0) > +#define VERSION_NULL(name) \ > + .name ## _str = NULL, \ > + .name ## _ver = 0 > + > +/* > + * Feature stability status and versions: compat <= safe <= default > + */ > +struct btrfs_feature { > + const char *name; > + > + /* > + * At least one of the bit must be set in the following *_flag member. > + * > + * For features like list-all and quota which don't have any > + * incompat/compat_ro bit set, it go to runtime_flag. > + */ > + u64 incompat_flag; > + u64 compat_ro_flag; > + u64 runtime_flag; > + > + const char *sysfs_name; > + /* > + * Compatibility with kernel of given version. Filesystem can be > + * mounted. > + */ > + const char *compat_str; > + u32 compat_ver; > + /* > + * Considered safe for use, but is not on by default, even if the > + * kernel supports the feature. > + */ > + const char *safe_str; > + u32 safe_ver; > + /* > + * Considered safe for use and will be turned on by default if > + * supported by the running kernel. > + */ > + const char *default_str; > + u32 default_ver; > + const char *desc; > +}; > + > static const struct btrfs_mkfs_features btrfs_mkfs_default_features = { > .compat_ro_flags = BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE | > BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID,
On 2023/9/21 10:02, Anand Jain wrote: > On 05/09/2023 15:51, Qu Wenruo wrote: >> For the incoming "btrfs tune" subcommand, we will have different >> features supported by that subcommand. >> >> Instead of bloating the runtime and mkfs features, here we just export >> btrfs_feature, so each subcommand can have their own definition of >> supported features. >> > > Looks good. > >> And since we're here, also add needed headers for future users of >> "fsfeatures.h". >> > I don't see anything added, missed? My bad, the line is not clear enough. There are two added #include lines inside "fsfeatures.h", as during development I found if we just include "fsfeatures.h" by itself, there would be some missing definitions. Thus we have the following lines: --- a/common/fsfeatures.h +++ b/common/fsfeatures.h @@ -19,7 +19,9 @@ #include "kerncompat.h" #include <stdio.h> +#include <linux/version.h> #include "kernel-lib/sizes.h" +#include "kernel-shared/uapi/btrfs.h" Thanks, Qu > > Thanks, Anand > >> Signed-off-by: Qu Wenruo <wqu@suse.com> >> --- >> common/fsfeatures.c | 53 --------------------------------------------- >> common/fsfeatures.h | 50 ++++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 50 insertions(+), 53 deletions(-) >> >> diff --git a/common/fsfeatures.c b/common/fsfeatures.c >> index 9ee392d3a8a6..f8eeea7695c1 100644 >> --- a/common/fsfeatures.c >> +++ b/common/fsfeatures.c >> @@ -32,64 +32,11 @@ >> #include "common/sysfs-utils.h" >> #include "common/messages.h" >> -/* >> - * Insert a root item for temporary tree root >> - * >> - * Only used in make_btrfs_v2(). >> - */ >> -#define VERSION_TO_STRING3(name, a,b,c) \ >> - .name ## _str = #a "." #b "." #c, \ >> - .name ## _ver = KERNEL_VERSION(a,b,c) >> -#define VERSION_TO_STRING2(name, a,b) \ >> - .name ## _str = #a "." #b, \ >> - .name ## _ver = KERNEL_VERSION(a,b,0) >> -#define VERSION_NULL(name) \ >> - .name ## _str = NULL, \ >> - .name ## _ver = 0 >> - >> enum feature_source { >> FS_FEATURES, >> RUNTIME_FEATURES, >> }; >> -/* >> - * Feature stability status and versions: compat <= safe <= default >> - */ >> -struct btrfs_feature { >> - const char *name; >> - >> - /* >> - * At least one of the bit must be set in the following *_flag >> member. >> - * >> - * For features like list-all and quota which don't have any >> - * incompat/compat_ro bit set, it go to runtime_flag. >> - */ >> - u64 incompat_flag; >> - u64 compat_ro_flag; >> - u64 runtime_flag; >> - >> - const char *sysfs_name; >> - /* >> - * Compatibility with kernel of given version. Filesystem can be >> - * mounted. >> - */ >> - const char *compat_str; >> - u32 compat_ver; >> - /* >> - * Considered safe for use, but is not on by default, even if the >> - * kernel supports the feature. >> - */ >> - const char *safe_str; >> - u32 safe_ver; >> - /* >> - * Considered safe for use and will be turned on by default if >> - * supported by the running kernel. >> - */ >> - const char *default_str; >> - u32 default_ver; >> - const char *desc; >> -}; >> - >> static const struct btrfs_feature mkfs_features[] = { >> { >> .name = "mixed-bg", >> diff --git a/common/fsfeatures.h b/common/fsfeatures.h >> index c4ab704862cd..c9fb489d2d79 100644 >> --- a/common/fsfeatures.h >> +++ b/common/fsfeatures.h >> @@ -19,7 +19,9 @@ >> #include "kerncompat.h" >> #include <stdio.h> >> +#include <linux/version.h> >> #include "kernel-lib/sizes.h" >> +#include "kernel-shared/uapi/btrfs.h" >> #define BTRFS_MKFS_DEFAULT_NODE_SIZE SZ_16K >> @@ -43,6 +45,54 @@ struct btrfs_mkfs_features { >> */ >> #define BTRFS_FEATURE_STRING_BUF_SIZE (160) >> +#define VERSION_TO_STRING3(name, a,b,c) \ >> + .name ## _str = #a "." #b "." #c, \ >> + .name ## _ver = KERNEL_VERSION(a,b,c) >> +#define VERSION_TO_STRING2(name, a,b) \ >> + .name ## _str = #a "." #b, \ >> + .name ## _ver = KERNEL_VERSION(a,b,0) >> +#define VERSION_NULL(name) \ >> + .name ## _str = NULL, \ >> + .name ## _ver = 0 >> + >> +/* >> + * Feature stability status and versions: compat <= safe <= default >> + */ >> +struct btrfs_feature { >> + const char *name; >> + >> + /* >> + * At least one of the bit must be set in the following *_flag >> member. >> + * >> + * For features like list-all and quota which don't have any >> + * incompat/compat_ro bit set, it go to runtime_flag. >> + */ >> + u64 incompat_flag; >> + u64 compat_ro_flag; >> + u64 runtime_flag; >> + >> + const char *sysfs_name; >> + /* >> + * Compatibility with kernel of given version. Filesystem can be >> + * mounted. >> + */ >> + const char *compat_str; >> + u32 compat_ver; >> + /* >> + * Considered safe for use, but is not on by default, even if the >> + * kernel supports the feature. >> + */ >> + const char *safe_str; >> + u32 safe_ver; >> + /* >> + * Considered safe for use and will be turned on by default if >> + * supported by the running kernel. >> + */ >> + const char *default_str; >> + u32 default_ver; >> + const char *desc; >> +}; >> + >> static const struct btrfs_mkfs_features btrfs_mkfs_default_features = { >> .compat_ro_flags = BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE | >> BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID, >
diff --git a/common/fsfeatures.c b/common/fsfeatures.c index 9ee392d3a8a6..f8eeea7695c1 100644 --- a/common/fsfeatures.c +++ b/common/fsfeatures.c @@ -32,64 +32,11 @@ #include "common/sysfs-utils.h" #include "common/messages.h" -/* - * Insert a root item for temporary tree root - * - * Only used in make_btrfs_v2(). - */ -#define VERSION_TO_STRING3(name, a,b,c) \ - .name ## _str = #a "." #b "." #c, \ - .name ## _ver = KERNEL_VERSION(a,b,c) -#define VERSION_TO_STRING2(name, a,b) \ - .name ## _str = #a "." #b, \ - .name ## _ver = KERNEL_VERSION(a,b,0) -#define VERSION_NULL(name) \ - .name ## _str = NULL, \ - .name ## _ver = 0 - enum feature_source { FS_FEATURES, RUNTIME_FEATURES, }; -/* - * Feature stability status and versions: compat <= safe <= default - */ -struct btrfs_feature { - const char *name; - - /* - * At least one of the bit must be set in the following *_flag member. - * - * For features like list-all and quota which don't have any - * incompat/compat_ro bit set, it go to runtime_flag. - */ - u64 incompat_flag; - u64 compat_ro_flag; - u64 runtime_flag; - - const char *sysfs_name; - /* - * Compatibility with kernel of given version. Filesystem can be - * mounted. - */ - const char *compat_str; - u32 compat_ver; - /* - * Considered safe for use, but is not on by default, even if the - * kernel supports the feature. - */ - const char *safe_str; - u32 safe_ver; - /* - * Considered safe for use and will be turned on by default if - * supported by the running kernel. - */ - const char *default_str; - u32 default_ver; - const char *desc; -}; - static const struct btrfs_feature mkfs_features[] = { { .name = "mixed-bg", diff --git a/common/fsfeatures.h b/common/fsfeatures.h index c4ab704862cd..c9fb489d2d79 100644 --- a/common/fsfeatures.h +++ b/common/fsfeatures.h @@ -19,7 +19,9 @@ #include "kerncompat.h" #include <stdio.h> +#include <linux/version.h> #include "kernel-lib/sizes.h" +#include "kernel-shared/uapi/btrfs.h" #define BTRFS_MKFS_DEFAULT_NODE_SIZE SZ_16K @@ -43,6 +45,54 @@ struct btrfs_mkfs_features { */ #define BTRFS_FEATURE_STRING_BUF_SIZE (160) +#define VERSION_TO_STRING3(name, a,b,c) \ + .name ## _str = #a "." #b "." #c, \ + .name ## _ver = KERNEL_VERSION(a,b,c) +#define VERSION_TO_STRING2(name, a,b) \ + .name ## _str = #a "." #b, \ + .name ## _ver = KERNEL_VERSION(a,b,0) +#define VERSION_NULL(name) \ + .name ## _str = NULL, \ + .name ## _ver = 0 + +/* + * Feature stability status and versions: compat <= safe <= default + */ +struct btrfs_feature { + const char *name; + + /* + * At least one of the bit must be set in the following *_flag member. + * + * For features like list-all and quota which don't have any + * incompat/compat_ro bit set, it go to runtime_flag. + */ + u64 incompat_flag; + u64 compat_ro_flag; + u64 runtime_flag; + + const char *sysfs_name; + /* + * Compatibility with kernel of given version. Filesystem can be + * mounted. + */ + const char *compat_str; + u32 compat_ver; + /* + * Considered safe for use, but is not on by default, even if the + * kernel supports the feature. + */ + const char *safe_str; + u32 safe_ver; + /* + * Considered safe for use and will be turned on by default if + * supported by the running kernel. + */ + const char *default_str; + u32 default_ver; + const char *desc; +}; + static const struct btrfs_mkfs_features btrfs_mkfs_default_features = { .compat_ro_flags = BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE | BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID,
For the incoming "btrfs tune" subcommand, we will have different features supported by that subcommand. Instead of bloating the runtime and mkfs features, here we just export btrfs_feature, so each subcommand can have their own definition of supported features. And since we're here, also add needed headers for future users of "fsfeatures.h". Signed-off-by: Qu Wenruo <wqu@suse.com> --- common/fsfeatures.c | 53 --------------------------------------------- common/fsfeatures.h | 50 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 53 deletions(-)