mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-25 09:54:47 +01:00
zfs: FilesytemDiff: len(IncrementalPath) < 2 means same most recent version
bonus: style + typo fixes
This commit is contained in:
parent
d0c0e2510b
commit
1a92717894
@ -62,7 +62,7 @@ type FilesystemDiff struct {
|
|||||||
|
|
||||||
// The increments required to get left up to right's most recent version
|
// The increments required to get left up to right's most recent version
|
||||||
// 0th element is the common ancestor, ordered by birthtime, oldest first
|
// 0th element is the common ancestor, ordered by birthtime, oldest first
|
||||||
// If empty, left and right are at same most recent version
|
// If len() < 2, left and right are at same most recent version
|
||||||
// If nil, there is no incremental path for left to get to right's most recent version
|
// If nil, there is no incremental path for left to get to right's most recent version
|
||||||
// This means either (check Diverged field to determine which case we are in)
|
// This means either (check Diverged field to determine which case we are in)
|
||||||
// a) no common ancestor (left deleted all the snapshots it previously transferred to right)
|
// a) no common ancestor (left deleted all the snapshots it previously transferred to right)
|
||||||
@ -150,6 +150,7 @@ func MakeFilesystemDiff(left, right []FilesystemVersion) (diff FilesystemDiff) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Assert both left and right are sorted by createtxg
|
// Assert both left and right are sorted by createtxg
|
||||||
|
{
|
||||||
var leftSorted, rightSorted fsbyCreateTXG
|
var leftSorted, rightSorted fsbyCreateTXG
|
||||||
leftSorted = left
|
leftSorted = left
|
||||||
rightSorted = right
|
rightSorted = right
|
||||||
@ -159,8 +160,9 @@ func MakeFilesystemDiff(left, right []FilesystemVersion) (diff FilesystemDiff) {
|
|||||||
if !sort.IsSorted(rightSorted) {
|
if !sort.IsSorted(rightSorted) {
|
||||||
panic("cannot make filesystem diff: unsorted right")
|
panic("cannot make filesystem diff: unsorted right")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Find most recent common ancestor by name, preferring snapshots over bookmars
|
// Find most recent common ancestor by name, preferring snapshots over bookmarks
|
||||||
mrcaLeft := len(left) - 1
|
mrcaLeft := len(left) - 1
|
||||||
var mrcaRight int
|
var mrcaRight int
|
||||||
outer:
|
outer:
|
||||||
@ -202,7 +204,8 @@ outer:
|
|||||||
panic("invariant violated: mrca on left must be the last item in the left list")
|
panic("invariant violated: mrca on left must be the last item in the left list")
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip bookmarks going forward from right
|
// incPath must not contain bookmarks except initial one,
|
||||||
|
// and only if that initial bookmark's snapshot is gone
|
||||||
incPath := make([]FilesystemVersion, 0, len(right))
|
incPath := make([]FilesystemVersion, 0, len(right))
|
||||||
incPath = append(incPath, right[mrcaRight])
|
incPath = append(incPath, right[mrcaRight])
|
||||||
// right[mrcaRight] may be a bookmark if there's no equally named snapshot
|
// right[mrcaRight] may be a bookmark if there's no equally named snapshot
|
||||||
|
Loading…
Reference in New Issue
Block a user