Skip to content

Commit 4f7aca9

Browse files
committed
fix(backup): skip loading the backingFile when doing backup or when user request
exporting the volume without backingFile longhorn-9209 Signed-off-by: Phan Le <[email protected]>
1 parent 0402d70 commit 4f7aca9

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

pkg/replica/diff_disk.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type diffDisk struct {
2020
// we don't know the location yet.
2121
location []byte
2222
// list of files in grandparent, parent, child, etc order.
23-
// index 0 is nil or backing file and index n-1 is the active write layer
23+
// index 0 is nil, index 1 is backing file, and index n-1 is the active write layer
2424
files []types.DiffDisk
2525
sectorSize int64
2626
// current size of the head file.
@@ -372,12 +372,17 @@ func (d *diffDisk) initializeSectorLocation(value byte) {
372372
}
373373
}
374374

375-
func (d *diffDisk) preload() error {
375+
func (d *diffDisk) preload(isThereBackingFile bool) error {
376376
for i, f := range d.files {
377377
if i == 0 {
378378
continue
379379
}
380380

381+
// Skip loading the backingFile if it exists
382+
if i == int(backingFileIndex) && isThereBackingFile {
383+
continue
384+
}
385+
381386
if err := LoadDiffDiskLocationList(d, f, byte(i)); err != nil {
382387
return err
383388
}

pkg/replica/extents.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ const MaxExtentsBuffer = 1024
1111
func LoadDiffDiskLocationList(diffDisk *diffDisk, disk types.DiffDisk, currentFileIndex byte) error {
1212
fd := disk.Fd()
1313

14-
// The backing file will have a Fd of 0
15-
if fd == 0 {
16-
return nil
17-
}
18-
1914
start := uint64(0)
2015
end := uint64(len(diffDisk.location)) * uint64(diffDisk.sectorSize)
2116
for {

pkg/replica/replica.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,8 @@ func (r *Replica) Preload(includeBackingFileLayer bool) error {
14671467
} else {
14681468
r.volume.initializeSectorLocation(nilFileIndex)
14691469
}
1470-
return r.volume.preload()
1470+
isThereBackingFile := r.info.BackingFile != nil
1471+
return r.volume.preload(isThereBackingFile)
14711472
}
14721473

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

0 commit comments

Comments
 (0)