Verified Commit 8c57fd95 authored by jD91mZM2's avatar jD91mZM2
Browse files

Fix bugs & increase page size

parent a1c69a8e
...@@ -20,7 +20,7 @@ use super::spin::Mutex; ...@@ -20,7 +20,7 @@ use super::spin::Mutex;
/// The size to round offset/len up to. /// The size to round offset/len up to.
/// This ensures more fmaps can share the same memory even with different parameters. /// This ensures more fmaps can share the same memory even with different parameters.
const PAGE_SIZE: usize = 8; const PAGE_SIZE: usize = 4096;
/// The max amount of fmaps that can be held simultaneously. /// The max amount of fmaps that can be held simultaneously.
/// This restriction is here because we can under no circumstances reallocate, /// This restriction is here because we can under no circumstances reallocate,
/// that would invalidate previous mappings. /// that would invalidate previous mappings.
...@@ -38,7 +38,7 @@ impl FmapKey { ...@@ -38,7 +38,7 @@ impl FmapKey {
FmapKey { FmapKey {
block: self.block, block: self.block,
offset: self.offset - self.offset % PAGE_SIZE, offset: self.offset - self.offset % PAGE_SIZE,
size: if remainder == 0 { self.size } else { self.size - remainder + self.size } size: if remainder == 0 { self.size } else { self.size - remainder + PAGE_SIZE }
} }
} }
pub fn is_compatible(&self, other: &FmapKey) -> bool { pub fn is_compatible(&self, other: &FmapKey) -> bool {
...@@ -68,7 +68,7 @@ impl Fmaps { ...@@ -68,7 +68,7 @@ impl Fmaps {
let mut first_empty = None; let mut first_empty = None;
for (i, entry) in self.0.iter_mut().enumerate() { for (i, entry) in self.0.iter_mut().enumerate() {
match entry { match entry {
None => first_empty = Some(i), None if first_empty.is_none() => first_empty = Some(i),
Some(entry) if entry.0.is_compatible(key) => return Ok((i, entry)), Some(entry) if entry.0.is_compatible(key) => return Ok((i, entry)),
_ => () _ => ()
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment