Merge branch 'clone_grant_using_fmap' into 'master'

Clone grant using fmap

See merge request redox-os/kernel!190
This commit is contained in:
Jeremy Soller
2022-03-30 13:53:08 +00:00
5 changed files with 55 additions and 39 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ use crate::scheme::{self, SchemeNamespace, SchemeId};
use crate::syscall::error::{Result, Error, EBADF};
/// A file description
#[derive(Debug)]
#[derive(Clone, Copy, Debug)]
pub struct FileDescription {
/// The namespace the file was opened from (used for debugging)
pub namespace: SchemeNamespace,
+14 -8
View File
@@ -290,7 +290,15 @@ pub struct Grant {
mapped: bool,
owned: bool,
//TODO: This is probably a very heavy way to keep track of fmap'd files, perhaps move to the context?
pub desc_opt: Option<FileDescriptor>,
pub desc_opt: Option<GrantFileRef>,
}
#[derive(Clone, Debug)]
pub struct GrantFileRef {
pub desc: FileDescriptor,
pub offset: usize,
// TODO: Can the flags maybe be stored together with the page flags. Should some flags be kept,
// and others discarded when re-fmapping on clone?
pub flags: MapFlags,
}
impl Grant {
@@ -363,7 +371,7 @@ impl Grant {
}
}
pub fn map_inactive(src: VirtualAddress, dst: VirtualAddress, size: usize, flags: PageFlags<RmmA>, desc_opt: Option<FileDescriptor>, inactive_table: &mut InactivePageTable) -> Grant {
pub fn map_inactive(src: VirtualAddress, dst: VirtualAddress, size: usize, flags: PageFlags<RmmA>, desc_opt: Option<GrantFileRef>, inactive_table: &mut InactivePageTable) -> Grant {
let active_table = unsafe { ActivePageTable::new(src.kind()) };
let mut inactive_mapper = inactive_table.mapper();
@@ -507,10 +515,9 @@ impl Grant {
flush_all.flush();
if let Some(desc) = self.desc_opt.take() {
println!("Grant::unmap: close desc {:?}", desc);
if let Some(file_ref) = self.desc_opt.take() {
//TODO: This imposes a large cost on unmapping, but that cost cannot be avoided without modifying fmap and funmap
let _ = desc.close();
let _ = file_ref.desc.close();
}
self.mapped = false;
@@ -533,10 +540,9 @@ impl Grant {
ipi(IpiKind::Tlb, IpiTarget::Other);
if let Some(desc) = self.desc_opt.take() {
println!("Grant::unmap_inactive: close desc {:?}", desc);
if let Some(file_ref) = self.desc_opt.take() {
//TODO: This imposes a large cost on unmapping, but that cost cannot be avoided without modifying fmap and funmap
let _ = desc.close();
let _ = file_ref.desc.close();
}
self.mapped = false;