Skip to content

Commit

Permalink
Merge pull request #77 from openebs/wipe
Browse files Browse the repository at this point in the history
feat(wipe/replica): add replica wipe api
  • Loading branch information
tiagolobocastro authored Aug 1, 2023
2 parents 2697ddf + 9987064 commit acea24e
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -28,6 +29,7 @@ fn main() {
"protobuf/v1/nexus.proto",
"protobuf/v1/registration.proto",
"protobuf/v1/snapshot.proto",
"protobuf/v1/test.proto",
],
&["protobuf/v1"],
)
Expand Down
80 changes: 80 additions & 0 deletions protobuf/v1/test.proto
Original file line number Diff line number Diff line change
@@ -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;
}

9 changes: 9 additions & 0 deletions src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit acea24e

Please sign in to comment.