All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
@ 2014-02-12 14:25 Vyacheslav Dubeyko
  2014-02-12 16:15 ` Sergei Antonov
  0 siblings, 1 reply; 12+ messages in thread
From: Vyacheslav Dubeyko @ 2014-02-12 14:25 UTC (permalink / raw)
  To: Linux FS devel list
  Cc: Al Viro, ChristophHellwig, Hin-Tak Leung, Andrew Morton

From: Vyacheslav Dubeyko <slava@dubeyko.com>
Subject: [PATCH v3 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 stuctures 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) are little-endian.

Signed-off-by: Vyacheslav Dubeyko <slava@dubeyko.com>
CC: Al Viro <viro@zeniv.linux.org.uk>
CC: Christoph Hellwig <hch@infradead.org>
Tested-by: Hin-Tak Leung <htl10@users.sourceforge.net>
---
 fs/hfsplus/hfsplus_fs.h  |   23 ++++++++++++++++++++
 fs/hfsplus/hfsplus_raw.h |   53 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 08846425b..18ca92c 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -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,23 @@ 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;
+
+	/* TODO: Pointer of JBD */
+
+	struct super_block *sbp;
+};
+
 /*
  * Attributes file states
  */
@@ -146,6 +168,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;
diff --git a/fs/hfsplus/hfsplus_raw.h b/fs/hfsplus/hfsplus_raw.h
index 8ffb3a8..a50ad9d 100644
--- a/fs/hfsplus/hfsplus_raw.h
+++ b/fs/hfsplus/hfsplus_raw.h
@@ -46,6 +46,7 @@
 #define HFSP_SYMLINK_CREATOR	0x72686170	/* 'rhap' */
 
 #define HFSP_MOUNT_VERSION	0x482b4c78	/* 'H+Lx' */
+#define HFSP_MOUNT_JOURNALED_VERSION 0x4846534A	/* 'HFSJ' */
 
 /* Structures used on disk */
 
@@ -105,7 +106,7 @@ struct hfsplus_vh {
 	__be16 version;
 	__be32 attributes;
 	__be32 last_mount_vers;
-	u32 reserved;
+	__be32 journal_info_block;
 
 	__be32 create_date;
 	__be32 modify_date;
@@ -401,4 +402,54 @@ typedef union {
 	struct hfsplus_attr_key attr;
 } __packed hfsplus_btree_key;
 
+/* HFS+ on-disk journal structures */
+struct hfsplus_journal_info_block {
+#define HFSPLUS_JOURNAL_IN_FS		0x01
+#define HFSPLUS_JOURNAL_ON_OTHER_DEVICE	0x02
+#define HFSPLUS_JOURNAL_NEED_INIT	0x04
+	__be32 flags;
+	__be32 device_signature[8];
+	__be64 offset;
+	__be64 size;
+	u32 reserved[32];
+} __packed;
+
+/* Valid magic and endian value */
+#define HFSPLUS_JOURNAL_HEADER_MAGIC	0x4A4E4C78
+#define HFSPLUS_JOURNAL_HEADER_ENDIAN	0x12345678
+
+/* !!! Litle-endian structure !!! */
+struct hfsplus_journal_header {
+	__le32 magic;
+	__le32 endian;
+	__le64 start;
+	__le64 end;
+	__le64 size; /* Includes the header and the buffer */
+	__le32 blhdr_size;
+	__le32 checksum;
+	__le32 jhdr_size;
+} __packed;
+
+/* !!! Litle-endian structure !!! */
+struct hfsplus_block_info {
+	__le64 bnum;
+	__le32 bsize;
+	union {
+		__le32 checksum;
+		__le32 seq_num; /* only used in binfo[0] */
+	} block;
+} __packed;
+
+/* !!! Litle-endian structure !!! */
+struct hfsplus_blhdr {
+	__le16 max_blocks;
+	__le16 num_blocks;
+	__le32 bytes_used;
+	__le32 checksum;
+#define HFSPLUS_BLHDR_CHECK_CHECKSUMS	0x0001
+#define HFSPLUS_BLHDR_FIRST_HEADER	0x0002
+	__le32 flags;
+	struct hfsplus_block_info binfo[1];
+} __packed;
+
 #endif
-- 
1.7.9.5







^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
  2014-02-12 14:25 [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay Vyacheslav Dubeyko
@ 2014-02-12 16:15 ` Sergei Antonov
  2014-02-12 16:38   ` Vyacheslav Dubeyko
  0 siblings, 1 reply; 12+ messages in thread
From: Sergei Antonov @ 2014-02-12 16:15 UTC (permalink / raw)
  To: Vyacheslav Dubeyko
  Cc: Linux FS devel list, Al Viro, ChristophHellwig, Hin-Tak Leung,
	Andrew Morton

On 12 February 2014 15:25, Vyacheslav Dubeyko <slava@dubeyko.com> wrote:
> From: Vyacheslav Dubeyko <slava@dubeyko.com>
> Subject: [PATCH v3 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 stuctures 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) are little-endian.

Journal header and block lists are either big-endian or little-endian.
See JOURNAL_NEED_SWAP in Apple's code.

> Signed-off-by: Vyacheslav Dubeyko <slava@dubeyko.com>
> CC: Al Viro <viro@zeniv.linux.org.uk>
> CC: Christoph Hellwig <hch@infradead.org>
> Tested-by: Hin-Tak Leung <htl10@users.sourceforge.net>
> ---
>  fs/hfsplus/hfsplus_fs.h  |   23 ++++++++++++++++++++
>  fs/hfsplus/hfsplus_raw.h |   53 +++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 75 insertions(+), 1 deletion(-)
>
> diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
> index 08846425b..18ca92c 100644
> --- a/fs/hfsplus/hfsplus_fs.h
> +++ b/fs/hfsplus/hfsplus_fs.h
> @@ -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,23 @@ 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;
> +
> +       /* TODO: Pointer of JBD */
> +
> +       struct super_block *sbp;
> +};
> +
>  /*
>   * Attributes file states
>   */
> @@ -146,6 +168,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;
> diff --git a/fs/hfsplus/hfsplus_raw.h b/fs/hfsplus/hfsplus_raw.h
> index 8ffb3a8..a50ad9d 100644
> --- a/fs/hfsplus/hfsplus_raw.h
> +++ b/fs/hfsplus/hfsplus_raw.h
> @@ -46,6 +46,7 @@
>  #define HFSP_SYMLINK_CREATOR   0x72686170      /* 'rhap' */
>
>  #define HFSP_MOUNT_VERSION     0x482b4c78      /* 'H+Lx' */
> +#define HFSP_MOUNT_JOURNALED_VERSION 0x4846534A        /* 'HFSJ' */
>
>  /* Structures used on disk */
>
> @@ -105,7 +106,7 @@ struct hfsplus_vh {
>         __be16 version;
>         __be32 attributes;
>         __be32 last_mount_vers;
> -       u32 reserved;
> +       __be32 journal_info_block;
>
>         __be32 create_date;
>         __be32 modify_date;
> @@ -401,4 +402,54 @@ typedef union {
>         struct hfsplus_attr_key attr;
>  } __packed hfsplus_btree_key;
>
> +/* HFS+ on-disk journal structures */
> +struct hfsplus_journal_info_block {
> +#define HFSPLUS_JOURNAL_IN_FS          0x01
> +#define HFSPLUS_JOURNAL_ON_OTHER_DEVICE        0x02
> +#define HFSPLUS_JOURNAL_NEED_INIT      0x04
> +       __be32 flags;
> +       __be32 device_signature[8];
> +       __be64 offset;
> +       __be64 size;
> +       u32 reserved[32];
> +} __packed;
> +
> +/* Valid magic and endian value */
> +#define HFSPLUS_JOURNAL_HEADER_MAGIC   0x4A4E4C78
> +#define HFSPLUS_JOURNAL_HEADER_ENDIAN  0x12345678
> +
> +/* !!! Litle-endian structure !!! */

Not necessarily little-endian.

> +struct hfsplus_journal_header {
> +       __le32 magic;
> +       __le32 endian;
> +       __le64 start;
> +       __le64 end;
> +       __le64 size; /* Includes the header and the buffer */
> +       __le32 blhdr_size;
> +       __le32 checksum;
> +       __le32 jhdr_size;
> +} __packed;
> +
> +/* !!! Litle-endian structure !!! */
> +struct hfsplus_block_info {
> +       __le64 bnum;
> +       __le32 bsize;
> +       union {
> +               __le32 checksum;
> +               __le32 seq_num; /* only used in binfo[0] */
> +       } block;
> +} __packed;
> +
> +/* !!! Litle-endian structure !!! */
> +struct hfsplus_blhdr {
> +       __le16 max_blocks;
> +       __le16 num_blocks;
> +       __le32 bytes_used;
> +       __le32 checksum;
> +#define HFSPLUS_BLHDR_CHECK_CHECKSUMS  0x0001
> +#define HFSPLUS_BLHDR_FIRST_HEADER     0x0002
> +       __le32 flags;
> +       struct hfsplus_block_info binfo[1];
> +} __packed;
> +
>  #endif
> --

So in your patchset functions hfsplus_verify_journal_header() etc.
refuse to understand BE journal.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
  2014-02-12 16:15 ` Sergei Antonov
@ 2014-02-12 16:38   ` Vyacheslav Dubeyko
  2014-02-12 16:50     ` Sergei Antonov
  0 siblings, 1 reply; 12+ messages in thread
From: Vyacheslav Dubeyko @ 2014-02-12 16:38 UTC (permalink / raw)
  To: Sergei Antonov
  Cc: Linux FS devel list, Al Viro, ChristophHellwig, Hin-Tak Leung,
	Andrew Morton

On Wed, 2014-02-12 at 17:15 +0100, Sergei Antonov wrote:

> > 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) are little-endian.
> 
> Journal header and block lists are either big-endian or little-endian.
> See JOURNAL_NEED_SWAP in Apple's code.

Do you know how to create journal with BE internal structures? Or have
you examples of journal with such structures? I haven't such examples.
And I can't see such opportunities in newfs_hfs tool. So, I don't think
that Journal header and block lists can be not little-endian. I can't
implement or test something unreal. Could you share the way of creation
HFS+ journal with big-endian Journal header and block lists?

Thanks,
Vyacheaslav Dubeyko.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
  2014-02-12 16:38   ` Vyacheslav Dubeyko
@ 2014-02-12 16:50     ` Sergei Antonov
  2014-02-12 17:59       ` Vyacheslav Dubeyko
  0 siblings, 1 reply; 12+ messages in thread
From: Sergei Antonov @ 2014-02-12 16:50 UTC (permalink / raw)
  To: Vyacheslav Dubeyko
  Cc: Linux FS devel list, Al Viro, ChristophHellwig, Hin-Tak Leung,
	Andrew Morton

On 12 February 2014 17:38, Vyacheslav Dubeyko <slava@dubeyko.com> wrote:
> On Wed, 2014-02-12 at 17:15 +0100, Sergei Antonov wrote:
>
>> > 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) are little-endian.
>>
>> Journal header and block lists are either big-endian or little-endian.
>> See JOURNAL_NEED_SWAP in Apple's code.
>
> Do you know how to create journal with BE internal structures?

You need a PowerPC Mac I guess.

> And I can't see such opportunities in newfs_hfs tool.

Ha! New_hfs does not initialize journal at all.

> Could you share the way of creation
> HFS+ journal with big-endian Journal header and block lists?

As I said, header and block lists are BE.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
  2014-02-12 16:50     ` Sergei Antonov
@ 2014-02-12 17:59       ` Vyacheslav Dubeyko
  2014-02-13 10:41         ` Sergei Antonov
  2014-02-13 20:07         ` Hin-Tak Leung
  0 siblings, 2 replies; 12+ messages in thread
From: Vyacheslav Dubeyko @ 2014-02-12 17:59 UTC (permalink / raw)
  To: Sergei Antonov
  Cc: Linux FS devel list, Al Viro, ChristophHellwig, Hin-Tak Leung,
	Andrew Morton


On Feb 12, 2014, at 7:50 PM, Sergei Antonov wrote:

> On 12 February 2014 17:38, Vyacheslav Dubeyko <slava@dubeyko.com> wrote:
>> On Wed, 2014-02-12 at 17:15 +0100, Sergei Antonov wrote:
>> 
>>>> 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) are little-endian.
>>> 
>>> Journal header and block lists are either big-endian or little-endian.
>>> See JOURNAL_NEED_SWAP in Apple's code.
>> 
>> Do you know how to create journal with BE internal structures?
> 
> You need a PowerPC Mac I guess.
> 

You guess or you know? Please, share concrete way.

>> And I can't see such opportunities in newfs_hfs tool.
> 
> Ha! New_hfs does not initialize journal at all.
> 

Namely, newfs_hfs create journal. Otherwise, what tool does it?

>> Could you share the way of creation
>> HFS+ journal with big-endian Journal header and block lists?
> 
> As I said, header and block lists are BE.

I can only repeat. Could you share the way of creation HFS+ journal
with big-endian Journal header and block lists?

Thanks,
Vyacheslav Dubeyko.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
  2014-02-12 17:59       ` Vyacheslav Dubeyko
@ 2014-02-13 10:41         ` Sergei Antonov
  2014-02-13 10:56           ` Vyacheslav Dubeyko
  2014-02-13 20:07         ` Hin-Tak Leung
  1 sibling, 1 reply; 12+ messages in thread
From: Sergei Antonov @ 2014-02-13 10:41 UTC (permalink / raw)
  To: Vyacheslav Dubeyko
  Cc: Linux FS devel list, Al Viro, ChristophHellwig, Hin-Tak Leung,
	Andrew Morton

On 12 February 2014 18:59, Vyacheslav Dubeyko <slava@dubeyko.com> wrote:
>
> On Feb 12, 2014, at 7:50 PM, Sergei Antonov wrote:
>
>> On 12 February 2014 17:38, Vyacheslav Dubeyko <slava@dubeyko.com> wrote:
>>> On Wed, 2014-02-12 at 17:15 +0100, Sergei Antonov wrote:
>>>
>>>>> 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) are little-endian.
>>>>
>>>> Journal header and block lists are either big-endian or little-endian.
>>>> See JOURNAL_NEED_SWAP in Apple's code.
>>>
>>> Do you know how to create journal with BE internal structures?
>>
>> You need a PowerPC Mac I guess.
>>
>
> You guess or you know? Please, share concrete way.
>
>>> And I can't see such opportunities in newfs_hfs tool.
>>
>> Ha! New_hfs does not initialize journal at all.
>>
>
> Namely, newfs_hfs create journal. Otherwise, what tool does it?
>
>>> Could you share the way of creation
>>> HFS+ journal with big-endian Journal header and block lists?
>>
>> As I said, header and block lists are BE.
>
> I can only repeat. Could you share the way of creation HFS+ journal
> with big-endian Journal header and block lists?
>
> Thanks,
> Vyacheslav Dubeyko.

I saw big-endian journal on Panther installed on PearPC emulator.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
  2014-02-13 10:41         ` Sergei Antonov
@ 2014-02-13 10:56           ` Vyacheslav Dubeyko
  0 siblings, 0 replies; 12+ messages in thread
From: Vyacheslav Dubeyko @ 2014-02-13 10:56 UTC (permalink / raw)
  To: Sergei Antonov
  Cc: Linux FS devel list, Al Viro, ChristophHellwig, Hin-Tak Leung,
	Andrew Morton

On Thu, 2014-02-13 at 11:41 +0100, Sergei Antonov wrote:

> >
> > I can only repeat. Could you share the way of creation HFS+ journal
> > with big-endian Journal header and block lists?
> >
> > Thanks,
> > Vyacheslav Dubeyko.
> 
> I saw big-endian journal on Panther installed on PearPC emulator.

I need to have HFS+ volume with big-endian journal in my hand or clear
description of creation way of such HFS+ volume.

Frankly speaking, I haven't time for installation of some emulator. So,
I would like to have ready image of HFS+ volume in my hand. 

Thanks,
Vyacheslav Dubeyko.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
  2014-02-12 17:59       ` Vyacheslav Dubeyko
  2014-02-13 10:41         ` Sergei Antonov
@ 2014-02-13 20:07         ` Hin-Tak Leung
  2014-02-14  7:22           ` Vyacheslav Dubeyko
  1 sibling, 1 reply; 12+ messages in thread
From: Hin-Tak Leung @ 2014-02-13 20:07 UTC (permalink / raw)
  To: Sergei Antonov, Vyacheslav Dubeyko
  Cc: Linux FS devel list, Al Viro, ChristophHellwig, Andrew Morton

--------------------------------------------
On Wed, 12/2/14, Vyacheslav Dubeyko <slava@dubeyko.com> wrote:

 Subject: Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
 To: "Sergei Antonov" <saproj@gmail.com>
 Cc: "Linux FS devel list" <linux-fsdevel@vger.kernel.org>, "Al Viro" <viro@zeniv.linux.org.uk>, "ChristophHellwig" <hch@infradead.org>, "Hin-Tak Leung" <htl10@users.sourceforge.net>, "Andrew Morton" <akpm@linux-foundation.org>
 Date: Wednesday, 12 February, 2014, 17:59
 
 
 On Feb 12, 2014, at 7:50 PM, Sergei Antonov wrote:
 
 > On 12 February 2014 17:38, Vyacheslav Dubeyko <slava@dubeyko.com>
 wrote:
 >> On Wed, 2014-02-12 at 17:15 +0100, Sergei Antonov
 wrote:
 >> 
 >>>> 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) are little-endian.
 >>> 
 >>> Journal header and block lists are either
 big-endian or little-endian.
 >>> See JOURNAL_NEED_SWAP in Apple's code.
 >> 
 >> Do you know how to create journal with BE internal
 structures?
 > 
 > You need a PowerPC Mac I guess.
 > 
 
 You guess or you know? Please, share concrete way.
 
 >> And I can't see such opportunities in newfs_hfs
 tool.
 > 
 > Ha! New_hfs does not initialize journal at all.
 > 
 
 Namely, newfs_hfs create journal. Otherwise, what tool does
 it?
 
 >> Could you share the way of creation
 >> HFS+ journal with big-endian Journal header and
 block lists?
 > 
 > As I said, header and block lists are BE.
 
 I can only repeat. Could you share the way of creation HFS+
 journal
 with big-endian Journal header and block lists?
 
 Thanks,
 Vyacheslav Dubeyko.
 
 Hi all,

I Have mentioned earlier that I have the powerpc version of Darwin 8 (equivalent
to Mac OS X 10.4) running inside pearpc, and have other uses of it and therefore have given it
some use. I can look into this - and probably will, when I try v3 of  Vyacheslav's patch set.

Darwin 8 does certainly noticed it was uncleanly shut down and display a message about
journal replay the next time it starts; also it seems to notice the journal had been played
with by somebody else - there is a message about invalid/invalidating journal entries
when I ran fsck.hfsplus manually between unclean shut down and restart.
(That's assuming  fsck.hfsplus can cope with disk images written by the powerpc
version of darwin 8 correctly, one way or another - I should hope so, as it is
not unthinkable for a mac user to own both kind of macs).

So it appears that the journal is not emptied by fsck.hfsplus, but simply marked done
and no longer relevant, and the darwin kernel code notices that.

HTH.

Hin-Tak 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
  2014-02-13 20:07         ` Hin-Tak Leung
@ 2014-02-14  7:22           ` Vyacheslav Dubeyko
  2014-02-15  4:04             ` Hin-Tak Leung
  0 siblings, 1 reply; 12+ messages in thread
From: Vyacheslav Dubeyko @ 2014-02-14  7:22 UTC (permalink / raw)
  To: htl10
  Cc: Sergei Antonov, Linux FS devel list, Al Viro, ChristophHellwig,
	Andrew Morton

On Thu, 2014-02-13 at 20:07 +0000, Hin-Tak Leung wrote:
>  
>  Hi all,
> 
> I Have mentioned earlier that I have the powerpc version of Darwin 8 (equivalent
> to Mac OS X 10.4) running inside pearpc, and have other uses of it and therefore have given it
> some use. I can look into this - and probably will, when I try v3 of  Vyacheslav's patch set.
> 

So, had you any error messages when you tried patchset v3? If you really
have HFS+ volume with big-endian structures in journal then failure with
journal replay or volume corruption is inevitable.

> Darwin 8 does certainly noticed it was uncleanly shut down and display a message about
> journal replay the next time it starts; also it seems to notice the journal had been played
> with by somebody else - there is a message about invalid/invalidating journal entries
> when I ran fsck.hfsplus manually between unclean shut down and restart.
> (That's assuming  fsck.hfsplus can cope with disk images written by the powerpc
> version of darwin 8 correctly, one way or another - I should hope so, as it is
> not unthinkable for a mac user to own both kind of macs).
> 
> So it appears that the journal is not emptied by fsck.hfsplus, but simply marked done
> and no longer relevant, and the darwin kernel code notices that.
> 

As far as I can judge, fsck tool doesn't replay journal, usually. It
need to take into account presence of journal with transactions. But
namely file system driver is responsible for journal replay. And, as I
remember correctly, fsck.hfsplus claims about presence of journal and it
suggests to use force option for volume checking in such case.

Thanks,
Vyacheslav Dubeyko.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
  2014-02-14  7:22           ` Vyacheslav Dubeyko
@ 2014-02-15  4:04             ` Hin-Tak Leung
  2014-02-15 14:27               ` Vyacheslav Dubeyko
  0 siblings, 1 reply; 12+ messages in thread
From: Hin-Tak Leung @ 2014-02-15  4:04 UTC (permalink / raw)
  To: Vyacheslav Dubeyko
  Cc: Sergei Antonov, Linux FS devel list, Al Viro, ChristophHellwig,
	Andrew Morton


--------------------------------------------
On Fri, 14/2/14, Vyacheslav Dubeyko <slava@dubeyko.com> wrote:

 Subject: Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
 To: htl10@users.sourceforge.net
 Cc: "Sergei Antonov" <saproj@gmail.com>, "Linux FS devel list" <linux-fsdevel@vger.kernel.org>, "Al Viro" <viro@zeniv.linux.org.uk>, "ChristophHellwig" <hch@infradead.org>, "Andrew Morton" <akpm@linux-foundation.org>
 Date: Friday, 14 February, 2014, 7:22
 
 On Thu, 2014-02-13 at 20:07 +0000,
 Hin-Tak Leung wrote:
 >  
 >  Hi all,
 > 
 > I Have mentioned earlier that I have the powerpc
 version of Darwin 8 (equivalent
 > to Mac OS X 10.4) running inside pearpc, and have other
 uses of it and therefore have given it
 > some use. I can look into this - and probably will,
 when I try v3 of  Vyacheslav's patch set.
 > 
 
 So, had you any error messages when you tried patchset v3?
 If you really
 have HFS+ volume with big-endian structures in journal then
 failure with
 journal replay or volume corruption is inevitable.
 
 > Darwin 8 does certainly noticed it was uncleanly shut
 down and display a message about
 > journal replay the next time it starts; also it seems
 to notice the journal had been played
 > with by somebody else - there is a message about
 invalid/invalidating journal entries
 > when I ran fsck.hfsplus manually between unclean shut
 down and restart.
 > (That's assuming  fsck.hfsplus can cope with disk
 images written by the powerpc
 > version of darwin 8 correctly, one way or another - I
 should hope so, as it is
 > not unthinkable for a mac user to own both kind of
 macs).
 > 
 > So it appears that the journal is not emptied by
 fsck.hfsplus, but simply marked done
 > and no longer relevant, and the darwin kernel code
 notices that.
 > 
 
 As far as I can judge, fsck tool doesn't replay journal,
 usually. It
 need to take into account presence of journal with
 transactions. But
 namely file system driver is responsible for journal replay.
 And, as I
 remember correctly, fsck.hfsplus claims about presence of
 journal and it
 suggests to use force option for volume checking in such
 case.
 
 Thanks,
 Vyacheslav Dubeyko.
 
Hi Vyacheslav,

I am afraid I have bad news for you - Sergei may be right.

This is what shows on an unclean-shutdown image:

[179982.068363] hfsplus: invalid journal header
[179982.068375] hfsplus: journal replay failed, mounting read-only
[179982.068378] hfsplus: filesystem was not cleanly unmounted, mounting read-only
[179982.068380] hfsplus: running fsck.hfsplus is recommended

This is on the clean shutdown after:

[182188.224271] hfsplus: invalid journal header
[182188.224287] hfsplus: journal replay failed, mounting read-only

Obviously my virtual machine is still working, so the file system
must be valid.
I have also recorded that the darwin kernel outputs this when replaying the journal:
 Feb 14 19:15:55 localhost kernel[0]: jnl: replay_journal: from: 3365376 to: 2762752 (joffset 0x1a000)

which might be interesting to try to replicate.

The good news is I have saved the unclean image, and the clean one after,
they compress to just over 600MB each (and expands to 3GB each).
Since they are just darwin 8 (plus some open-source software I tried to work on within)
and *not* full Mac OS X, I suppose you can have them, if you
can find the space for me to upload them to.

As I mentioned earlier that the darwin kernel seems to notice that its filesystem
had been manipulated by fsck.hfsplus. To be precise, it seems
that whenever I had done a fsck.hfsplus between, the darwin kernel outputs this
kind of message:

Feb 12 07:23:20 localhost kernel[0]: jnl: journal start/end pointers reset! (jnl 0x1838e60; s 0x232a00 e 0x722600)
Feb 12 15:22:37 localhost kernel[0]: jnl: journal start/end pointers reset! (jnl 0x17dbe60; s 0x96600 e 0x322600)

So it might be also worth looking at the XNU source what that means,
and whether fsck.hfsplus is behaving correctly on x86_64 linux on manipulating
powerpc HFS+ images.

OTOH, I am happy if you have debug patches, etc to try thing out at this end.

Hin-Tak

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
  2014-02-15  4:04             ` Hin-Tak Leung
@ 2014-02-15 14:27               ` Vyacheslav Dubeyko
  0 siblings, 0 replies; 12+ messages in thread
From: Vyacheslav Dubeyko @ 2014-02-15 14:27 UTC (permalink / raw)
  To: htl10
  Cc: Sergei Antonov, Linux FS devel list, Al Viro, ChristophHellwig,
	Andrew Morton

Hi Hin-Tak,

On Sat, 2014-02-15 at 04:04 +0000, Hin-Tak Leung wrote:
>  
> Hi Vyacheslav,
> 
> I am afraid I have bad news for you - Sergei may be right.
> 
> This is what shows on an unclean-shutdown image:
> 
> [179982.068363] hfsplus: invalid journal header
> [179982.068375] hfsplus: journal replay failed, mounting read-only
> [179982.068378] hfsplus: filesystem was not cleanly unmounted, mounting read-only
> [179982.068380] hfsplus: running fsck.hfsplus is recommended
> 
> This is on the clean shutdown after:
> 
> [182188.224271] hfsplus: invalid journal header
> [182188.224287] hfsplus: journal replay failed, mounting read-only
> 

Ok. Now I can see the issue. :) It is the real evidence. Thank you.

> Obviously my virtual machine is still working, so the file system
> must be valid.
> I have also recorded that the darwin kernel outputs this when replaying the journal:
>  Feb 14 19:15:55 localhost kernel[0]: jnl: replay_journal: from: 3365376 to: 2762752 (joffset 0x1a000)
> 
> which might be interesting to try to replicate.
> 
> The good news is I have saved the unclean image, and the clean one after,
> they compress to just over 600MB each (and expands to 3GB each).
> Since they are just darwin 8 (plus some open-source software I tried to work on within)
> and *not* full Mac OS X, I suppose you can have them, if you
> can find the space for me to upload them to.
> 

It is really great. I send you the information about place and
credentials for upload in private e-mail.

I am looking forward to have these images in my hands for investigation.

> As I mentioned earlier that the darwin kernel seems to notice that its filesystem
> had been manipulated by fsck.hfsplus. To be precise, it seems
> that whenever I had done a fsck.hfsplus between, the darwin kernel outputs this
> kind of message:
> 
> Feb 12 07:23:20 localhost kernel[0]: jnl: journal start/end pointers reset! (jnl 0x1838e60; s 0x232a00 e 0x722600)
> Feb 12 15:22:37 localhost kernel[0]: jnl: journal start/end pointers reset! (jnl 0x17dbe60; s 0x96600 e 0x322600)
> 
> So it might be also worth looking at the XNU source what that means,
> and whether fsck.hfsplus is behaving correctly on x86_64 linux on manipulating
> powerpc HFS+ images.
> 
> OTOH, I am happy if you have debug patches, etc to try thing out at this end.
> 

Thank you for all efforts. I really appreciate it.

Thanks,
Vyacheslav Dubeyko.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay
@ 2014-02-15 16:12 Hin-Tak Leung
  0 siblings, 0 replies; 12+ messages in thread
From: Hin-Tak Leung @ 2014-02-15 16:12 UTC (permalink / raw)
  To: slava; +Cc: saproj, linux-fsdevel, viro, hch, akpm

Hi  Vyacheslav and all,

------------------------------
On Sat, Feb 15, 2014 2:27 PM GMT Vyacheslav Dubeyko wrote:

<snipped>
>It is really great. I send you the information about place and
>credentials for upload in private e-mail.
>
>I am looking forward to have these images in my hands for investigation.

The disk images are currently being uploaded & will probably take another hour before
it finishes.

>> As I mentioned earlier that the darwin kernel seems to notice that its filesystem
>> had been manipulated by fsck.hfsplus. To be precise, it seems
>> that whenever I had done a fsck.hfsplus between, the darwin kernel outputs this
>> kind of message:
>> 
>> Feb 12 07:23:20 localhost kernel[0]: jnl: journal start/end pointers reset! (jnl 0x1838e60; s 0x232a00 e 0x722600)
>> Feb 12 15:22:37 localhost kernel[0]: jnl: journal start/end pointers reset! (jnl 0x17dbe60; s 0x96600 e 0x322600)
>> 
>> So it might be also worth looking at the XNU source what that means,
>> and whether fsck.hfsplus is behaving correctly on x86_64 linux on manipulating
>> powerpc HFS+ images.
>> 
>> OTOH, I am happy if you have debug patches, etc to try thing out at this end.
>> 
>
>Thank you for all efforts. I really appreciate it.

Thank you for your work! I think we are heading where we'll be able to cope
with dual-boot machines between unclean shutdown.

Hin-Tak

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-02-15 16:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-12 14:25 [PATCH v3 01/15] hfsplus: add necessary declarations for journal replay Vyacheslav Dubeyko
2014-02-12 16:15 ` Sergei Antonov
2014-02-12 16:38   ` Vyacheslav Dubeyko
2014-02-12 16:50     ` Sergei Antonov
2014-02-12 17:59       ` Vyacheslav Dubeyko
2014-02-13 10:41         ` Sergei Antonov
2014-02-13 10:56           ` Vyacheslav Dubeyko
2014-02-13 20:07         ` Hin-Tak Leung
2014-02-14  7:22           ` Vyacheslav Dubeyko
2014-02-15  4:04             ` Hin-Tak Leung
2014-02-15 14:27               ` Vyacheslav Dubeyko
2014-02-15 16:12 Hin-Tak Leung

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.