jbd2: clean up feature test macros with predicate functions
Create separate predicate functions to test/set/clear feature flags, thereby replacing the wordy old macros. Furthermore, clean out the places where we open-coded feature tests. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:

committed by
Theodore Ts'o

parent
e2b911c535
commit
56316a0d28
@@ -278,6 +278,7 @@ typedef struct journal_superblock_s
|
||||
/* 0x0400 */
|
||||
} journal_superblock_t;
|
||||
|
||||
/* Use the jbd2_{has,set,clear}_feature_* helpers; these will be removed */
|
||||
#define JBD2_HAS_COMPAT_FEATURE(j,mask) \
|
||||
((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
|
||||
@@ -288,7 +289,7 @@ typedef struct journal_superblock_s
|
||||
((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
|
||||
|
||||
#define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001
|
||||
#define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001
|
||||
|
||||
#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
|
||||
#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
|
||||
@@ -296,6 +297,8 @@ typedef struct journal_superblock_s
|
||||
#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
|
||||
#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
|
||||
|
||||
/* See "journal feature predicate functions" below */
|
||||
|
||||
/* Features known to this kernel version: */
|
||||
#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
|
||||
#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
|
||||
@@ -1034,6 +1037,69 @@ struct journal_s
|
||||
__u32 j_csum_seed;
|
||||
};
|
||||
|
||||
/* journal feature predicate functions */
|
||||
#define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \
|
||||
static inline bool jbd2_has_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
return ((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_compat & \
|
||||
cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname)) != 0); \
|
||||
} \
|
||||
static inline void jbd2_set_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_compat |= \
|
||||
cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
|
||||
} \
|
||||
static inline void jbd2_clear_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_compat &= \
|
||||
~cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
|
||||
}
|
||||
|
||||
#define JBD2_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
|
||||
static inline bool jbd2_has_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
return ((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_ro_compat & \
|
||||
cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname)) != 0); \
|
||||
} \
|
||||
static inline void jbd2_set_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_ro_compat |= \
|
||||
cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
|
||||
} \
|
||||
static inline void jbd2_clear_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_ro_compat &= \
|
||||
~cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
|
||||
}
|
||||
|
||||
#define JBD2_FEATURE_INCOMPAT_FUNCS(name, flagname) \
|
||||
static inline bool jbd2_has_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
return ((j)->j_format_version >= 2 && \
|
||||
((j)->j_superblock->s_feature_incompat & \
|
||||
cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname)) != 0); \
|
||||
} \
|
||||
static inline void jbd2_set_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_incompat |= \
|
||||
cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
|
||||
} \
|
||||
static inline void jbd2_clear_feature_##name(journal_t *j) \
|
||||
{ \
|
||||
(j)->j_superblock->s_feature_incompat &= \
|
||||
~cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
|
||||
}
|
||||
|
||||
JBD2_FEATURE_COMPAT_FUNCS(checksum, CHECKSUM)
|
||||
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(revoke, REVOKE)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
|
||||
JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
|
||||
|
||||
/*
|
||||
* Journal flag definitions
|
||||
*/
|
||||
@@ -1340,8 +1406,7 @@ extern size_t journal_tag_bytes(journal_t *journal);
|
||||
|
||||
static inline bool jbd2_journal_has_csum_v2or3_feature(journal_t *j)
|
||||
{
|
||||
return JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2) ||
|
||||
JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3);
|
||||
return jbd2_has_feature_csum2(j) || jbd2_has_feature_csum3(j);
|
||||
}
|
||||
|
||||
static inline int jbd2_journal_has_csum_v2or3(journal_t *journal)
|
||||
|
Reference in New Issue
Block a user