Make the file lookup faster

This commit is contained in:
Ruihan Li
2024-12-26 21:35:56 +08:00
committed by Tate, Hongliang Tian
parent fb8f493b43
commit b9ce3e64ad
59 changed files with 483 additions and 390 deletions

View File

@ -2,7 +2,10 @@
use super::SyscallReturn;
use crate::{
fs::{file_table::FileDesc, utils::FallocMode},
fs::{
file_table::{get_file_fast, FileDesc},
utils::FallocMode,
},
prelude::*,
process::ResourceType,
};
@ -21,10 +24,8 @@ pub fn sys_fallocate(
check_offset_and_len(offset, len, ctx)?;
let file = {
let file_table = ctx.posix_thread.file_table().lock();
file_table.get_file(fd)?.clone()
};
let mut file_table = ctx.thread_local.file_table().borrow_mut();
let file = get_file_fast!(&mut file_table, fd);
let falloc_mode = FallocMode::try_from(
RawFallocMode::from_bits(mode as _)