Skip to content

Commit 92a274e

Browse files
committed
fix: workaround problems with udevd races
When `udevd` rescans block device partitions while Talos is doing partitions, it might be that Talos can hit the following error while trying to open/mount a partition: ``` no such device or address ``` Previous attempts to fix that were using `ENODEV`, while the proper code is `ENXIO`. Also take exclusive lock while working with user disks to prevent concurrent udevd rescan. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 31b24ea commit 92a274e

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

cmd/installer/pkg/install/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ func retryBlockdeviceOpen(device string) (*blockdevice.BlockDevice, error) {
445445
switch {
446446
case os.IsNotExist(openErr):
447447
return retry.ExpectedError(openErr)
448-
case errors.Is(openErr, syscall.ENODEV):
448+
case errors.Is(openErr, syscall.ENODEV), errors.Is(openErr, syscall.ENXIO):
449449
return retry.ExpectedError(openErr)
450450
default:
451451
return nil

internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_sequencer_tasks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ func partitionAndFormatDisks(logger *log.Logger, r runtime.Runtime) error {
850850

851851
for _, disk := range r.Config().Machine().Disks() {
852852
if err := func() error {
853-
bd, err := blockdevice.Open(disk.Device(), blockdevice.WithMode(blockdevice.ReadonlyMode))
853+
bd, err := blockdevice.Open(disk.Device(), blockdevice.WithMode(blockdevice.ReadonlyMode), blockdevice.WithExclusiveLock(true))
854854
if err != nil {
855855
return err
856856
}
@@ -921,7 +921,7 @@ func mountDisks(logger *log.Logger, r runtime.Runtime) (err error) {
921921
mountpoints := mount.NewMountPoints()
922922

923923
for _, disk := range r.Config().Machine().Disks() {
924-
bd, err := blockdevice.Open(disk.Device(), blockdevice.WithMode(blockdevice.ReadonlyMode))
924+
bd, err := blockdevice.Open(disk.Device(), blockdevice.WithMode(blockdevice.ReadonlyMode), blockdevice.WithExclusiveLock(true))
925925
if err != nil {
926926
return err
927927
}

internal/pkg/mount/mount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func mountRetry(f RetryFunc, p *Point, isUnmount bool) (err error) {
148148
switch err {
149149
case unix.EBUSY:
150150
return retry.ExpectedError(err)
151-
case unix.ENOENT, unix.ENODEV:
151+
case unix.ENOENT, unix.ENXIO:
152152
// if udevd triggers BLKRRPART ioctl, partition device entry might disappear temporarily
153153
return retry.ExpectedError(err)
154154
case unix.EUCLEAN, unix.EIO:

0 commit comments

Comments
 (0)