Skip to content

Commit

Permalink
fix(backup): skip loading the backingFile when doing backup or when u…
Browse files Browse the repository at this point in the history
…ser request

exporting the volume without backingFile

longhorn-9209

Signed-off-by: Phan Le <[email protected]>
  • Loading branch information
PhanLe1010 committed Aug 13, 2024
1 parent 0402d70 commit bc499c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pkg/replica/diff_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type diffDisk struct {
// we don't know the location yet.
location []byte
// list of files in grandparent, parent, child, etc order.
// index 0 is nil or backing file and index n-1 is the active write layer
// index 0 is nil, index 1 is backing file, and index n-1 is the active write layer
files []types.DiffDisk
sectorSize int64
// current size of the head file.
Expand Down Expand Up @@ -372,12 +372,17 @@ func (d *diffDisk) initializeSectorLocation(value byte) {
}
}

func (d *diffDisk) preload() error {
func (d *diffDisk) preload(isThereBackingFile bool) error {
for i, f := range d.files {
if i == 0 {
continue
}

// Skip loading the backingFile if it exists
if i == int(backingFileIndex) && isThereBackingFile {
continue
}

if err := LoadDiffDiskLocationList(d, f, byte(i)); err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/replica/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,8 @@ func (r *Replica) Preload(includeBackingFileLayer bool) error {
} else {
r.volume.initializeSectorLocation(nilFileIndex)
}
return r.volume.preload()
isThereBackingFile := r.info.BackingFile != nil
return r.volume.preload(isThereBackingFile)
}

func (r *Replica) GetDataLayout(ctx context.Context) (<-chan sparse.FileInterval, <-chan error, error) {
Expand Down

0 comments on commit bc499c8

Please sign in to comment.