[cache (rust)] Fix data types

This commit is contained in:
Ming-Hung Tsai 2021-02-25 18:14:01 +08:00
parent 3d9b32e509
commit 74fcb9d505
2 changed files with 9 additions and 9 deletions

8
src/cache/xml.rs vendored
View File

@ -11,22 +11,22 @@ use quick_xml::Writer;
#[derive(Clone)]
pub struct Superblock {
pub uuid: String,
pub block_size: u64,
pub nr_cache_blocks: u64,
pub block_size: u32,
pub nr_cache_blocks: u32,
pub policy: String,
pub hint_width: u32,
}
#[derive(Clone)]
pub struct Map {
pub cblock: u64,
pub cblock: u32,
pub oblock: u64,
pub dirty: bool,
}
#[derive(Clone)]
pub struct Hint {
pub cblock: u64,
pub cblock: u32,
pub data: Vec<u8>,
}

View File

@ -24,8 +24,8 @@ pub fn write_xml(path: &Path, g: &mut dyn XmlGen) -> Result<()> {
}
pub struct CacheGen {
block_size: u64,
nr_cache_blocks: u64,
block_size: u32,
nr_cache_blocks: u32,
nr_origin_blocks: u64,
percent_resident: u8,
percent_dirty: u8,
@ -33,8 +33,8 @@ pub struct CacheGen {
impl CacheGen {
pub fn new(
block_size: u64,
nr_cache_blocks: u64,
block_size: u32,
nr_cache_blocks: u32,
nr_origin_blocks: u64,
percent_resident: u8,
percent_dirty: u8,
@ -67,7 +67,7 @@ impl XmlGen for CacheGen {
v.mappings_b()?;
{
let nr_resident = (self.nr_cache_blocks * 100 as u64) / (self.percent_resident as u64);
let nr_resident = (self.nr_cache_blocks * 100 as u32) / (self.percent_resident as u32);
let mut used = HashSet::new();
for n in 0..nr_resident {
let mut oblock = 0u64;