diff --git a/pkg/replica/diff_disk.go b/pkg/replica/diff_disk.go index 1134a7fad..4b57ef911 100644 --- a/pkg/replica/diff_disk.go +++ b/pkg/replica/diff_disk.go @@ -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 and index n-1 is the active write layer files []types.DiffDisk sectorSize int64 // current size of the head file. @@ -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 } diff --git a/pkg/replica/replica.go b/pkg/replica/replica.go index 815b9bbcd..575cbe914 100644 --- a/pkg/replica/replica.go +++ b/pkg/replica/replica.go @@ -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) {