Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new 'create_options' argument when creating DM devices #3308

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ optional = true

[dependencies.devicemapper]
version = "0.33.3"
git = "https://github.com/bmr-cymru/devicemapper-rs"
branch = "bmr-create-options"
optional = true

[dependencies.dbus]
Expand Down
14 changes: 12 additions & 2 deletions src/engine/strat_engine/backstore/backstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use chrono::{DateTime, Utc};
use serde_json::Value;
use tempfile::TempDir;

use devicemapper::{CacheDev, Device, DmDevice, LinearDev, Sectors};
use devicemapper::{CacheDev, Device, DmDevice, DmOptions, LinearDev, Sectors};

use crate::{
engine::{
Expand Down Expand Up @@ -60,6 +60,7 @@ fn make_cache(
&dm_name,
Some(&dm_uuid),
cache_tier.meta_segments.map_to_dm(),
Some(DmOptions::private()),
)?;

if new {
Expand All @@ -77,6 +78,7 @@ fn make_cache(
&dm_name,
Some(&dm_uuid),
cache_tier.cache_segments.map_to_dm(),
Some(DmOptions::private()),
)?;

let (dm_name, dm_uuid) = format_backstore_ids(pool_uuid, CacheRole::Cache);
Expand All @@ -88,6 +90,7 @@ fn make_cache(
cache,
origin,
CACHE_BLOCK_SIZE,
Some(DmOptions::private()),
)?)
}

Expand Down Expand Up @@ -147,6 +150,7 @@ impl Backstore {
&dm_name,
Some(&dm_uuid),
data_tier.segments.map_to_dm(),
Some(DmOptions::private()),
) {
Ok(origin) => origin,
Err(e) => {
Expand Down Expand Up @@ -389,7 +393,13 @@ impl Backstore {
if create {
let table = self.data_tier.segments.map_to_dm();
let (dm_name, dm_uuid) = format_backstore_ids(pool_uuid, CacheRole::OriginSub);
let origin = LinearDev::setup(get_dm(), &dm_name, Some(&dm_uuid), table)?;
let origin = LinearDev::setup(
get_dm(),
&dm_name,
Some(&dm_uuid),
table,
Some(DmOptions::private()),
)?;
self.linear = Some(origin);
}

Expand Down
3 changes: 2 additions & 1 deletion src/engine/strat_engine/tests/real.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde_json::{from_reader, Value};
use uuid::Uuid;

use devicemapper::{
devnode_to_devno, Bytes, Device, DmDevice, DmName, LinearDev, LinearDevTargetParams,
devnode_to_devno, Bytes, Device, DmDevice, DmName, DmOptions, LinearDev, LinearDevTargetParams,
LinearTargetParams, Sectors, TargetLine, IEC,
};

Expand Down Expand Up @@ -186,6 +186,7 @@ fn make_linear_test_dev(devnode: &Path, start: Sectors, length: Sectors) -> Line
DmName::new(&format!("stratis_test_{}", Uuid::new_v4())).expect("valid format"),
None,
table,
Some(DmOptions::default()),
)
.unwrap()
}
Expand Down
13 changes: 11 additions & 2 deletions src/engine/strat_engine/thinpool/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ impl StratFilesystem {
) -> StratisResult<(FilesystemUuid, StratFilesystem)> {
let fs_uuid = FilesystemUuid::new_v4();
let (dm_name, dm_uuid) = format_thin_ids(pool_uuid, ThinRole::Filesystem(fs_uuid));
let mut thin_dev =
ThinDev::new(get_dm(), &dm_name, Some(&dm_uuid), size, thinpool_dev, id)?;
let mut thin_dev = ThinDev::new(
get_dm(),
&dm_name,
Some(&dm_uuid),
size,
thinpool_dev,
id,
Some(DmOptions::default()),
)?;

if let Err(err) = create_fs(&thin_dev.devnode(), Some(StratisUuid::Fs(fs_uuid)), false) {
if let Err(err2) = retry_with_index(Fixed::from_millis(100).take(4), |i| {
Expand Down Expand Up @@ -123,6 +130,7 @@ impl StratFilesystem {
fssave.size,
thinpool_dev,
fssave.thin_id,
Some(DmOptions::default()),
)?;
Ok(StratFilesystem {
used: init_used(&thin_dev),
Expand Down Expand Up @@ -192,6 +200,7 @@ impl StratFilesystem {
snapshot_dm_uuid,
thin_pool,
snapshot_thin_id,
Some(DmOptions::default()),
) {
Ok(thin_dev) => {
// If the source is mounted, XFS puts a dummy record in the
Expand Down
9 changes: 9 additions & 0 deletions src/engine/strat_engine/thinpool/thinpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ impl ThinPool {
&dm_name,
Some(&dm_uuid),
segs_to_table(backstore_device, &[meta_segments]),
Some(DmOptions::private()),
)?;

// Wipe the first 4 KiB, i.e. 8 sectors as recommended in kernel DM
Expand All @@ -371,6 +372,7 @@ impl ThinPool {
&dm_name,
Some(&dm_uuid),
segs_to_table(backstore_device, &[data_segments]),
Some(DmOptions::private()),
)?;

let (dm_name, dm_uuid) = format_flex_ids(pool_uuid, FlexRole::MetadataVolume);
Expand All @@ -379,6 +381,7 @@ impl ThinPool {
&dm_name,
Some(&dm_uuid),
segs_to_table(backstore_device, &[mdv_segments]),
Some(DmOptions::private()),
)?;
let mdv = MetadataVol::initialize(pool_uuid, mdv_dev)?;

Expand All @@ -403,6 +406,7 @@ impl ThinPool {
"no_discard_passdown".to_string(),
"skip_block_zeroing".to_string(),
],
Some(DmOptions::private()),
)?;

let thin_pool_status = thinpool_dev.status(get_dm(), DmOptions::default()).ok();
Expand Down Expand Up @@ -463,6 +467,7 @@ impl ThinPool {
&dm_name,
Some(&dm_uuid),
segs_to_table(backstore_device, &data_segments),
Some(DmOptions::private()),
)?;

// TODO: Remove in stratisd 4.0.
Expand Down Expand Up @@ -492,6 +497,7 @@ impl ThinPool {
"error_if_no_space".to_owned(),
]
}),
Some(DmOptions::private()),
)?;

// TODO: Remove in stratisd 4.0.
Expand All @@ -505,6 +511,7 @@ impl ThinPool {
&dm_name,
Some(&dm_uuid),
segs_to_table(backstore_device, &mdv_segments),
Some(DmOptions::private()),
)?;
let mdv = MetadataVol::setup(pool_uuid, mdv_dev)?;
let filesystem_metadatas = mdv.filesystems()?;
Expand Down Expand Up @@ -1672,6 +1679,7 @@ fn setup_metadev(
&dm_name,
Some(&dm_uuid),
segs_to_table(device, &meta_segments),
Some(DmOptions::private()),
)?;

if !device_exists(get_dm(), thinpool_name)? {
Expand Down Expand Up @@ -1703,6 +1711,7 @@ fn attempt_thin_repair(
&dm_name,
Some(&dm_uuid),
segs_to_table(device, spare_segments),
Some(DmOptions::private()),
)?;

thin_repair(&meta_dev.devnode(), &new_meta_dev.devnode())?;
Expand Down