1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 #ifndef _BCACHE_FEATURES_H 3 #define _BCACHE_FEATURES_H 4 5 #include <linux/bcache.h> 6 #include <linux/kernel.h> 7 #include <linux/types.h> 8 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 13 14 #define BCH_FEATURE_COMPAT_SUUP 0 15 #define BCH_FEATURE_RO_COMPAT_SUUP 0 16 #define BCH_FEATURE_INCOMPAT_SUUP 0 17 18 #define BCH_HAS_COMPAT_FEATURE(sb, mask) \ 19 ((sb)->feature_compat & (mask)) 20 #define BCH_HAS_RO_COMPAT_FEATURE(sb, mask) \ 21 ((sb)->feature_ro_compat & (mask)) 22 #define BCH_HAS_INCOMPAT_FEATURE(sb, mask) \ 23 ((sb)->feature_incompat & (mask)) 24 25 /* Feature set definition */ 26 27 #define BCH_FEATURE_COMPAT_FUNCS(name, flagname) \ 28 static inline int bch_has_feature_##name(struct cache_sb *sb) \ 29 { \ 30 return (((sb)->feature_compat & \ 31 BCH##_FEATURE_COMPAT_##flagname) != 0); \ 32 } \ 33 static inline void bch_set_feature_##name(struct cache_sb *sb) \ 34 { \ 35 (sb)->feature_compat |= \ 36 BCH##_FEATURE_COMPAT_##flagname; \ 37 } \ 38 static inline void bch_clear_feature_##name(struct cache_sb *sb) \ 39 { \ 40 (sb)->feature_compat &= \ 41 ~BCH##_FEATURE_COMPAT_##flagname; \ 42 } 43 44 #define BCH_FEATURE_RO_COMPAT_FUNCS(name, flagname) \ 45 static inline int bch_has_feature_##name(struct cache_sb *sb) \ 46 { \ 47 return (((sb)->feature_ro_compat & \ 48 BCH##_FEATURE_RO_COMPAT_##flagname) != 0); \ 49 } \ 50 static inline void bch_set_feature_##name(struct cache_sb *sb) \ 51 { \ 52 (sb)->feature_ro_compat |= \ 53 BCH##_FEATURE_RO_COMPAT_##flagname; \ 54 } \ 55 static inline void bch_clear_feature_##name(struct cache_sb *sb) \ 56 { \ 57 (sb)->feature_ro_compat &= \ 58 ~BCH##_FEATURE_RO_COMPAT_##flagname; \ 59 } 60 61 #define BCH_FEATURE_INCOMPAT_FUNCS(name, flagname) \ 62 static inline int bch_has_feature_##name(struct cache_sb *sb) \ 63 { \ 64 return (((sb)->feature_incompat & \ 65 BCH##_FEATURE_INCOMPAT_##flagname) != 0); \ 66 } \ 67 static inline void bch_set_feature_##name(struct cache_sb *sb) \ 68 { \ 69 (sb)->feature_incompat |= \ 70 BCH##_FEATURE_INCOMPAT_##flagname; \ 71 } \ 72 static inline void bch_clear_feature_##name(struct cache_sb *sb) \ 73 { \ 74 (sb)->feature_incompat &= \ 75 ~BCH##_FEATURE_INCOMPAT_##flagname; \ 76 } 77 78 #endif 79