Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backup): skip loading the backingFile when doing backup or when user requests exporting the volume without backingFile (backport #1187) #1188

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 0 additions & 5 deletions pkg/replica/extents.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ const MaxExtentsBuffer = 1024
func LoadDiffDiskLocationList(diffDisk *diffDisk, disk types.DiffDisk, currentFileIndex byte) error {
fd := disk.Fd()

// The backing file will have a Fd of 0
if fd == 0 {
return nil
}

start := uint64(0)
end := uint64(len(diffDisk.location)) * uint64(diffDisk.sectorSize)
for {
Expand Down
3 changes: 2 additions & 1 deletion pkg/replica/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,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