Skip to content

Commit 3e43a88

Browse files
authored
Merge pull request #839 from jbaublitz/stratisd-metadata-rework
Make target table structs public to support easier alternate table construction
2 parents c26372b + fd707cf commit 3e43a88

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

src/cachedev.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,27 @@ pub const MAX_CACHE_BLOCK_SIZE: Sectors = Sectors(2 * IEC::Mi); // 1 GiB
3030

3131
const CACHE_TARGET_NAME: &str = "cache";
3232

33+
/// Struct representing params for a cache target
3334
#[derive(Clone, Debug, Eq, PartialEq)]
3435
pub struct CacheTargetParams {
36+
/// Cache metadata device
3537
pub meta: Device,
38+
/// Cache device
3639
pub cache: Device,
40+
/// Origin device with data to be cached
3741
pub origin: Device,
42+
/// Cache block size
3843
pub cache_block_size: Sectors,
44+
/// Feature arguments
3945
pub feature_args: HashSet<String>,
46+
/// IO policy
4047
pub policy: String,
48+
/// IO policy arguments
4149
pub policy_args: HashMap<String, String>,
4250
}
4351

4452
impl CacheTargetParams {
53+
/// Create a new CacheTargetParams struct
4554
pub fn new(
4655
meta: Device,
4756
cache: Device,
@@ -177,12 +186,15 @@ impl TargetParams for CacheTargetParams {
177186
}
178187
}
179188

189+
/// A target table for a cache device.
180190
#[derive(Clone, Debug, Eq, PartialEq)]
181191
pub struct CacheDevTargetTable {
192+
/// The device's table
182193
pub table: TargetLine<CacheTargetParams>,
183194
}
184195

185196
impl CacheDevTargetTable {
197+
/// Make a new CacheDevTargetTable from the required input
186198
pub fn new(start: Sectors, length: Sectors, params: CacheTargetParams) -> CacheDevTargetTable {
187199
CacheDevTargetTable {
188200
table: TargetLine::new(start, length, params),

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ extern crate assert_matches;
114114

115115
pub use crate::{
116116
cachedev::{
117-
CacheDev, CacheDevPerformance, CacheDevStatus, CacheDevUsage, CacheDevWorkingStatus,
118-
MAX_CACHE_BLOCK_SIZE, MIN_CACHE_BLOCK_SIZE,
117+
CacheDev, CacheDevPerformance, CacheDevStatus, CacheDevTargetTable, CacheDevUsage,
118+
CacheDevWorkingStatus, CacheTargetParams, MAX_CACHE_BLOCK_SIZE, MIN_CACHE_BLOCK_SIZE,
119119
},
120120
consts::IEC,
121121
core::{
@@ -130,11 +130,11 @@ pub use crate::{
130130
shared::{
131131
device_exists, DmDevice, TargetLine, TargetParams, TargetTable, TargetType, TargetTypeBuf,
132132
},
133-
thindev::{ThinDev, ThinDevWorkingStatus, ThinStatus},
133+
thindev::{ThinDev, ThinDevTargetTable, ThinDevWorkingStatus, ThinStatus, ThinTargetParams},
134134
thindevid::ThinDevId,
135135
thinpooldev::{
136-
ThinPoolDev, ThinPoolNoSpacePolicy, ThinPoolStatus, ThinPoolStatusSummary, ThinPoolUsage,
137-
ThinPoolWorkingStatus,
136+
ThinPoolDev, ThinPoolDevTargetTable, ThinPoolNoSpacePolicy, ThinPoolStatus,
137+
ThinPoolStatusSummary, ThinPoolTargetParams, ThinPoolUsage, ThinPoolWorkingStatus,
138138
},
139139
units::{Bytes, DataBlocks, MetaBlocks, Sectors, SECTOR_SIZE},
140140
};

src/thindev.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ use crate::{
1818

1919
const THIN_TARGET_NAME: &str = "thin";
2020

21+
/// Struct representing params for a thin target
2122
#[derive(Clone, Debug, Eq, PartialEq)]
2223
pub struct ThinTargetParams {
24+
/// Thin pool for the given thin device
2325
pub pool: Device,
26+
/// Thin ID
2427
pub thin_id: ThinDevId,
28+
/// Optional block device outside of pool to be treated as a read-only snapshot
29+
/// origin
2530
pub external_origin_dev: Option<Device>,
2631
}
2732

2833
impl ThinTargetParams {
34+
/// Create a new ThinTargetParams struct
2935
pub fn new(
3036
pool: Device,
3137
thin_id: ThinDevId,
@@ -92,12 +98,15 @@ impl TargetParams for ThinTargetParams {
9298
}
9399
}
94100

101+
/// A target table for a thin device.
95102
#[derive(Clone, Debug, Eq, PartialEq)]
96103
pub struct ThinDevTargetTable {
104+
/// The device's table
97105
pub table: TargetLine<ThinTargetParams>,
98106
}
99107

100108
impl ThinDevTargetTable {
109+
/// Make a new ThinDevTargetTable from required input
101110
pub fn new(start: Sectors, length: Sectors, params: ThinTargetParams) -> ThinDevTargetTable {
102111
ThinDevTargetTable {
103112
table: TargetLine::new(start, length, params),

src/thinpooldev.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,23 @@ use crate::core::devnode_to_devno;
2424

2525
const THINPOOL_TARGET_NAME: &str = "thin-pool";
2626

27+
/// Struct representing params for a thin pool target
2728
#[derive(Clone, Debug, Eq, PartialEq)]
2829
pub struct ThinPoolTargetParams {
30+
/// Thin pool metadata device
2931
pub metadata_dev: Device,
32+
/// Thin pool data device
3033
pub data_dev: Device,
34+
/// Block size for allocations within the thin pool
3135
pub data_block_size: Sectors,
36+
/// Amount of free space left at which to trigger the low water mark
3237
pub low_water_mark: DataBlocks,
38+
/// Feature arguments
3339
pub feature_args: HashSet<String>,
3440
}
3541

3642
impl ThinPoolTargetParams {
43+
/// Create a new ThinPoolTargetParams struct
3744
pub fn new(
3845
metadata_dev: Device,
3946
data_dev: Device,
@@ -136,12 +143,15 @@ impl TargetParams for ThinPoolTargetParams {
136143
}
137144
}
138145

146+
/// A target table for a thin pool device.
139147
#[derive(Clone, Debug, Eq, PartialEq)]
140148
pub struct ThinPoolDevTargetTable {
149+
/// The device's table
141150
pub table: TargetLine<ThinPoolTargetParams>,
142151
}
143152

144153
impl ThinPoolDevTargetTable {
154+
/// Make a new ThinPoolDevTargetTable from a suitable vec
145155
pub fn new(
146156
start: Sectors,
147157
length: Sectors,

0 commit comments

Comments
 (0)