zfs: generalize dry send information for normal sends and with resume token

This is in preparation for resumable send & recv, thus we just don't use
the ResumeToken field for the time being.
This commit is contained in:
Christian Schwarz
2018-10-18 15:45:58 +02:00
parent 1f072936c5
commit 6fcf0635a5
3 changed files with 285 additions and 45 deletions
+7 -6
View File
@@ -79,16 +79,17 @@ func (p *Sender) Send(ctx context.Context, r *pdu.SendReq) (*pdu.SendRes, io.Rea
}
if r.DryRun {
size, err := zfs.ZFSSendDry(r.Filesystem, r.From, r.To)
if err == zfs.BookmarkSizeEstimationNotSupported {
return &pdu.SendRes{ExpectedSize: 0}, nil, nil
}
si, err := zfs.ZFSSendDry(r.Filesystem, r.From, r.To, "")
if err != nil {
return nil, nil, err
}
return &pdu.SendRes{ExpectedSize: size}, nil, nil
var expSize int64 = 0 // protocol says 0 means no estimate
if si.SizeEstimate != -1 { // but si returns -1 for no size estimate
expSize = si.SizeEstimate
}
return &pdu.SendRes{ExpectedSize: expSize}, nil, nil
} else {
stream, err := zfs.ZFSSend(r.Filesystem, r.From, r.To)
stream, err := zfs.ZFSSend(r.Filesystem, r.From, r.To, "")
if err != nil {
return nil, nil, err
}