Skip to content

Commit

Permalink
fix: run xfs_repair on invalid argument error
Browse files Browse the repository at this point in the history
Run `xfs_repair` for invalid argument error.

Part of: #8292

Signed-off-by: Noel Georgi <git@frezbo.dev>
  • Loading branch information
frezbo committed Feb 13, 2024
1 parent f868fb8 commit 2f0421b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions internal/pkg/mount/mount.go
Expand Up @@ -141,6 +141,7 @@ func PrefixMountTargets(mountpoints *Points, targetPrefix string) error {
return iter.Err()
}

//nolint:gocyclo
func mountRetry(f RetryFunc, p *Point, isUnmount bool) (err error) {
err = retry.Constant(5*time.Second, retry.WithUnits(50*time.Millisecond)).Retry(func() error {
if err = f(p); err != nil {
Expand All @@ -162,6 +163,14 @@ func mountRetry(f RetryFunc, p *Point, isUnmount bool) (err error) {
return retry.ExpectedError(checkErr)
}

if !isMounted && !isUnmount {
if errRepair := p.Repair(); errRepair != nil {
return fmt.Errorf("error repairing: %w", errRepair)
}

return retry.ExpectedError(err)
}

if !isMounted && isUnmount { // if partition is already unmounted, ignore EINVAL
return nil
}
Expand Down

0 comments on commit 2f0421b

Please sign in to comment.