diff --git a/build.rs b/build.rs index ca079a75..cde22c7a 100644 --- a/build.rs +++ b/build.rs @@ -18,6 +18,7 @@ fn main() { .build_server(true) .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]") .extern_path(".google.protobuf.Timestamp", "::prost_wkt_types::Timestamp") + .extern_path(".google.protobuf.Duration", "::prost_wkt_types::Duration") .compile( &[ "protobuf/v1/bdev.proto", @@ -28,6 +29,7 @@ fn main() { "protobuf/v1/nexus.proto", "protobuf/v1/registration.proto", "protobuf/v1/snapshot.proto", + "protobuf/v1/test.proto", ], &["protobuf/v1"], ) diff --git a/protobuf/v1/test.proto b/protobuf/v1/test.proto new file mode 100644 index 00000000..904b2dd1 --- /dev/null +++ b/protobuf/v1/test.proto @@ -0,0 +1,80 @@ +syntax = "proto3"; + +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/wrappers.proto"; + +package mayastor.v1; + +// Service to be used by test code, it is not meant to be used in production! +service TestRpc { + // Replica related methods. + // + // Wipe a replica using the selected method. + // The replica MUST NOT have any user data and must not be currently used + // by any nexus => this will cause data loss! + rpc WipeReplica (WipeReplicaRequest) returns (stream WipeReplicaResponse) {} +} + +message WipeReplicaRequest { + // Uuid of the replica. + string uuid = 1; + oneof pool { + // Name of the pool where the replica resides. + string pool_name = 2; + // Optional uuid for the pool where the replica resides. + string pool_uuid = 3; + } + StreamWipeOptions wipe_options = 4; +} + +message WipeOptions { + enum WipeMethod { + // Don't actually wipe, just pretend. + NONE = 0; + // Wipe by writing zeroes. + WRITE_ZEROES = 1; + // Wipe by sending unmap/trim. + UNMAP = 2; + // Wipe by writing a given patter (see write_pattern(6) field). + WRITE_PATTERN = 3; + } + // Method used to wipe the bdev. + WipeMethod wipe_method = 1; + // When using WRITE_PATTERN, wipe using this 32bit write pattern + // Default: 0xDEADBEEF. + optional uint32 write_pattern = 2; +} + +message StreamWipeOptions { + WipeOptions options = 1; + // Notify client when every chunk is complete. + uint64 chunk_size = 2; +} + +// Stream of messages which are sent from the server to the client. +// A message is sent at the beginning, then a message will be sent after +// each chunk sized bytes are wiped. +// In case of successful wipes this brings the total number of messages +// to total_chunks + 1. +message WipeReplicaResponse { + // Uuid of the replica. + string uuid = 1; + // Total bytes to be wiped. + uint64 total_bytes = 2; + // Size of a chunk. + uint64 chunk_size = 3; + // Size of the last chunk (may differ in case of non multiple of the total size). + uint64 last_chunk_size = 4; + // Number of chunks (how many notifications -1) to be received. + uint64 total_chunks = 5; + // How many bytes we've wiped so far (this will be incremented in chunks). + uint64 wiped_bytes = 6; + // How many chunks we've wiped so far. + uint64 wiped_chunks = 7; + // Remaining bytes to be wiped. + uint64 remaining_bytes = 8; + // Duration since the start of the wipe. + google.protobuf.Duration since = 9; +} + diff --git a/src/v1.rs b/src/v1.rs index 75d90055..33388e53 100644 --- a/src/v1.rs +++ b/src/v1.rs @@ -97,6 +97,15 @@ pub mod nexus { }; } +pub mod test { + pub use super::pb::{ + test_rpc_client::TestRpcClient, + test_rpc_server::{TestRpc, TestRpcServer}, + wipe_options, wipe_replica_request, StreamWipeOptions, WipeOptions, WipeReplicaRequest, + WipeReplicaResponse, + }; +} + #[derive(Debug)] pub enum Error { ParseError,