Removed unused vmo type

This commit is contained in:
Jianfeng Jiang
2023-07-17 11:02:49 +08:00
committed by Tate, Hongliang Tian
parent 38a78cc3ce
commit 2c33f5dae1
2 changed files with 9 additions and 20 deletions

View File

@ -127,23 +127,11 @@ bitflags! {
} }
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum VmoType {
/// This vmo_ is created as a copy on write child
CopyOnWriteChild,
/// This vmo_ is created as a slice child
SliceChild,
/// This vmo_ is not created as a child of a parent vmo
NotChild,
}
pub(super) struct Vmo_ { pub(super) struct Vmo_ {
/// Flags /// Flags
flags: VmoFlags, flags: VmoFlags,
/// VmoInner /// VmoInner
inner: Mutex<VmoInner>, inner: Mutex<VmoInner>,
/// vmo type
vmo_type: VmoType,
} }
struct VmoInner { struct VmoInner {
@ -321,6 +309,14 @@ impl VmoInner {
Ok(frame) Ok(frame)
} }
fn is_cow_child(&self) -> bool {
if let Some(inherited_pages) = &self.inherited_pages {
inherited_pages.is_copy_on_write
} else {
false
}
}
} }
impl Vmo_ { impl Vmo_ {
@ -474,7 +470,7 @@ impl<R> Vmo<R> {
} }
pub fn is_cow_child(&self) -> bool { pub fn is_cow_child(&self) -> bool {
self.0.vmo_type == VmoType::CopyOnWriteChild self.0.inner.lock().is_cow_child()
} }
} }

View File

@ -11,7 +11,6 @@ use typeflags_util::{SetExtend, SetExtendOp};
use crate::prelude::*; use crate::prelude::*;
use crate::vm::vmo::InheritedPages; use crate::vm::vmo::InheritedPages;
use crate::vm::vmo::VmoType;
use crate::vm::vmo::{VmoInner, Vmo_}; use crate::vm::vmo::{VmoInner, Vmo_};
use jinux_rights::{Dup, Rights, TRightSet, TRights, Write}; use jinux_rights::{Dup, Rights, TRightSet, TRights, Write};
@ -136,7 +135,6 @@ fn alloc_vmo_(size: usize, flags: VmoFlags, pager: Option<Arc<dyn Pager>>) -> Re
Ok(Vmo_ { Ok(Vmo_ {
flags, flags,
inner: Mutex::new(vmo_inner), inner: Mutex::new(vmo_inner),
vmo_type: VmoType::NotChild,
}) })
} }
@ -499,14 +497,9 @@ fn alloc_child_vmo_(
committed_pages: BTreeMap::new(), committed_pages: BTreeMap::new(),
inherited_pages: Some(inherited_pages), inherited_pages: Some(inherited_pages),
}; };
let vmo_type = match child_type {
ChildType::Cow => VmoType::CopyOnWriteChild,
ChildType::Slice => VmoType::SliceChild,
};
Ok(Vmo_ { Ok(Vmo_ {
flags: child_flags, flags: child_flags,
inner: Mutex::new(vmo_inner), inner: Mutex::new(vmo_inner),
vmo_type,
}) })
} }