@@ -44,18 +44,16 @@ struct Cache<Storage: driver::Storage> {
4444 write : UnsafeCell < Storage :: CACHE_BUFFER > ,
4545 // lookahead: aligned::Aligned<aligned::A4, Bytes<Storage::LOOKAHEAD_SIZE>>,
4646 lookahead : UnsafeCell < Storage :: LOOKAHEAD_BUFFER > ,
47- size : usize ,
47+ cache_size : usize ,
4848}
4949
5050impl < S : driver:: Storage > Cache < S > {
51- pub fn new ( storage : & S ) -> Self {
52- let cache_size = storage. cache_size ( ) ;
53- let lookahaed_size = storage. lookahead_size ( ) ;
51+ pub fn new ( cache_size : usize , lookahead_size : usize ) -> Self {
5452 Self {
5553 read : UnsafeCell :: new ( S :: CACHE_BUFFER :: with_len ( cache_size) ) ,
5654 write : UnsafeCell :: new ( S :: CACHE_BUFFER :: with_len ( cache_size) ) ,
57- lookahead : UnsafeCell :: new ( S :: LOOKAHEAD_BUFFER :: with_len ( lookahaed_size * 8 ) ) ,
58- size : cache_size,
55+ lookahead : UnsafeCell :: new ( S :: LOOKAHEAD_BUFFER :: with_len ( lookahead_size ) ) ,
56+ cache_size,
5957 }
6058 }
6159}
@@ -100,7 +98,7 @@ impl<Storage: driver::Storage> Allocation<Storage> {
10098 debug_assert ! ( cache_size <= block_size) ;
10199 debug_assert ! ( block_size % cache_size == 0 ) ;
102100
103- let cache = Cache :: new ( storage ) ;
101+ let cache = Cache :: new ( cache_size as _ , lookahead_size as _ ) ;
104102
105103 let filename_max_plus_one: u32 = crate :: consts:: FILENAME_MAX_PLUS_ONE ;
106104 debug_assert ! ( filename_max_plus_one > 1 ) ;
@@ -169,8 +167,8 @@ impl<Storage: driver::Storage> Allocation<Storage> {
169167// also consider "erasing" the lifetime completely
170168pub struct Filesystem < ' a , Storage : driver:: Storage > {
171169 alloc : RefCell < & ' a mut Allocation < Storage > > ,
172- cache_size : usize ,
173170 storage : & ' a mut Storage ,
171+ cache_size : usize ,
174172}
175173
176174fn metadata ( info : ll:: lfs_info ) -> Metadata {
@@ -1075,7 +1073,7 @@ impl<'a, Storage: driver::Storage> Filesystem<'a, Storage> {
10751073 alloc. config . lookahead_buffer = alloc. cache . lookahead . get_mut ( ) . as_mut_ptr ( ) as * mut c_void ;
10761074
10771075 Filesystem {
1078- cache_size : alloc. cache . size ,
1076+ cache_size : alloc. cache . cache_size ,
10791077 alloc : RefCell :: new ( alloc) ,
10801078 storage,
10811079 }
0 commit comments