uint32_t blocknr_high; /* most-significant high 32bits. */
};
+/* Definitions for the journal tag flags word: */
+#define JBD_FLAG_ESCAPE 1 /* on-disk block is escaped */
+#define JBD_FLAG_SAME_UUID 2 /* block has same uuid as previous */
+#define JBD_FLAG_DELETED 4 /* block deleted by this transaction */
+#define JBD_FLAG_LAST_TAG 8 /* last tag in this descriptor block */
+
/* Tail of descriptor block, for checksumming */
struct jbd_block_tail {
uint32_t checksum;
struct ext4_blockdev *bdev;
struct ext4_inode_ref inode_ref;
struct jbd_sb sb;
+
+ bool dirty;
+};
+
+struct jbd_buf {
+ struct ext4_block block;
+ struct ext4_block block_jbd;
+
+ struct jbd_trans *trans;
+
+ LIST_ENTRY(jbd_buf) buf_node;
+};
+
+struct jbd_trans {
+ uint32_t trans_id;
+ LIST_HEAD(jbd_trans_buf, jbd_buf) buf_list;
+ LIST_ENTRY(jbd_trans) trans_node;
+};
+
+struct jbd_journal {
+ uint32_t first;
+ uint32_t start;
+ uint32_t last;
+ uint32_t first_trans_id;
+ uint32_t last_trans_id;
+
+ LIST_HEAD(jbd_trans_list, jbd_trans) trans_list;
+
+ struct jbd_fs *jbd_fs;
};
/*****************************************************************************/
#define EXT4_CRC32_INIT (0xFFFFFFFFUL)
/*****************************************************************************/
-#ifdef CONFIG_BIG_ENDIAN
-static inline uint64_t to_le64(uint64_t n)
+
+static inline uint64_t reorder64(uint64_t n)
{
- return ((n & 0xff) << 56) | ((n & 0xff00) << 40) |
- ((n & 0xff0000) << 24) | ((n & 0xff000000LL) << 8) |
- ((n & 0xff00000000LL) >> 8) | ((n & 0xff0000000000LL) >> 24) |
+ return ((n & 0xff) << 56) |
+ ((n & 0xff00) << 40) |
+ ((n & 0xff0000) << 24) |
+ ((n & 0xff000000LL) << 8) |
+ ((n & 0xff00000000LL) >> 8) |
+ ((n & 0xff0000000000LL) >> 24) |
((n & 0xff000000000000LL) >> 40) |
((n & 0xff00000000000000LL) >> 56);
}
-static inline uint32_t to_le32(uint32_t n)
+static inline uint32_t reorder32(uint32_t n)
{
- return ((n & 0xff) << 24) | ((n & 0xff00) << 8) |
- ((n & 0xff0000) >> 8) | ((n & 0xff000000) >> 24);
+ return ((n & 0xff) << 24) |
+ ((n & 0xff00) << 8) |
+ ((n & 0xff0000) >> 8) |
+ ((n & 0xff000000) >> 24);
}
-static inline uint16_t to_le16(uint16_t n)
+static inline uint16_t reorder16(uint16_t n)
{
- return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
+ return ((n & 0xff) << 8) |
+ ((n & 0xff00) >> 8);
}
+#ifdef CONFIG_BIG_ENDIAN
+#define to_le64(_n) reorder64(_n)
+#define to_le32(_n) reorder32(_n)
+#define to_le16(_n) reorder16(_n)
+
#define to_be64(_n) _n
#define to_be32(_n) _n
#define to_be16(_n) _n
#define to_le32(_n) _n
#define to_le16(_n) _n
-static inline uint64_t to_be64(uint64_t n)
-{
- return ((n & 0xff) << 56) | ((n & 0xff00) << 40) |
- ((n & 0xff0000) << 24) | ((n & 0xff000000LL) << 8) |
- ((n & 0xff00000000LL) >> 8) | ((n & 0xff0000000000LL) >> 24) |
- ((n & 0xff000000000000LL) >> 40) |
- ((n & 0xff00000000000000LL) >> 56);
-}
-
-static inline uint32_t to_be32(uint32_t n)
-{
- return ((n & 0xff) << 24) | ((n & 0xff00) << 8) |
- ((n & 0xff0000) >> 8) | ((n & 0xff000000) >> 24);
-}
-
-static inline uint16_t to_be16(uint16_t n)
-{
- return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
-}
-
+#define to_be64(_n) reorder64(_n)
+#define to_be32(_n) reorder32(_n)
+#define to_be16(_n) reorder16(_n)
#endif
/****************************Access macros to ext4 structures*****************/
(s, f, v) do { (s)->f = (v); } \
while (0)
+/****************************Access macros to jbd2 structures*****************/
+
+#define jbd_get32(s, f) to_be32((s)->f)
+#define jbd_get16(s, f) to_be16((s)->f)
+#define jbd_get8(s, f) (s)->f
+
+#define jbd_set32(s, f, v) \
+ do { \
+ (s)->f = to_be32(v); \
+ } while (0)
+#define jbd_set16(s, f, v) \
+ do { \
+ (s)->f = to_be16(v); \
+ } while (0)
+#define jbd_set8 \
+ (s, f, v) do { (s)->f = (v); } \
+ while (0)
#ifdef __GNUC__
#ifndef __unused