Skip to contentSkip to conversation

HFS+ journal improvement - take 5

PATCH In review Warren Turkal 2 participants 5 messages Nov 20, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover HFS+ journal improvement - take 5

This is a patchset to change the way that the HFS+ filesystem detects whether a volume has a journal or not.

The code currently mounts an HFS+ volume read-only by default when a journal is detected. One can force a read/write mount by giving the "force" mount option. The current code has this behavior since there is no support for the HFS+ journal.

My problem is that the detection of the journal could be better. The current code tests the attribute bit in the volume header that indicates there is a journal. If that bit is set, the code assumes that there is a journal.

Unfortunately, this is not enough to really determine if there is a journal or not. When that bit is set, one must also examine the journal info block field of the volume header. If this field is 0, there is no journal, and the volume can be mounted read/write.

Thanks,
wt

Warren Turkal (2):
Identify journal info block in volume header.
Fix journal detection on HFS+.

 fs/hfsplus/hfsplus_raw.h |    2 +-
 fs/hfsplus/super.c       |   13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)
#1 lore raw

PATCH 1/2 Identify journal info block in volume header.

The HFS+ support in the kernel currently will mount an HFS+ volume read-only if the volume header has the attribute bit set that indicates there is a journal. The kernel does this because there is no support for a journalled HFS+ volume.

The problem is that this is only half of what needs to be checked to see if there really is a journal. There is also an entry in the volume header that tells you where to find the journal info block. In the kernel version of the kernel, this 4 byte block is labeled reserved. This patch identifies the journal info block in the header.

---
 fs/hfsplus/hfsplus_raw.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/hfsplus/hfsplus_raw.h +1 -1
index fe99fe8..14f1dd8 100644
@@ -94,7 +94,7 @@ struct hfsplus_vh {
 	__be16 version;
 	__be32 attributes;
 	__be32 last_mount_vers;
-	u32 reserved;
+	__be32 journal_info_block;
 
 	__be32 create_date;
 	__be32 modify_date;
Signature · 1 line
1.5.6.3
#2 lore raw

PATCH 2/2 Fix journal detection on HFS+.

The code currently mounts an HFS+ volume read-only (unless given the "force" mount option) if it detects that the HFS+ volume has a journal. The code was unconditionally assuming that the volume had a jounal if the journal attribute was set in the volume header. However, the volume also has to have a non-zero journal info block to actually have a journal.

In this patch, I refactored the journal detection into a function since the logic is used twice. The journal detection also uses the better logic to determine if there is a journal.

---
 fs/hfsplus/super.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
fs/hfsplus/super.c +10 -3
index eb74531..4f00a84 100644
@@ -15,10 +15,17 @@
 #include <linux/vfs.h>
 #include <linux/nls.h>
 
+#include "hfsplus_fs.h"
+
 static struct inode *hfsplus_alloc_inode(struct super_block *sb);
 static void hfsplus_destroy_inode(struct inode *inode);
+static bool hfsplus_vol_has_journal(struct hfsplus_vh *vhdr);
 
-#include "hfsplus_fs.h"
+static bool hfsplus_vol_has_journal(struct hfsplus_vh *vhdr)
+{
+	return (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED) &&
+				vhdr->journal_info_block);
+}
 
 struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
 {
@@ -260,7 +267,7 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data)
 			printk(KERN_WARNING "hfs: filesystem is marked locked, leaving read-only.\n");
 			sb->s_flags |= MS_RDONLY;
 			*flags |= MS_RDONLY;
-		} else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) {
+		} else if (hfsplus_vol_has_journal(vhdr)) {
 			printk(KERN_WARNING "hfs: filesystem is marked journaled, leaving read-only.\n");
 			sb->s_flags |= MS_RDONLY;
 			*flags |= MS_RDONLY;
@@ -356,7 +363,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
 	} else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) {
 		printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n");
 		sb->s_flags |= MS_RDONLY;
-	} else if ((vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) && !(sb->s_flags & MS_RDONLY)) {
+	} else if (hfsplus_vol_has_journal(vhdr) && !(sb->s_flags & MS_RDONLY)) {
 		printk(KERN_WARNING "hfs: write access to a journaled filesystem is not supported, "
 		       "use the force option at your own risk, mounting read-only.\n");
 		sb->s_flags |= MS_RDONLY;
Signature · 1 line
1.5.6.3
Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] Fix journal detection on HFS+.

Quoted 6 lines · Warren Turkal
fs/hfsplus/super.c +0 -0
index eb74531..4f00a84 100644

fs/hfsplus/super.c line 22

Quoted 8 lines
fs/hfsplus/super.c +3 -0
@@ -15,10 +15,17 @@
 #include <linux/vfs.h>
 #include <linux/nls.h>
 
+#include "hfsplus_fs.h"
+
 static struct inode *hfsplus_alloc_inode(struct super_block *sb);
 static void hfsplus_destroy_inode(struct inode *inode);
+static bool hfsplus_vol_has_journal(struct hfsplus_vh *vhdr);

Sorry for not noticing this before. The function declaration is unnecessary. There are no callers before the actual function definition, which is just below.

fs/hfsplus/super.c line 28

Quoted 6 lines
fs/hfsplus/super.c +5 -1
-#include "hfsplus_fs.h"
+static bool hfsplus_vol_has_journal(struct hfsplus_vh *vhdr)
+{
+	return (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED) &&
+				vhdr->journal_info_block);
+}

You're going through a huge number of iterations for such a simple change. Others would have lost patience some time ago. :(

Jörn

Signature · 7 lines
Courage is not the absence of fear, but rather the judgement that
something else is more important than fear.
-- Ambrose Redmoon
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Re: [PATCH 2/2] Fix journal detection on HFS+.

Quoted 10 lines · Jörn Engel
Quoted 9 lines · Warren Turkal
fs/hfsplus/super.c +0 -0
index eb74531..4f00a84 100644
@@ -15,10 +15,17 @@
 #include <linux/vfs.h>
 #include <linux/nls.h>
 
Quoted 9 lines

fs/hfsplus/super.c line 22

Quoted 5 lines
fs/hfsplus/super.c +3 -0
+#include "hfsplus_fs.h"
+
 static struct inode *hfsplus_alloc_inode(struct super_block *sb);
 static void hfsplus_destroy_inode(struct inode *inode);
+static bool hfsplus_vol_has_journal(struct hfsplus_vh *vhdr);

Sorry for not noticing this before. The function declaration is unnecessary. There are no callers before the actual function definition, which is just below.

I will have to get rid of this when I get home tonight.

Quoted 9 lines

fs/hfsplus/super.c line 28

Quoted 6 lines
fs/hfsplus/super.c +5 -1
-#include "hfsplus_fs.h"
+static bool hfsplus_vol_has_journal(struct hfsplus_vh *vhdr)
+{
+     return (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED) &&
+                             vhdr->journal_info_block);
+}

You're going through a huge number of iterations for such a simple change. Others would have lost patience some time ago. :(

Bah...I'm playing in someone else's sandbox, and I have a lot to learn around here. I figure I probably shouldn't second guess the more experienced folks.

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