Skip to contentSkip to conversation

hfsplus: add necessary declarations for journal replay

PATCH In review Vyacheslav Dubeyko 1 participant 1 message Feb 23, 2014

Subsystems (2)
lore
Share & tools
lore

Vyacheslav Dubeyko

author maintainer
#0 lore raw

PATCH v4 1/15 hfsplus: add necessary declarations for journal replay

From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH v4 01/15] hfsplus: add necessary declarations for journal replay

The patch adds necessary declarations of HFS+ journal's on-disk structures, declaration of structure for journal's object in memory and different journal related flags.

If HFSPLUS_VOL_JOURNALED is set in the volume header's attributes field, the volume has a journal. The journal data structures consist of a journal info block, journal header, and journal buffer. The journal info block indicates the location and size of the journal header and journal buffer. The journal buffer is the space set aside to hold transactions. The journal header describes which part of the journal buffer is active and contains transactions waiting to be committed.

A single transaction consists of several blocks, including both the data to be written, and the location where that data is to be written. This is represented on disk by a block list header, which describes the number and sizes of the blocks, immediately followed by the contents of those blocks.

The journal info block (struct hfsplus_journal_info_block) is big-endian structure. The rest structures of HFS+ journal (struct hfsplus_journal_header, struct hfsplus_blhdr, struct hfsplus_block_info) can be as little-endian as big-endian. The endian field of struct hfsplus_journal_header defines what endianness has a journal.

---
 fs/hfsplus/hfsplus_fs.h  |   35 +++++++++++++++++++++
 fs/hfsplus/hfsplus_raw.h |   77 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 111 insertions(+), 1 deletion(-)
fs/hfsplus/hfsplus_fs.h +35 -0
index 08846425b..2353eaa 100644
@@ -31,6 +31,11 @@
 #define DBG_BITMAP	0x00000040
 #define DBG_ATTR_MOD	0x00000080
 #define DBG_ACL_MOD	0x00000100
+#define DBG_JOURNAL	0x00000200
+#define DBG_JREPLAY	0x00000400
+#define DBG_JTRANS	0x00000800
+#define DBG_JCOMMIT	0x00001000
+#define DBG_JCHKPT	0x00002000
 
 #if 0
 #define DBG_MASK	(DBG_EXTENT|DBG_INODE|DBG_BNODE_MOD)
@@ -126,6 +131,35 @@ struct hfs_bnode {
 #define HFS_BNODE_DIRTY		3
 #define HFS_BNODE_DELETED	4
 
+/* An HFS+ Journal held in memory */
+struct hfsplus_journal {
+	struct mutex jnl_lock;
+
+	/* Journal info block specific */
+	void *jib_buf;
+	struct hfsplus_journal_info_block *jib;
+
+	/* Journal header specific */
+	void *jh_buf;
+	struct hfsplus_journal_header *jh;
+#define HFSPLUS_JOURNAL_CORRUPTED	0
+#define HFSPLUS_BE_JOURNAL		1
+#define HFSPLUS_LE_JOURNAL		2
+	u8 endianness;
+
+	/* TODO: Pointer of JBD */
+
+	struct super_block *sbp;
+};
+
+#define HFSPLUS_JOURNAL_PTR(ptr) \
+	((struct hfsplus_journal *)(ptr))
+
+#define IS_BE_JOURNAL(jnl) \
+	(HFSPLUS_JOURNAL_PTR(jnl)->endianness == HFSPLUS_BE_JOURNAL)
+#define IS_LE_JOURNAL(jnl) \
+	(HFSPLUS_JOURNAL_PTR(jnl)->endianness == HFSPLUS_LE_JOURNAL)
+
 /*
  * Attributes file states
  */
@@ -146,6 +180,7 @@ struct hfsplus_sb_info {
 	struct hfsplus_vh *s_vhdr;
 	void *s_backup_vhdr_buf;
 	struct hfsplus_vh *s_backup_vhdr;
+	struct hfsplus_journal *jnl;
 	struct hfs_btree *ext_tree;
 	struct hfs_btree *cat_tree;
 	struct hfs_btree *attr_tree;
fs/hfsplus/hfsplus_raw.h +76 -1

93 lines not on this page · raw message

Signature · 1 line
1.7.9.5