Skip to content

Commit

Permalink
fix(rebuild): add same device validation
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
  • Loading branch information
tiagolobocastro committed Jan 30, 2024
1 parent 37f211c commit dc53c12
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions io-engine/src/rebuild/rebuild_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ impl RebuildDescriptor {
bdev: dst_uri.to_string(),
})?;

if src_descriptor.device_name() == dst_descriptor.device_name() {
return Err(RebuildError::SameBdev {
bdev: src_descriptor.device_name(),
});
}

let source_hdl = RebuildDescriptor::io_handle(&*src_descriptor).await?;
let destination_hdl =
RebuildDescriptor::io_handle(&*dst_descriptor).await?;
Expand Down
4 changes: 4 additions & 0 deletions io-engine/src/rebuild/rebuild_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ pub enum RebuildError {
NoCopyBuffer { source: DmaError },
#[snafu(display("Failed to validate rebuild job creation parameters"))]
InvalidParameters {},
#[snafu(display(
"The same device was specified for both source and destination: {bdev}"
))]
SameBdev { bdev: String },
#[snafu(display("Failed to get a handle for bdev {}", bdev))]
NoBdevHandle { source: CoreError, bdev: String },
#[snafu(display("Bdev {} not found", bdev))]
Expand Down

0 comments on commit dc53c12

Please sign in to comment.