Skip to content

Commit

Permalink
chore(bors): merge pull request #797
Browse files Browse the repository at this point in the history
797: Cherry PR 796,792 r=tiagolobocastro a=tiagolobocastro



Co-authored-by: Tiago Castro <[email protected]>
  • Loading branch information
mayastor-bors and tiagolobocastro committed Mar 28, 2024
2 parents 5446a34 + 7d196d5 commit 6b35b1a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ impl AgentToIoEngine for transport::DestroyPool {
impl AgentToIoEngine for transport::CreateNexus {
type IoEngineMessage = v0::CreateNexusV2Request;
fn to_rpc(&self) -> Self::IoEngineMessage {
let nexus_config = self
.config
.clone()
.unwrap_or_else(|| NexusNvmfConfig::default().with_no_resv());
let nexus_config = match self.config.as_ref() {
Some(config) if config != &NexusNvmfConfig::default().with_no_resv() => config.clone(),
_ => NexusNvmfConfig::default().with_no_resv_v0(),
};
Self::IoEngineMessage {
name: self.name(),
uuid: self.uuid.clone().into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ pub(crate) fn replica_rebuildable(
/// Calculates the number of bytes required to rebuild this replica up to the given minimum.
/// # Warning: valid only if the current blocks are exactly the same as the healthy replicas.
pub(crate) fn rebuild_space_required(min_allocated_bytes: u64, replica: &Replica) -> u64 {
if !replica.thin {
return 0;
}

let repl_allocated_bytes = replica
.space
.as_ref()
Expand All @@ -194,7 +198,7 @@ pub(crate) fn rebuild_space_required(min_allocated_bytes: u64, replica: &Replica

// we've already allocated some bytes, so take those into account
// did you read the warning above?
let bytes_needed = min_allocated_bytes - repl_allocated_bytes;
let bytes_needed = min_allocated_bytes - repl_allocated_bytes.min(min_allocated_bytes);

// We need sufficient free space for at least the current allocation of other replicas, but
// just this capacity may not be enough as applications may carry on issuing new writes.
Expand Down
9 changes: 7 additions & 2 deletions control-plane/agents/src/bin/core/node/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,13 @@ impl Service {
let node = nodes.write().await.get_mut(&node_state.id).cloned();
let send_event = match node {
None => {
let mut node =
NodeWrapper::new(&node_state, self.deadline, self.comms_timeouts.clone());
let ha_disabled = self.registry.ha_disabled();
let mut node = NodeWrapper::new(
&node_state,
self.deadline,
self.comms_timeouts.clone(),
ha_disabled,
);

// On startup api version is not known, thus probe all apiversions
let result = match startup {
Expand Down
17 changes: 16 additions & 1 deletion control-plane/agents/src/bin/core/node/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ pub(crate) struct NodeWrapper {
states: ResourceStatesLocked,
/// The number of rebuilds in progress on the node.
num_rebuilds: Arc<RwLock<NumRebuilds>>,
/// If HA is disabled, don't use reservations when creating nexuses.
disable_ha: bool,
}

impl NodeWrapper {
Expand All @@ -104,6 +106,7 @@ impl NodeWrapper {
node: &NodeState,
deadline: std::time::Duration,
comms_timeouts: NodeCommsTimeout,
disable_ha: bool,
) -> Self {
tracing::debug!("Creating new node {:?}", node);
Self {
Expand All @@ -114,6 +117,7 @@ impl NodeWrapper {
comms_timeouts,
states: ResourceStatesLocked::new(),
num_rebuilds: Arc::new(RwLock::new(0)),
disable_ha,
}
}

Expand All @@ -132,6 +136,7 @@ impl NodeWrapper {
),
states: ResourceStatesLocked::new(),
num_rebuilds: Arc::new(RwLock::new(0)),
disable_ha: false,
}
}

Expand Down Expand Up @@ -590,6 +595,7 @@ impl NodeWrapper {
tracing::info!(
node.id = %self.id(),
node.endpoint = self.endpoint_str(),
api.versions = ?self.node_state.api_versions,
startup,
"Preloading node"
);
Expand Down Expand Up @@ -1368,7 +1374,16 @@ impl NexusApi<()> for Arc<tokio::sync::RwLock<NodeWrapper>> {
});
}
let dataplane = self.grpc_client_locked(request.id()).await?;
match dataplane.create_nexus(request).await {
let disable_resv = self.read().await.disable_ha;
let result = if disable_resv {
let mut request = request.clone();
request.config = None;
dataplane.create_nexus(&request).await
} else {
dataplane.create_nexus(request).await
};

match result {
Ok(nexus) => {
self.update_nexus_state(Either::Insert(nexus.clone())).await;
Ok(nexus)
Expand Down
7 changes: 7 additions & 0 deletions control-plane/stor-port/src/types/v0/transport/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,13 @@ impl NexusNvmfConfig {
self.reservation_type = NvmeReservation::Reserved;
self
}
/// On v0 reservations are mostly disabled, simply set key to 1 to avoid failure.
pub fn with_no_resv_v0(mut self) -> Self {
self.reservation_key = 1;
self.preempt_policy = NexusNvmePreemption::ArgKey(None);
self.reservation_type = NvmeReservation::Reserved;
self
}
}

impl Default for NexusNvmfConfig {
Expand Down

0 comments on commit 6b35b1a

Please sign in to comment.