Skip to content

Commit 51a72f0

Browse files
committed
mark device faulty after parent fails to suspend
When an error is returned here, unlike the other error returns in the function, nothing is done to mark the added device as faulty or remove it. I have observed this causing future snapshot creations to continue to attempt to use the same ID (from the sequence) to create new devices and get blocked because the device already exists because it was not rolled back here. Hopefully fixes #5110 Signed-off-by: Jeremy Williams <[email protected]>
1 parent 134f7a7 commit 51a72f0

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

snapshots/devmapper/pool_device.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,6 @@ func (p *PoolDevice) CreateSnapshotDevice(ctx context.Context, deviceName string
331331
}
332332
}()
333333

334-
// Save snapshot metadata and allocate new device ID
335-
metaErr = p.metadata.AddDevice(ctx, snapInfo)
336-
if metaErr != nil {
337-
return metaErr
338-
}
339-
340334
// The base device must be suspend before taking a snapshot to
341335
// avoid corruption.
342336
// https://github.com/torvalds/linux/blob/v5.7/Documentation/admin-guide/device-mapper/thin-provisioning.rst#internal-snapshots
@@ -354,6 +348,12 @@ func (p *PoolDevice) CreateSnapshotDevice(ctx context.Context, deviceName string
354348
}()
355349
}
356350

351+
// Save snapshot metadata and allocate new device ID
352+
metaErr = p.metadata.AddDevice(ctx, snapInfo)
353+
if metaErr != nil {
354+
return metaErr
355+
}
356+
357357
// Create thin device snapshot
358358
devErr = p.createSnapshot(ctx, baseInfo, snapInfo)
359359
if devErr != nil {

0 commit comments

Comments
 (0)