Skip to content

Commit

Permalink
Change LinearDev::new to LinearDev::setup
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <amulhern@redhat.com>
  • Loading branch information
mulkieran committed Sep 14, 2017
1 parent ff1d74c commit be4cc40
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
39 changes: 20 additions & 19 deletions src/engine/strat_engine/thinpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,19 @@ impl ThinPool {
// superblock DM issue error messages because it triggers code paths
// that are trying to re-adopt the device with the attributes that
// have been passed.
let meta_dev = LinearDev::new(&format_flex_name(&pool_uuid, FlexRole::ThinMeta),
dm,
map_to_dm(&meta_segments))?;
let meta_dev = LinearDev::setup(&format_flex_name(&pool_uuid, FlexRole::ThinMeta),
dm,
map_to_dm(&meta_segments))?;
wipe_sectors(&meta_dev.devnode(),
Sectors(0),
ThinPool::initial_metadata_size())?;

let data_dev = LinearDev::new(&format_flex_name(&pool_uuid, FlexRole::ThinData),
dm,
map_to_dm(&data_segments))?;
let data_dev = LinearDev::setup(&format_flex_name(&pool_uuid, FlexRole::ThinData),
dm,
map_to_dm(&data_segments))?;

let mdv_name = format_flex_name(&pool_uuid, FlexRole::MetadataVolume);
let mdv_dev = LinearDev::new(&mdv_name, dm, map_to_dm(&mdv_segments))?;
let mdv_dev = LinearDev::setup(&mdv_name, dm, map_to_dm(&mdv_segments))?;
let mdv = MetadataVol::initialize(&pool_uuid, mdv_dev)?;

let name = format_thinpool_name(&pool_uuid, ThinPoolRole::Pool);
Expand Down Expand Up @@ -177,13 +177,13 @@ impl ThinPool {
.map(&mapper)
.collect::<EngineResult<Vec<_>>>()?;

let meta_dev = LinearDev::new(&format_flex_name(&pool_uuid, FlexRole::ThinMeta),
dm,
map_to_dm(&meta_segments))?;
let meta_dev = LinearDev::setup(&format_flex_name(&pool_uuid, FlexRole::ThinMeta),
dm,
map_to_dm(&meta_segments))?;

let data_dev = LinearDev::new(&format_flex_name(&pool_uuid, FlexRole::ThinData),
dm,
map_to_dm(&data_segments))?;
let data_dev = LinearDev::setup(&format_flex_name(&pool_uuid, FlexRole::ThinData),
dm,
map_to_dm(&data_segments))?;


let name = format_thinpool_name(&pool_uuid, ThinPoolRole::Pool);
Expand Down Expand Up @@ -212,9 +212,9 @@ impl ThinPool {
Err(e) => Err(e.into()),
}?;

let mdv_dev = LinearDev::new(&format_flex_name(&pool_uuid, FlexRole::MetadataVolume),
dm,
map_to_dm(&mdv_segments))?;
let mdv_dev = LinearDev::setup(&format_flex_name(&pool_uuid, FlexRole::MetadataVolume),
dm,
map_to_dm(&mdv_segments))?;
let mdv = MetadataVol::setup(&pool_uuid, mdv_dev)?;
let filesystem_metadatas = mdv.filesystems()?;

Expand Down Expand Up @@ -562,9 +562,10 @@ fn attempt_thin_repair(pool_uuid: PoolUuid,
meta_dev: LinearDev,
spare_segments: &[BlkDevSegment])
-> EngineResult<LinearDev> {
let mut new_meta_dev = LinearDev::new(&format_flex_name(&pool_uuid, FlexRole::ThinMetaSpare),
dm,
map_to_dm(spare_segments))?;
let mut new_meta_dev = LinearDev::setup(&format_flex_name(&pool_uuid,
FlexRole::ThinMetaSpare),
dm,
map_to_dm(spare_segments))?;


if !Command::new("thin_repair")
Expand Down
18 changes: 9 additions & 9 deletions tests/util/dm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ pub fn test_linear_device(paths: &[&Path]) -> () {
.collect::<Vec<_>>();

let dm = DM::new().unwrap();
let lineardev = LinearDev::new(DmName::new("stratis_testing_linear").expect("valid format"),
&dm,
segments)
let lineardev = LinearDev::setup(DmName::new("stratis_testing_linear").expect("valid format"),
&dm,
segments)
.unwrap();
let lineardev_size = blkdev_size(&OpenOptions::new()
.read(true)
Expand Down Expand Up @@ -84,9 +84,9 @@ pub fn test_thinpool_device(paths: &[&Path]) -> () {
.alloc_space(Bytes(16 * IEC::Mi).sectors())
.unwrap();
let metadata_dev =
LinearDev::new(DmName::new("stratis_testing_thinpool_metadata").expect("valid format"),
&dm,
map_to_dm(&meta_segs))
LinearDev::setup(DmName::new("stratis_testing_thinpool_metadata").expect("valid format"),
&dm,
map_to_dm(&meta_segs))
.unwrap();

// Clear the meta data device. If the first block is not all zeros - the
Expand All @@ -97,9 +97,9 @@ pub fn test_thinpool_device(paths: &[&Path]) -> () {

let data_segs = bd_mgr.alloc_space(Bytes(IEC::Gi).sectors()).unwrap();
let data_dev =
LinearDev::new(DmName::new("stratis_testing_thinpool_datadev").expect("valid format"),
&dm,
map_to_dm(&data_segs))
LinearDev::setup(DmName::new("stratis_testing_thinpool_datadev").expect("valid format"),
&dm,
map_to_dm(&data_segs))
.unwrap();
let thinpool_dev =
ThinPoolDev::new(DmName::new("stratis_testing_thinpool").expect("valid format"),
Expand Down

0 comments on commit be4cc40

Please sign in to comment.