Skip to content

Commit

Permalink
passthrough: hornor no_open in do_getattr()
Browse files Browse the repository at this point in the history
Otherwise we'll get EBADF failure as we can't find handle in handle map.

Fixes: 2895435 ("passthrough: optimize async_do_getattr/do_getattr()")
Signed-off-by: Eryu Guan <[email protected]>
  • Loading branch information
eryugey authored and bergwolf committed Apr 27, 2022
1 parent e7fa805 commit 98dbac7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/passthrough/async_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,11 @@ impl<D: AsyncDrive> PassthroughFs<D> {
e
})?;

if let Some(h) = handle {
let hd = self.handle_map.get(h, inode)?;
// kernel sends 0 as handle in case of no_open, and it depends on fuse server to handle
// this case correctly.
if !self.no_open.load(Ordering::Relaxed) && handle.is_some() {
// Safe as we just checked handle
let hd = self.handle_map.get(handle.unwrap(), inode)?;
fd = hd.get_handle_raw_fd();
st = self.async_stat_fd(ctx, fd, None).await;
} else {
Expand Down
7 changes: 5 additions & 2 deletions src/passthrough/sync_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,11 @@ impl<D: AsyncDrive> PassthroughFs<D> {
e
})?;

if let Some(h) = handle {
let hd = self.handle_map.get(h, inode)?;
// kernel sends 0 as handle in case of no_open, and it depends on fuse server to handle
// this case correctly.
if !self.no_open.load(Ordering::Relaxed) && handle.is_some() {
// Safe as we just checked handle
let hd = self.handle_map.get(handle.unwrap(), inode)?;
fd = hd.get_handle_raw_fd();
st = Self::stat_fd(fd, None);
} else {
Expand Down

0 comments on commit 98dbac7

Please sign in to comment.