Skip to content

Commit

Permalink
Merge pull request #3563 from mulkieran/metadata-to-vec
Browse files Browse the repository at this point in the history
Do not construct a String from metadata when saving
  • Loading branch information
mulkieran authored Mar 11, 2024
2 parents 6a73c22 + 12a661b commit ffe9e43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/engine/strat_engine/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ impl StratPool {
/// Write current metadata to pool members.
#[pool_mutating_action("NoPoolChanges")]
pub fn write_metadata(&mut self, name: &str) -> StratisResult<()> {
let data = serde_json::to_string(&self.record(name))?;
self.backstore.save_state(data.as_bytes())
let data = serde_json::to_vec(&self.record(name))?;
self.backstore.save_state(&data)
}

/// Teardown a pool.
Expand Down Expand Up @@ -433,10 +433,8 @@ impl StratPool {
self.thin_pool.teardown(pool_uuid)?;
let mut data = self.record(pool_name);
data.started = Some(false);
let json = serde_json::to_string(&data).map_err(|e| (StratisError::from(e), false))?;
self.backstore
.save_state(json.as_bytes())
.map_err(|e| (e, false))?;
let json = serde_json::to_vec(&data).map_err(|e| (StratisError::from(e), false))?;
self.backstore.save_state(&json).map_err(|e| (e, false))?;
self.backstore.teardown(pool_uuid).map_err(|e| (e, false))?;
let bds = self.backstore.drain_bds();
Ok(DeviceSet::from(bds))
Expand Down
4 changes: 2 additions & 2 deletions src/engine/strat_engine/thinpool/mdv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl MetadataVol {
uuid: FilesystemUuid,
fs: &StratFilesystem,
) -> StratisResult<()> {
let data = serde_json::to_string(&fs.record(name, uuid))?;
let data = serde_json::to_vec(&fs.record(name, uuid))?;
let path = self
.mount_pt
.join(FILESYSTEM_DIR)
Expand All @@ -125,7 +125,7 @@ impl MetadataVol {
.create(true)
.open(&temp_path)?;

mdv_record_file.write_all(data.as_bytes())?;
mdv_record_file.write_all(&data)?;
// This ultimately results in an fsync() on the file.
mdv_record_file.sync_all()?;
}
Expand Down

0 comments on commit ffe9e43

Please sign in to comment.