Skip to content

Commit

Permalink
handle ENOSPC by running the evicter
Browse files Browse the repository at this point in the history
fixes #1
  • Loading branch information
kahing committed Sep 9, 2017
1 parent e3fea8b commit e83d976
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/catfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ mod inode;
mod substr;

use self::inode::Inode;
use self::flags::DiskSpace;
use super::evicter::Evicter;

#[derive(Default)]
struct InodeStore {
Expand Down Expand Up @@ -636,6 +638,15 @@ impl CatFS {
reply.error(e2.raw_os_error().unwrap());
return;
}
} else if e.errno() == libc::ENOSPC {
debug!(
"write(0x{:016x}, 0x{:016x}, {}) = ENOSPC",
ino,
fh,
data.len()
);
let _ = Evicter::new(self.cache_dir, &DiskSpace::Percent(1.0))
.loop_once();
} else {
error!(
"<-- !write 0x{:016x} {:?} @ {} = {}",
Expand Down
2 changes: 1 addition & 1 deletion src/evicter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Evicter {
return to_evict(&self.low_watermark, st);
}

fn loop_once(&self) -> error::Result<()> {
pub fn loop_once(&self) -> error::Result<()> {
let st = (self.statvfs)(self.dir)?;

let to_evict_bytes = self.should_evict(&st);
Expand Down

0 comments on commit e83d976

Please sign in to comment.