mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-28 11:25:20 +01:00
2d8c3692ec
Before this change, resuming from an unencrypted dataset with send.raw=true specified wouldn't work with zrepl due to overly restrictive resume token checking. An initial PR to fix this was made in https://github.com/zrepl/zrepl/pull/503 but it didn't address the core of the problem. The core of the problem was that zrepl assumed that if a resume token contained `rawok=true, compressok=true`, the resulting send would be encrypted. But if the sender dataset was unencrypted, such a resume would actually result in an unencrypted send. Which could be totally legitimate but zrepl failed to recognize that. BACKGROUND ========== The following snippets of OpenZFS code are insightful regarding how the various ${X}ok values in the resume token are handled: -6c3c5fcfbe/module/zfs/dmu_send.c (L1947-L2012)
-6c3c5fcfbe/module/zfs/dmu_recv.c (L877-L891)
- https://github.com/openzfs/zfs/blob/6c3c5fc/lib/libzfs/libzfs_sendrecv.c#L1663-L1672 Basically, some zfs send flags make the DMU send code set some DMU send stream featureflags, although it's not a pure mapping, i.e, which DMU send stream flags are used depends somewhat on the dataset (e.g., is it encrypted or not, or, does it use zstd or not). Then, the receiver looks at some (but not all) feature flags and maps them to ${X}ok dataset zap attributes. These are funnelled back to the sender 1:1 through the resume_token. And the sender turns them into lzc flags. As an example, let's look at zfs send --raw. if the sender requests a raw send on an unencrypted dataset, the send stream (and hence the resume token) will not have the raw stream featureflag set, and hence the resume token will not have the rawok field set. Instead, it will have compressok, embedok, and depending on whether large blocks are present in the dataset, largeblockok set. WHAT'S ZREPL'S ROLE IN THIS? ============================ zrepl provides a virtual encrypted sendflag that is like `raw`, but further ensures that we only send encrypted datasets. For any other resume token stuff, it shoudn't do any checking, because it's a futile effort to keep up with ZFS send/recv features that are orthogonal to encryption. CHANGES MADE IN THIS COMMIT =========================== - Rip out a bunch of needless checking that zrepl would do during planning. These checks were there to give better error messages, but actually, the error messages created by the endpoint.Sender.Send RPC upon send args validation failure are good enough. - Add platformtests to validate all combinations of (Unencrypted/Encrypted FS) x (send.encrypted = true | false) x (send.raw = true | false) for cases both non-resuming and resuming send. Additional manual testing done: 1. With zrepl 0.5, setup with unencrypted dataset, send.raw=true specified, no send.encrypted specified. 2. Observe that regular non-resuming send works, but resuming doesn't work. 3. Upgrade zrepl to this change. 4. Observe that both regular and resuming send works. closes https://github.com/zrepl/zrepl/pull/613
138 lines
3.5 KiB
Protocol Buffer
138 lines
3.5 KiB
Protocol Buffer
syntax = "proto3";
|
|
option go_package = ".;pdu";
|
|
|
|
service Replication {
|
|
rpc Ping(PingReq) returns (PingRes);
|
|
rpc ListFilesystems(ListFilesystemReq) returns (ListFilesystemRes);
|
|
rpc ListFilesystemVersions(ListFilesystemVersionsReq)
|
|
returns (ListFilesystemVersionsRes);
|
|
rpc DestroySnapshots(DestroySnapshotsReq) returns (DestroySnapshotsRes);
|
|
rpc ReplicationCursor(ReplicationCursorReq) returns (ReplicationCursorRes);
|
|
rpc SendDry(SendReq) returns (SendRes);
|
|
rpc SendCompleted(SendCompletedReq) returns (SendCompletedRes);
|
|
// for Send and Recv, see package rpc
|
|
}
|
|
|
|
message ListFilesystemReq {}
|
|
|
|
message ListFilesystemRes { repeated Filesystem Filesystems = 1; }
|
|
|
|
message Filesystem {
|
|
string Path = 1;
|
|
string ResumeToken = 2;
|
|
bool IsPlaceholder = 3;
|
|
}
|
|
|
|
message ListFilesystemVersionsReq { string Filesystem = 1; }
|
|
|
|
message ListFilesystemVersionsRes { repeated FilesystemVersion Versions = 1; }
|
|
|
|
message FilesystemVersion {
|
|
enum VersionType {
|
|
Snapshot = 0;
|
|
Bookmark = 1;
|
|
}
|
|
VersionType Type = 1;
|
|
string Name = 2;
|
|
uint64 Guid = 3;
|
|
uint64 CreateTXG = 4;
|
|
string Creation = 5; // RFC 3339
|
|
}
|
|
|
|
message SendReq {
|
|
string Filesystem = 1;
|
|
// May be empty / null to request a full transfer of To
|
|
FilesystemVersion From = 2;
|
|
FilesystemVersion To = 3;
|
|
|
|
// If ResumeToken is not empty, the resume token that CAN be used for 'zfs
|
|
// send' by the sender. The sender MUST indicate use of ResumeToken in the
|
|
// reply message SendRes.UsedResumeToken If it does not work, the sender
|
|
// SHOULD clear the resume token on their side and use From and To instead If
|
|
// ResumeToken is not empty, the GUIDs of From and To MUST correspond to those
|
|
// encoded in the ResumeToken. Otherwise, the Sender MUST return an error.
|
|
string ResumeToken = 4;
|
|
|
|
ReplicationConfig ReplicationConfig = 6;
|
|
}
|
|
|
|
message ReplicationConfig {
|
|
ReplicationConfigProtection protection = 1;
|
|
}
|
|
|
|
|
|
message ReplicationConfigProtection {
|
|
ReplicationGuaranteeKind Initial = 1;
|
|
ReplicationGuaranteeKind Incremental = 2;
|
|
}
|
|
|
|
enum ReplicationGuaranteeKind {
|
|
GuaranteeInvalid = 0;
|
|
GuaranteeResumability = 1;
|
|
GuaranteeIncrementalReplication = 2;
|
|
GuaranteeNothing = 3;
|
|
}
|
|
|
|
message Property {
|
|
string Name = 1;
|
|
string Value = 2;
|
|
}
|
|
|
|
message SendRes {
|
|
// Whether the resume token provided in the request has been used or not.
|
|
// If the SendReq.ResumeToken == "", this field MUST be false.
|
|
bool UsedResumeToken = 1;
|
|
|
|
// Expected stream size determined by dry run, not exact.
|
|
// 0 indicates that for the given SendReq, no size estimate could be made.
|
|
uint64 ExpectedSize = 2;
|
|
}
|
|
|
|
message SendCompletedReq {
|
|
SendReq OriginalReq = 2;
|
|
}
|
|
|
|
message SendCompletedRes {}
|
|
|
|
message ReceiveReq {
|
|
string Filesystem = 1;
|
|
FilesystemVersion To = 2;
|
|
|
|
// If true, the receiver should clear the resume token before performing the
|
|
// zfs recv of the stream in the request
|
|
bool ClearResumeToken = 3;
|
|
|
|
ReplicationConfig ReplicationConfig = 4;
|
|
}
|
|
|
|
message ReceiveRes {}
|
|
|
|
message DestroySnapshotsReq {
|
|
string Filesystem = 1;
|
|
// Path to filesystem, snapshot or bookmark to be destroyed
|
|
repeated FilesystemVersion Snapshots = 2;
|
|
}
|
|
|
|
message DestroySnapshotRes {
|
|
FilesystemVersion Snapshot = 1;
|
|
string Error = 2;
|
|
}
|
|
|
|
message DestroySnapshotsRes { repeated DestroySnapshotRes Results = 1; }
|
|
|
|
message ReplicationCursorReq { string Filesystem = 1; }
|
|
|
|
message ReplicationCursorRes {
|
|
oneof Result {
|
|
uint64 Guid = 1;
|
|
bool Notexist = 2;
|
|
}
|
|
}
|
|
|
|
message PingReq { string Message = 1; }
|
|
|
|
message PingRes {
|
|
// Echo must be PingReq.Message
|
|
string Echo = 1;
|
|
}
|