Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement basic repair for broken directory hardlinks. #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dhoepfl
Copy link

@dhoepfl dhoepfl commented Dec 9, 2021

  • Any hardlink inode with a parent other than the metadata directory is changed
    to have the correct parent.
    I have seen these. I can understand how this happens when a normal directory
    is hardlined for the first time. The journal SHOULD prevent this from being a
    problem but obviously this is not the case.

  • Directory hardlink inodes named "temp..." get deleted.
    These directories were deleted while open when the volume was removed without
    unmounting. Since these directories have already been deleted, deleting them
    in fsck is the right thing to do. (Documented like that for files in the HFS+
    spec.)

  • Directory hardlink inodes with names other than "temp..." or "dir_..." are moved
    to "lost+found".
    It would be better to rename them to "dir_..." in a first pass, there might still
    be valid links to them. These links are deleted by a different repair step and I
    did not see how to remove those other repair steps. Would probably lead to a bigger
    rewrite of the hardlink check code so I decided to just move these to l+f.
    I have never seen this anyways.

- Any hardlink inode with a parent other than the metadata directory is changed
  to have the correct parent.
  I have seen these. I can understand how this happens when a normal directory
  is hardlined for the first time. The journal SHOULD prevent this from being a
  problem but obviously this is not the case.

- Directory hardlink inodes named "temp..." get deleted.
  These directories were deleted while open when the volume was removed without
  unmounting. Since these directories have already been deleted, deleting them
  in fsck is the right thing to do. (Documented like that for files in the HFS+
  spec.)

- Directory hardlink inodes with names other than "temp..." or "dir_..." are moved
  to "lost+found".
  It would be better to rename them to "dir_..." in a first pass, there might still
  be valid links to them. These links are deleted by a different repair step and I
  did not see how to remove those other repair steps. Would probably lead to a bigger
  rewrite of the hardlink check code so I decided to just move these to l+f.
  I have never seen this anyways.
@dhoepfl
Copy link
Author

dhoepfl commented Dec 9, 2021

Neither the first nor the third error should happen in a journaled filesystem (directory hardlinks require the Journal to be active). My guess is that using HFS+ over AFP (as TimeMachine does) does not correctly persist the journal before persisting changes. Thus loosing the connection during directory hardlink operation can result in partially executed atomic operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant