未验证 提交 0a02901c 编写于 作者: Y Yifan Wu 提交者: GitHub

Merge pull request #79 from Direktor799/main

fix(BlockCache): Vec as aligned buf
use super::{BlockDevice, BLOCK_SZ};
use alloc::collections::VecDeque;
use alloc::sync::Arc;
use alloc::vec;
use alloc::vec::Vec;
use lazy_static::*;
use spin::Mutex;
pub struct BlockCache {
cache: [u8; BLOCK_SZ],
cache: Vec<u8>,
block_id: usize,
block_device: Arc<dyn BlockDevice>,
modified: bool,
......@@ -14,7 +16,8 @@ pub struct BlockCache {
impl BlockCache {
/// Load a new BlockCache from disk.
pub fn new(block_id: usize, block_device: Arc<dyn BlockDevice>) -> Self {
let mut cache = [0u8; BLOCK_SZ];
// for alignment and move effciency
let mut cache = vec![0u8; BLOCK_SZ];
block_device.read_block(block_id, &mut cache);
Self {
cache,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册