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

Ignore xfs dirty logs #144

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions mount/mount_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const (
fsckErrorsCorrected = 1
// 'fsck' found errors but exited without correcting them
fsckErrorsUncorrected = 4
// 'xfs_repair' found errors but exited without correcting them
xfsRepairErrorsUncorrected = 1
// 'xfs_repair' was unable to proceed due to a dirty log
xfsRepairErrorsDirtyLogs = 2
)

// Mounter provides the default implementation of mount.Interface
Expand Down Expand Up @@ -330,12 +334,25 @@ func (mounter *SafeFormatAndMount) checkAndRepairXfsFilesystem(source string) er
} else {
klog.Warningf("Filesystem corruption was detected for %s, running xfs_repair to repair", source)
out, err := mounter.Exec.Command("xfs_repair", args...).CombinedOutput()
if err != nil {
return NewMountError(HasFilesystemErrors, "'xfs_repair' found errors on device %s but could not correct them: %s\n", source, out)
} else {
if err == nil {
klog.Infof("Device %s has errors which were corrected by xfs_repair.", source)
return nil
}
e, isExitError := err.(utilexec.ExitError)
if !isExitError {
return NewMountError(HasFilesystemErrors, "failed to run 'xfs_repair' on device %s: %v\n", source, err)

}
switch e.ExitStatus() {
case xfsRepairErrorsUncorrected:
return NewMountError(HasFilesystemErrors, "'xfs_repair' found errors on device %s but could not correct them: %s\n", source, string(out))
case xfsRepairErrorsDirtyLogs:
// mark the a dirty log issue as a warning, do you replay it by default.
klog.Warningf("A dirty log is detected on this xfs disk.")
return nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi I came across this pr because I do have exactly this problem using ceph rbd with xfs and rook.io
Wouldn't this cause the same potential "compounding of problems" as in #132 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I will. But 132 is still under discussion.

default:
return NewMountError(HasFilesystemErrors, "'xfs_repair' found errors on device %s but could not correct them: %s\n", source, string(out))
}
}
}
return nil
Expand Down
9 changes: 9 additions & 0 deletions mount/safe_format_and_mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,15 @@ func TestSafeFormatAndMount(t *testing.T) {
},
expErrorType: HasFilesystemErrors,
},
{
description: "Test that 'xfs_repair' is called twice and report a dirty log (return 2)",
fstype: "xfs",
execScripts: []ExecArgs{
{"blkid", []string{"-p", "-s", "TYPE", "-s", "PTTYPE", "-o", "export", "/dev/foo"}, "DEVNAME=/dev/foo\nTYPE=xfs\n", nil},
{"xfs_repair", []string{"-n", "/dev/foo"}, "", &testingexec.FakeExitError{Status: 1}},
{"xfs_repair", []string{"/dev/foo"}, "\nAn error occurred\n", &testingexec.FakeExitError{Status: 2}},
},
},
{
description: "Test that 'blkid' is called and confirms unformatted disk, format fails with sensitive options",
fstype: "ext4",
Expand Down