patch: increase FUSE block size and add retry

1. this should make file managers read small file in one request more
   likely
2. implemented retry, max times 3

Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
This commit is contained in:
ClSlaid 2023-10-28 11:14:16 +08:00
parent ed0ded33b7
commit 075a877284
No known key found for this signature in database
GPG Key ID: E0A5F564C51C056E
2 changed files with 19 additions and 19 deletions

View File

@ -1,11 +0,0 @@
#include "../cliprdr.h"
void xf_cliprdr_init(CliprdrClientContext* cliprdr)
{
(void)cliprdr;
}
void xf_cliprdr_uninit( CliprdrClientContext* cliprdr)
{
(void)cliprdr;
}

View File

@ -43,10 +43,11 @@ use crate::{send_data, ClipboardFile, CliprdrError};
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use super::LDAP_EPOCH_DELTA; use super::LDAP_EPOCH_DELTA;
/// fuse server ready retry max times
const READ_RETRY: i32 = 3;
/// block size for fuse, align to our asynchronic request size over FileContentsRequest. /// block size for fuse, align to our asynchronic request size over FileContentsRequest.
/// const BLOCK_SIZE: u32 = 4 * 1024 * 1024;
/// Question: will this hint users to read data in this size?
const BLOCK_SIZE: u32 = 128 * 1024;
/// read only permission /// read only permission
const PERM_READ: u16 = 0o444; const PERM_READ: u16 = 0o444;
@ -403,6 +404,7 @@ impl fuser::Filesystem for FuseServer {
reply.opened(fh, 0); reply.opened(fh, 0);
} }
// todo: implement retry
fn read( fn read(
&mut self, &mut self,
_req: &fuser::Request<'_>, _req: &fuser::Request<'_>,
@ -539,7 +541,7 @@ impl FuseServer {
clip_data_id: 0, clip_data_id: 0,
}; };
send_data(node.conn_id, request); send_data(node.conn_id, request.clone());
log::debug!( log::debug!(
"waiting for read reply for {:?} on stream: {}", "waiting for read reply for {:?} on stream: {}",
@ -547,6 +549,8 @@ impl FuseServer {
node.stream_id node.stream_id
); );
let mut retry_times = 0;
loop { loop {
let reply = self.rx.recv_timeout(self.timeout).map_err(|e| { let reply = self.rx.recv_timeout(self.timeout).map_err(|e| {
log::error!("failed to receive file list from channel: {:?}", e); log::error!("failed to receive file list from channel: {:?}", e);
@ -563,11 +567,18 @@ impl FuseServer {
log::debug!("stream id mismatch, ignore"); log::debug!("stream id mismatch, ignore");
continue; continue;
} }
if msg_flags & 1 == 0 { if msg_flags & 1 == 0 {
return Err(std::io::Error::new( retry_times += 1;
std::io::ErrorKind::Other, if retry_times > READ_RETRY {
"failure request", return Err(std::io::Error::new(
)); std::io::ErrorKind::Other,
"failure request",
));
}
send_data(node.conn_id, request.clone());
continue;
} }
return Ok(requested_data); return Ok(requested_data);
} }