aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/jbd2.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/jbd2.h')
-rw-r--r--include/linux/jbd2.h84
1 files changed, 79 insertions, 5 deletions
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index df07e78487d5..65407f6c9120 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -278,6 +278,7 @@ typedef struct journal_superblock_s
278/* 0x0400 */ 278/* 0x0400 */
279} journal_superblock_t; 279} journal_superblock_t;
280 280
281/* Use the jbd2_{has,set,clear}_feature_* helpers; these will be removed */
281#define JBD2_HAS_COMPAT_FEATURE(j,mask) \ 282#define JBD2_HAS_COMPAT_FEATURE(j,mask) \
282 ((j)->j_format_version >= 2 && \ 283 ((j)->j_format_version >= 2 && \
283 ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask)))) 284 ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
@@ -288,7 +289,7 @@ typedef struct journal_superblock_s
288 ((j)->j_format_version >= 2 && \ 289 ((j)->j_format_version >= 2 && \
289 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask)))) 290 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
290 291
291#define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001 292#define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001
292 293
293#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001 294#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
294#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002 295#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
@@ -296,6 +297,8 @@ typedef struct journal_superblock_s
296#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008 297#define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008
297#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010 298#define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010
298 299
300/* See "journal feature predicate functions" below */
301
299/* Features known to this kernel version: */ 302/* Features known to this kernel version: */
300#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM 303#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
301#define JBD2_KNOWN_ROCOMPAT_FEATURES 0 304#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
@@ -1034,6 +1037,69 @@ struct journal_s
1034 __u32 j_csum_seed; 1037 __u32 j_csum_seed;
1035}; 1038};
1036 1039
1040/* journal feature predicate functions */
1041#define JBD2_FEATURE_COMPAT_FUNCS(name, flagname) \
1042static inline bool jbd2_has_feature_##name(journal_t *j) \
1043{ \
1044 return ((j)->j_format_version >= 2 && \
1045 ((j)->j_superblock->s_feature_compat & \
1046 cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname)) != 0); \
1047} \
1048static inline void jbd2_set_feature_##name(journal_t *j) \
1049{ \
1050 (j)->j_superblock->s_feature_compat |= \
1051 cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
1052} \
1053static inline void jbd2_clear_feature_##name(journal_t *j) \
1054{ \
1055 (j)->j_superblock->s_feature_compat &= \
1056 ~cpu_to_be32(JBD2_FEATURE_COMPAT_##flagname); \
1057}
1058
1059#define JBD2_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
1060static inline bool jbd2_has_feature_##name(journal_t *j) \
1061{ \
1062 return ((j)->j_format_version >= 2 && \
1063 ((j)->j_superblock->s_feature_ro_compat & \
1064 cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname)) != 0); \
1065} \
1066static inline void jbd2_set_feature_##name(journal_t *j) \
1067{ \
1068 (j)->j_superblock->s_feature_ro_compat |= \
1069 cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
1070} \
1071static inline void jbd2_clear_feature_##name(journal_t *j) \
1072{ \
1073 (j)->j_superblock->s_feature_ro_compat &= \
1074 ~cpu_to_be32(JBD2_FEATURE_RO_COMPAT_##flagname); \
1075}
1076
1077#define JBD2_FEATURE_INCOMPAT_FUNCS(name, flagname) \
1078static inline bool jbd2_has_feature_##name(journal_t *j) \
1079{ \
1080 return ((j)->j_format_version >= 2 && \
1081 ((j)->j_superblock->s_feature_incompat & \
1082 cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname)) != 0); \
1083} \
1084static inline void jbd2_set_feature_##name(journal_t *j) \
1085{ \
1086 (j)->j_superblock->s_feature_incompat |= \
1087 cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
1088} \
1089static inline void jbd2_clear_feature_##name(journal_t *j) \
1090{ \
1091 (j)->j_superblock->s_feature_incompat &= \
1092 ~cpu_to_be32(JBD2_FEATURE_INCOMPAT_##flagname); \
1093}
1094
1095JBD2_FEATURE_COMPAT_FUNCS(checksum, CHECKSUM)
1096
1097JBD2_FEATURE_INCOMPAT_FUNCS(revoke, REVOKE)
1098JBD2_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
1099JBD2_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT)
1100JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
1101JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
1102
1037/* 1103/*
1038 * Journal flag definitions 1104 * Journal flag definitions
1039 */ 1105 */
@@ -1046,6 +1112,7 @@ struct journal_s
1046#define JBD2_ABORT_ON_SYNCDATA_ERR 0x040 /* Abort the journal on file 1112#define JBD2_ABORT_ON_SYNCDATA_ERR 0x040 /* Abort the journal on file
1047 * data write error in ordered 1113 * data write error in ordered
1048 * mode */ 1114 * mode */
1115#define JBD2_REC_ERR 0x080 /* The errno in the sb has been recorded */
1049 1116
1050/* 1117/*
1051 * Function declarations for the journaling transaction and buffer 1118 * Function declarations for the journaling transaction and buffer
@@ -1338,13 +1405,17 @@ static inline int tid_geq(tid_t x, tid_t y)
1338extern int jbd2_journal_blocks_per_page(struct inode *inode); 1405extern int jbd2_journal_blocks_per_page(struct inode *inode);
1339extern size_t journal_tag_bytes(journal_t *journal); 1406extern size_t journal_tag_bytes(journal_t *journal);
1340 1407
1408static inline bool jbd2_journal_has_csum_v2or3_feature(journal_t *j)
1409{
1410 return jbd2_has_feature_csum2(j) || jbd2_has_feature_csum3(j);
1411}
1412
1341static inline int jbd2_journal_has_csum_v2or3(journal_t *journal) 1413static inline int jbd2_journal_has_csum_v2or3(journal_t *journal)
1342{ 1414{
1343 if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) || 1415 WARN_ON_ONCE(jbd2_journal_has_csum_v2or3_feature(journal) &&
1344 JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3)) 1416 journal->j_chksum_driver == NULL);
1345 return 1;
1346 1417
1347 return 0; 1418 return journal->j_chksum_driver != NULL;
1348} 1419}
1349 1420
1350/* 1421/*
@@ -1444,4 +1515,7 @@ static inline tid_t jbd2_get_latest_transaction(journal_t *journal)
1444 1515
1445#endif /* __KERNEL__ */ 1516#endif /* __KERNEL__ */
1446 1517
1518#define EFSBADCRC EBADMSG /* Bad CRC detected */
1519#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
1520
1447#endif /* _LINUX_JBD2_H */ 1521#endif /* _LINUX_JBD2_H */