Skip to contentSkip to conversation

hfsplus: fix issue with unzeroed unused b-tree nodes

PATCH In review Vyacheslav Dubeyko 2 participants 2 messages Feb 12, 2013 – Feb 18, 2013

Subsystems (2)
lore
Share & tools
lore

Vyacheslav Dubeyko

author maintainer
#0 lore raw

PATCH 1/1 hfsplus: fix issue with unzeroed unused b-tree nodes

From: Vyacheslav Dubeyko <[email protected]>
Subject: [PATCH] hfsplus: fix issue with unzeroed unused b-tree nodes

The fsck_hfs (under MacOS X) complains about unzeroed unused b-tree nodes after deletion of folders' tree under Linux.

SYMPTOMS:
Running Disk Utiltiy's "Verify Disk" on "test" gives the following:
Verifying volume “Test”
Checking file systemChecking Journaled HFS Plus volume. Checking extents overflow file.
Checking catalog file.
Unused node is not erased (node = 3111)
Checking multi-linked files.
Checking catalog hierarchy.
Checking extended attributes file.
Checking volume bitmap.
Checking volume information.
The volume Test was found corrupt and needs to be repaired.
Error: This disk needs to be repaired. Click Repair Disk.

REPRODUCING PATH:
1. Prepare HFS+ (non-case sensitive) partition (for example, 5GB) under MacOS X.
2. Copy linux kernel source tree (for example, 3.7-rc6 version) on this partition under MacOS X.
3. Then switch to Linux and mount this prepared partition.
4. Execute sudo rm -r under prepared directory with linux kernel source tree.
5. Unmount and boot back into OS X.
6. Open up Disk Utility and verify partition.

REPRODUCIBILITY: 100%

FIX:
It is added code of node clearing in hfs_bnode_put() method for the case when node has flag HFS_BNODE_DELETED.

---
 fs/hfsplus/bnode.c |    2 ++
 1 file changed, 2 insertions(+)
fs/hfsplus/bnode.c +2 -0
index 1c42cc5..45d7400 100644
@@ -646,6 +646,8 @@ void hfs_bnode_put(struct hfs_bnode *node)
 		if (test_bit(HFS_BNODE_DELETED, &node->flags)) {
 			hfs_bnode_unhash(node);
 			spin_unlock(&tree->hash_lock);
+			hfs_bnode_clear(node, 0,
+				PAGE_CACHE_SIZE * tree->pages_per_bnode);
 			hfs_bmap_free(node);
 			hfs_bnode_free(node);
 			return;
Signature · 8 lines
1.7.9.5



--
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
Acked-by on v1 1/1
#1 lore raw
Quoted 32 lines · Vyacheslav Dubeyko

The fsck_hfs (under MacOS X) complains about unzeroed unused b-tree nodes after deletion of folders' tree under Linux.

SYMPTOMS:
Running Disk Utiltiy's "Verify Disk" on "test" gives the following:
Verifying volume “Test”
Checking file systemChecking Journaled HFS Plus volume. Checking extents overflow file.
Checking catalog file.
Unused node is not erased (node = 3111)
Checking multi-linked files.
Checking catalog hierarchy.
Checking extended attributes file.
Checking volume bitmap.
Checking volume information.
The volume Test was found corrupt and needs to be repaired.
Error: This disk needs to be repaired. Click Repair Disk.

REPRODUCING PATH:
1. Prepare HFS+ (non-case sensitive) partition (for example, 5GB) under MacOS X.
2. Copy linux kernel source tree (for example, 3.7-rc6 version) on this partition under MacOS X.
3. Then switch to Linux and mount this prepared partition.
4. Execute sudo rm -r under prepared directory with linux kernel source tree.
5. Unmount and boot back into OS X.
6. Open up Disk Utility and verify partition.

REPRODUCIBILITY: 100%

Quoted 7 lines

FIX:
It is added code of node clearing in hfs_bnode_put() method for the case when node has flag HFS_BNODE_DELETED.

I may have seen something like this some time ago but lost in the context of other more pressing issues.

It would seems to be some sort of newly added behavior. since both xnu (the mac os x kernel) and fsck.hfsplus are open-source, it might be interesting to pin point when the new behavior was introduced.

Hin-Tak

Quoted 19 lines
---
 fs/hfsplus/bnode.c |    2 ++
 1 file changed, 2 insertions(+)
fs/hfsplus/bnode.c +0 -0
index 1c42cc5..45d7400 100644
@@ -646,6 +646,8 @@ void hfs_bnode_put(struct hfs_bnode
 *node)
         if
 (test_bit(HFS_BNODE_DELETED, &node->flags)) {
            
 hfs_bnode_unhash(node);
            

spin_unlock(&tree->hash_lock);
+
hfs_bnode_clear(node, 0,
+

Quoted 14 lines

    PAGE_CACHE_SIZE *
tree->pages_per_bnode);

hfs_bmap_free(node);

hfs_bnode_free(node);

return;

Signature · 1 line
1.7.9.5

--
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