Skip to content

Commit be90837

Browse files
zyfjeffjiangliu
authored andcommitted
Fix batch forget can't handle too large msg
error: cannot process fuse message: Value too large for defined data type By default, when fuse sever reads the batch forget request, the bufsize given is MAX_BUFFER_SIZE + BUFFER_HEADER_SIZE, and the fuse kernel will fill this buffer as much as possible, so the size of the data that batch forget can fill should be the total buffer size - fuse header - batch forget header Here's the code for the fuse kernel to fill the batch forget request. ``` struct fuse_batch_forget_in arg = { .count = 0 }; struct fuse_in_header ih = { .opcode = FUSE_BATCH_FORGET, .unique = fuse_get_unique(fiq), .len = sizeof(ih) + sizeof(arg), }; if (nbytes < ih.len) { spin_unlock(&fiq->lock); return -EINVAL; } max_forgets = (nbytes - ih.len) / sizeof(struct fuse_forget_one); head = fuse_dequeue_forget(fiq, max_forgets, &count); spin_unlock(&fiq->lock); arg.count = count; ih.len += count * sizeof(struct fuse_forget_one); ``` so fuse_batch_forget_in.count * sizeof(struct fuse_forget_one) should less than or equal to bufsize - sizeof(fuse_in_header) - sizeof(fuse_batch_forget_in) Signed-off-by: zyfjeff <[email protected]>
1 parent d925e47 commit be90837

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/api/server/sync_io.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,11 @@ impl<F: FileSystem + Sync> Server<F> {
11071107
let BatchForgetIn { count, .. } = ctx.r.read_obj().map_err(Error::DecodeMessage)?;
11081108

11091109
if let Some(size) = (count as usize).checked_mul(size_of::<ForgetOne>()) {
1110-
if size > MAX_BUFFER_SIZE as usize {
1110+
if size
1111+
> (MAX_BUFFER_SIZE + BUFFER_HEADER_SIZE
1112+
- size_of::<BatchForgetIn>() as u32
1113+
- size_of::<InHeader>() as u32) as usize
1114+
{
11111115
return Err(Error::InvalidMessage(io::Error::from_raw_os_error(
11121116
libc::EOVERFLOW,
11131117
)));

0 commit comments

Comments
 (0)