Skip to content

Commit 242e05f

Browse files
committed
Invalidate cache if read fails.
1 parent 2fbd6cb commit 242e05f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/blockdevice.rs

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ where
112112
/// Read a block, and return a reference to it.
113113
pub fn read(&mut self, block_idx: BlockIdx) -> Result<&Block, D::Error> {
114114
if self.block_idx != Some(block_idx) {
115+
self.block_idx = None;
115116
self.block_device.read(&mut self.block, block_idx)?;
116117
self.block_idx = Some(block_idx);
117118
}
@@ -121,6 +122,7 @@ where
121122
/// Read a block, and return a reference to it.
122123
pub fn read_mut(&mut self, block_idx: BlockIdx) -> Result<&mut Block, D::Error> {
123124
if self.block_idx != Some(block_idx) {
125+
self.block_idx = None;
124126
self.block_device.read(&mut self.block, block_idx)?;
125127
self.block_idx = Some(block_idx);
126128
}

0 commit comments

Comments
 (0)