hfsplus: fix "unused node is not erased" error
authorSergei Antonov <[email protected]>
Fri, 6 Jun 2014 21:36:28 +0000 (14:36 -0700)
committerLinus Torvalds <[email protected]>
Fri, 6 Jun 2014 23:08:10 +0000 (16:08 -0700)
commit2cd282a1bc6b9d111b8beee63bea0af735a8a1aa
tree80dff1bb5f089868bdbee433b0308098b2c2e6b4
parent915ab236d3c491f9bb0f6596d03e25b37f4d5a20
hfsplus: fix "unused node is not erased" error

Zero newly allocated extents in the catalog tree if volume attributes
tell us to.  Not doing so we risk getting the "unused node is not
erased" error.  See kHFSUnusedNodeFix flag in Apple's source code for
reference.

There was a previous commit clearing the node when it is freed: commit
899bed05e9f6 ("hfsplus: fix issue with unzeroed unused b-tree nodes").
But it did not handle newly allocated extents (this patch fixes it).
And it zeroed nodes in all trees unconditionally which is an overkill.

This patch adds a condition and also switches to 'tree->node_size' as a
simpler method of getting the length to zero.

Signed-off-by: Sergei Antonov <[email protected]>
Cc: Anton Altaparmakov <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Vyacheslav Dubeyko <[email protected]>
Cc: Hin-Tak Leung <[email protected]>
Cc: Kyle Laracey <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/hfsplus/bnode.c
fs/hfsplus/btree.c
fs/hfsplus/extents.c
fs/hfsplus/hfsplus_fs.h
fs/hfsplus/hfsplus_raw.h
fs/hfsplus/xattr.c