@@ -63,6 +63,8 @@ impl Drop for Downstairs {
63
63
#[ derive( Debug ) ]
64
64
pub struct CrucibleDisk {
65
65
device_name : DeviceName ,
66
+ disk_id : Uuid ,
67
+ guest_os : Option < GuestOsKind > ,
66
68
inner : Mutex < Inner > ,
67
69
}
68
70
@@ -81,22 +83,23 @@ impl CrucibleDisk {
81
83
) -> anyhow:: Result < Self > {
82
84
Ok ( Self {
83
85
device_name,
86
+ disk_id : Uuid :: new_v4 ( ) ,
87
+ guest_os,
84
88
inner : Mutex :: new ( Inner :: new (
85
89
min_disk_size_gib,
86
90
block_size,
87
91
downstairs_binary_path,
88
92
downstairs_ports,
89
93
data_dir_root,
90
94
read_only_parent,
91
- guest_os,
92
95
log_mode,
93
96
) ?) ,
94
97
} )
95
98
}
96
99
97
100
/// Obtains the current volume construction request for this disk.
98
101
pub fn vcr ( & self ) -> VolumeConstructionRequest {
99
- self . inner . lock ( ) . unwrap ( ) . vcr ( )
102
+ self . inner . lock ( ) . unwrap ( ) . vcr ( self . disk_id )
100
103
}
101
104
102
105
/// Sets the generation number to use in subsequent calls to create a
@@ -112,11 +115,11 @@ impl super::DiskConfig for CrucibleDisk {
112
115
}
113
116
114
117
fn backend_spec ( & self ) -> ComponentV0 {
115
- self . inner . lock ( ) . unwrap ( ) . backend_spec ( )
118
+ self . inner . lock ( ) . unwrap ( ) . backend_spec ( self . disk_id )
116
119
}
117
120
118
121
fn guest_os ( & self ) -> Option < GuestOsKind > {
119
- self . inner . lock ( ) . unwrap ( ) . guest_os ( )
122
+ self . guest_os
120
123
}
121
124
122
125
fn as_crucible ( & self ) -> Option < & CrucibleDisk > {
@@ -126,9 +129,6 @@ impl super::DiskConfig for CrucibleDisk {
126
129
127
130
#[ derive( Debug ) ]
128
131
struct Inner {
129
- /// The UUID to insert into this disk's `VolumeConstructionRequest`s.
130
- id : Uuid ,
131
-
132
132
/// The disk's block size.
133
133
block_size : BlockSize ,
134
134
@@ -144,9 +144,6 @@ struct Inner {
144
144
/// An optional path to a file to use as a read-only parent for this disk.
145
145
read_only_parent : Option < PathBuf > ,
146
146
147
- /// The kind of guest OS that can be found on this disk, if there is one.
148
- guest_os : Option < GuestOsKind > ,
149
-
150
147
/// The base64-encoded encryption key to use for this disk.
151
148
encryption_key : String ,
152
149
@@ -166,7 +163,6 @@ impl Inner {
166
163
downstairs_ports : & [ u16 ] ,
167
164
data_dir_root : & impl AsRef < Path > ,
168
165
read_only_parent : Option < & impl AsRef < Path > > ,
169
- guest_os : Option < GuestOsKind > ,
170
166
log_mode : ServerLogMode ,
171
167
) -> anyhow:: Result < Self > {
172
168
// To create a region, Crucible requires a block size, an extent size
@@ -313,7 +309,6 @@ impl Inner {
313
309
}
314
310
315
311
Ok ( Self {
316
- id : disk_uuid,
317
312
block_size,
318
313
blocks_per_extent,
319
314
extent_count : extents_in_disk as u32 ,
@@ -328,13 +323,12 @@ impl Inner {
328
323
bytes
329
324
} ,
330
325
) ,
331
- guest_os,
332
326
generation : 1 ,
333
327
} )
334
328
}
335
329
336
- fn backend_spec ( & self ) -> ComponentV0 {
337
- let vcr = self . vcr ( ) ;
330
+ fn backend_spec ( & self , disk_id : Uuid ) -> ComponentV0 {
331
+ let vcr = self . vcr ( disk_id ) ;
338
332
339
333
ComponentV0 :: CrucibleStorageBackend ( CrucibleStorageBackend {
340
334
request_json : serde_json:: to_string ( & vcr)
@@ -343,19 +337,19 @@ impl Inner {
343
337
} )
344
338
}
345
339
346
- fn vcr ( & self ) -> VolumeConstructionRequest {
340
+ fn vcr ( & self , disk_id : Uuid ) -> VolumeConstructionRequest {
347
341
let downstairs_addrs =
348
342
self . downstairs_instances . iter ( ) . map ( |ds| ds. address ) . collect ( ) ;
349
343
350
344
VolumeConstructionRequest :: Volume {
351
- id : self . id ,
345
+ id : disk_id ,
352
346
block_size : self . block_size . bytes ( ) ,
353
347
sub_volumes : vec ! [ VolumeConstructionRequest :: Region {
354
348
block_size: self . block_size. bytes( ) ,
355
349
blocks_per_extent: self . blocks_per_extent,
356
350
extent_count: self . extent_count,
357
351
opts: CrucibleOpts {
358
- id: self . id ,
352
+ id: disk_id ,
359
353
target: downstairs_addrs,
360
354
lossy: false ,
361
355
flush_timeout: None ,
@@ -377,10 +371,6 @@ impl Inner {
377
371
} ) ,
378
372
}
379
373
}
380
-
381
- fn guest_os ( & self ) -> Option < GuestOsKind > {
382
- self . guest_os
383
- }
384
374
}
385
375
386
376
fn run_crucible_downstairs (
0 commit comments