Skip to content

Commit 29f639e

Browse files
bergwolferyugey
authored andcommitted
api: forget and batch forget must not reply
Otherwise, the kernel would fail the reply write syscall with ENOENT and we cannot tell whether it's because fuse connection is closed or not. Signed-off-by: Peng Tao <[email protected]>
1 parent ffaea12 commit 29f639e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/api/server/sync_io.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ impl<F: FileSystem + Sync> Server<F> {
3939
let in_header: InHeader = r.read_obj().map_err(Error::DecodeMessage)?;
4040
let mut ctx = SrvContext::<F, S>::new(in_header, r, w);
4141
if ctx.in_header.len > (MAX_BUFFER_SIZE + BUFFER_HEADER_SIZE) {
42+
if in_header.opcode == Opcode::Forget as u32
43+
|| in_header.opcode == Opcode::BatchForget as u32
44+
{
45+
// Forget and batch-forget do not require reply.
46+
return Err(Error::InvalidMessage(io::Error::from_raw_os_error(
47+
libc::EOVERFLOW,
48+
)));
49+
}
4250
return ctx.reply_error_explicit(io::Error::from_raw_os_error(libc::ENOMEM));
4351
}
4452

@@ -1007,10 +1015,14 @@ impl<F: FileSystem + Sync> Server<F> {
10071015

10081016
if let Some(size) = (count as usize).checked_mul(size_of::<ForgetOne>()) {
10091017
if size > MAX_BUFFER_SIZE as usize {
1010-
return ctx.reply_error_explicit(io::Error::from_raw_os_error(libc::ENOMEM));
1018+
return Err(Error::InvalidMessage(io::Error::from_raw_os_error(
1019+
libc::EOVERFLOW,
1020+
)));
10111021
}
10121022
} else {
1013-
return ctx.reply_error_explicit(io::Error::from_raw_os_error(libc::EOVERFLOW));
1023+
return Err(Error::InvalidMessage(io::Error::from_raw_os_error(
1024+
libc::EOVERFLOW,
1025+
)));
10141026
}
10151027

10161028
let mut requests = Vec::with_capacity(count as usize);

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ pub enum Error {
7474
/// The `size` field of the `SetxattrIn` message does not match the length
7575
/// of the decoded value.
7676
InvalidXattrSize((u32, usize)),
77+
/// Invalid message that the server cannot handle properly.
78+
InvalidMessage(io::Error),
7779
}
7880

7981
impl error::Error for Error {}
@@ -92,6 +94,7 @@ impl fmt::Display for Error {
9294
"The `size` field of the `SetxattrIn` message does not match the length of the \
9395
decoded value: size = {size}, value.len() = {len}"
9496
),
97+
InvalidMessage(err) => write!(f, "cannot process fuse message: {err}"),
9598
}
9699
}
97100
}

0 commit comments

Comments
 (0)