1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _BCACHE_FEATURES_H
3 #define _BCACHE_FEATURES_H
5 #include <linux/bcache.h>
6 #include <linux/kernel.h>
7 #include <linux/types.h>
9 #define BCH_FEATURE_COMPAT 0
10 #define BCH_FEATURE_RO_COMPAT 1
11 #define BCH_FEATURE_INCOMPAT 2
12 #define BCH_FEATURE_TYPE_MASK 0x03
14 /* Feature set definition */
15 /* Incompat feature set */
16 #define BCH_FEATURE_INCOMPAT_LARGE_BUCKET 0x0001 /* 32bit bucket size */
18 #define BCH_FEATURE_COMPAT_SUUP 0
19 #define BCH_FEATURE_RO_COMPAT_SUUP 0
20 #define BCH_FEATURE_INCOMPAT_SUUP BCH_FEATURE_INCOMPAT_LARGE_BUCKET
22 #define BCH_HAS_COMPAT_FEATURE(sb, mask) \
23 ((sb)->feature_compat & (mask))
24 #define BCH_HAS_RO_COMPAT_FEATURE(sb, mask) \
25 ((sb)->feature_ro_compat & (mask))
26 #define BCH_HAS_INCOMPAT_FEATURE(sb, mask) \
27 ((sb)->feature_incompat & (mask))
29 #define BCH_FEATURE_COMPAT_FUNCS(name, flagname) \
30 static inline int bch_has_feature_##name(struct cache_sb *sb) \
32 return (((sb)->feature_compat & \
33 BCH##_FEATURE_COMPAT_##flagname) != 0); \
35 static inline void bch_set_feature_##name(struct cache_sb *sb) \
37 (sb)->feature_compat |= \
38 BCH##_FEATURE_COMPAT_##flagname; \
40 static inline void bch_clear_feature_##name(struct cache_sb *sb) \
42 (sb)->feature_compat &= \
43 ~BCH##_FEATURE_COMPAT_##flagname; \
46 #define BCH_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
47 static inline int bch_has_feature_##name(struct cache_sb *sb) \
49 return (((sb)->feature_ro_compat & \
50 BCH##_FEATURE_RO_COMPAT_##flagname) != 0); \
52 static inline void bch_set_feature_##name(struct cache_sb *sb) \
54 (sb)->feature_ro_compat |= \
55 BCH##_FEATURE_RO_COMPAT_##flagname; \
57 static inline void bch_clear_feature_##name(struct cache_sb *sb) \
59 (sb)->feature_ro_compat &= \
60 ~BCH##_FEATURE_RO_COMPAT_##flagname; \
63 #define BCH_FEATURE_INCOMPAT_FUNCS(name, flagname) \
64 static inline int bch_has_feature_##name(struct cache_sb *sb) \
66 return (((sb)->feature_incompat & \
67 BCH##_FEATURE_INCOMPAT_##flagname) != 0); \
69 static inline void bch_set_feature_##name(struct cache_sb *sb) \
71 (sb)->feature_incompat |= \
72 BCH##_FEATURE_INCOMPAT_##flagname; \
74 static inline void bch_clear_feature_##name(struct cache_sb *sb) \
76 (sb)->feature_incompat &= \
77 ~BCH##_FEATURE_INCOMPAT_##flagname; \
80 BCH_FEATURE_INCOMPAT_FUNCS(large_bucket
, LARGE_BUCKET
);
82 int bch_print_cache_set_feature_compat(struct cache_set
*c
, char *buf
, int size
);
83 int bch_print_cache_set_feature_ro_compat(struct cache_set
*c
, char *buf
, int size
);
84 int bch_print_cache_set_feature_incompat(struct cache_set
*c
, char *buf
, int size
);