Skip to content

Commit

Permalink
Merge pull request #3440 from mulkieran/sort-feature-args
Browse files Browse the repository at this point in the history
Sort the set of feature_args before serializing them
  • Loading branch information
mulkieran authored Sep 14, 2023
2 parents 078974b + 2f27aa5 commit 99794d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/engine/strat_engine/serde_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// can convert to or from them when saving our current state, or
// restoring state from saved metadata.

use std::collections::HashSet;

use serde::Serialize;

use devicemapper::{Sectors, ThinDevId};
Expand Down Expand Up @@ -100,7 +98,7 @@ pub struct ThinPoolDevSave {
pub data_block_size: Sectors,
// TODO: This data type should no longer be optional in Stratis 4.0
#[serde(skip_serializing_if = "Option::is_none")]
pub feature_args: Option<HashSet<String>>,
pub feature_args: Option<Vec<String>>,
// TODO: This data type should no longer be optional in Stratis 4.0
#[serde(skip_serializing_if = "Option::is_none")]
pub fs_limit: Option<u64>,
Expand Down
15 changes: 13 additions & 2 deletions src/engine/strat_engine/thinpool/thinpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{
thread::scope,
};

use itertools::Itertools;
use retry::{delay::Fixed, retry_with_index};
use serde_json::{Map, Value};

Expand Down Expand Up @@ -483,7 +484,7 @@ impl ThinPool {
thin_pool_save
.feature_args
.as_ref()
.map(|hs| hs.iter().cloned().collect::<Vec<_>>())
.map(|x| x.to_vec())
.unwrap_or_else(|| {
migrate = true;
vec![
Expand Down Expand Up @@ -1645,7 +1646,17 @@ impl Recordable<ThinPoolDevSave> for ThinPool {
fn record(&self) -> ThinPoolDevSave {
ThinPoolDevSave {
data_block_size: self.thin_pool.data_block_size(),
feature_args: Some(self.thin_pool.table().table.params.feature_args.clone()),
feature_args: Some(
self.thin_pool
.table()
.table
.params
.feature_args
.iter()
.sorted()
.cloned()
.collect(),
),
fs_limit: Some(self.fs_limit),
enable_overprov: Some(self.enable_overprov),
}
Expand Down

0 comments on commit 99794d8

Please sign in to comment.