Skip to content

Commit

Permalink
Uniformly advance time in logrotate_fs
Browse files Browse the repository at this point in the history
For the sake of consitency, always update time when the state lock
is taken.

Signed-off-by: Brian L. Troutwine <[email protected]>
  • Loading branch information
blt committed Oct 29, 2024
1 parent e6bc8ca commit 87333f2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lading/src/generator/file_gen/logrotate_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ impl Filesystem for LogrotateFS {
fn lookup(&mut self, _: &Request, parent: u64, name: &OsStr, reply: ReplyEntry) {
let tick = self.get_current_tick();
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

let name_str = name.to_str().unwrap_or("");
if let Some(ino) = state.lookup(tick, parent as usize, name_str) {
Expand All @@ -262,6 +263,7 @@ impl Filesystem for LogrotateFS {
fn getattr(&mut self, _: &Request, ino: u64, reply: ReplyAttr) {
let tick = self.get_current_tick();
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

if let Some(attr) = getattr_helper(&mut state, self.start_time_system, tick, ino as usize) {
reply.attr(&TTL, &attr);
Expand All @@ -284,6 +286,7 @@ impl Filesystem for LogrotateFS {
) {
let tick = self.get_current_tick();
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

// Get the FileHandle from fh
let file_handle = {
Expand Down Expand Up @@ -319,6 +322,7 @@ impl Filesystem for LogrotateFS {
) {
let tick = self.get_current_tick();
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

// Remove the FileHandle from the mapping
let file_handle = {
Expand Down Expand Up @@ -399,6 +403,7 @@ impl Filesystem for LogrotateFS {
fn open(&mut self, _req: &Request, ino: u64, flags: i32, reply: fuser::ReplyOpen) {
let tick = self.get_current_tick();
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

if let Some(file_handle) = state.open_file(tick, ino as usize) {
let fh = file_handle.id();
Expand Down

0 comments on commit 87333f2

Please sign in to comment.