Skip to content

Commit

Permalink
fix: fix backing image size calculation
Browse files Browse the repository at this point in the history
ref: longhorn/longhorn 10342

Signed-off-by: Jack Lin <[email protected]>
  • Loading branch information
ChanYiLin committed Feb 5, 2025
1 parent 6e966aa commit b1bf0f6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/spdk/backing_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (bi *BackingImage) Create(spdkClient *spdkclient.Client, superiorPortAlloca
if err != nil {
bi.log.WithError(err).Error("Failed to create backing image")
}
// update the backing image afte preparing
// update the backing image after preparing
bi.UpdateCh <- nil
}()

Expand Down
4 changes: 2 additions & 2 deletions pkg/spdk/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (s *Server) verify() (err error) {
logrus.WithError(err).Warnf("failed to extract backing image name and disk UUID from lvol name %v", lvolName)
continue
}
actualSize := bdevLvol.DriverSpecific.Lvol.NumAllocatedClusters * uint64(defaultClusterSize)
size := bdevLvol.NumBlocks * uint64(bdevLvol.BlockSize)

Check warning on line 289 in pkg/spdk/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/server.go#L289

Added line #L289 was not covered by tests
alias := bdevLvol.Aliases[0]
expectedChecksum, err := GetSnapXattr(spdkClient, alias, types.BackingImageSnapshotAttrChecksum)
if err != nil {
Expand All @@ -298,7 +298,7 @@ func (s *Server) verify() (err error) {
logrus.WithError(err).Warnf("failed to retrieve backing image UUID attribute for snapshot %v", alias)
continue
}
backingImage := NewBackingImage(s.ctx, backingImageName, backingImageUUID, lvsUUID, actualSize, expectedChecksum, s.updateChs[types.InstanceTypeBackingImage])
backingImage := NewBackingImage(s.ctx, backingImageName, backingImageUUID, lvsUUID, size, expectedChecksum, s.updateChs[types.InstanceTypeBackingImage])

Check warning on line 301 in pkg/spdk/server.go

View check run for this annotation

Codecov / codecov/patch

pkg/spdk/server.go#L301

Added line #L301 was not covered by tests
backingImage.Alias = alias
// For uncahced backing image, we set the state to pending first, so we can distinguish it from the cached but starting backing image
backingImage.State = types.BackingImageStatePending
Expand Down

0 comments on commit b1bf0f6

Please sign in to comment.