Skip to content

Commit db715a4

Browse files
chuanlang.gcwliubogithub
authored andcommitted
fusedev: commit() no longer returns IoError
Writing fuse replies back to kernel should always return `EncodeMessage` with errors. So writing fuse replies will return unique error code hinting an error happens when replies. Signed-off-by: Changwei Ge <chge@linux.alibaba.com>
1 parent 001a2cb commit db715a4

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/api/server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ impl<F: FileSystem + Sync> Server<F> {
571571
};
572572

573573
w.write_all(out.as_slice()).map_err(Error::EncodeMessage)?;
574-
w.commit(&[&data_writer.0]).map_err(Error::IoError)?;
574+
w.commit(&[&data_writer.0]).map_err(Error::EncodeMessage)?;
575575
Ok(out.len as usize)
576576
}
577577
Err(e) => reply_error(e, in_header.unique, w),
@@ -976,7 +976,7 @@ impl<F: FileSystem + Sync> Server<F> {
976976
};
977977

978978
w.write_all(out.as_slice()).map_err(Error::EncodeMessage)?;
979-
w.commit(&[&cursor]).map_err(Error::IoError)?;
979+
w.commit(&[&cursor]).map_err(Error::EncodeMessage)?;
980980
Ok(out.len as usize)
981981
}
982982
}

src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ pub enum Error {
7575
/// The `size` field of the `SetxattrIn` message does not match the length
7676
/// of the decoded value.
7777
InvalidXattrSize((u32, usize)),
78-
/// An IO related error has happened.
79-
IoError(io::Error),
8078
}
8179

8280
impl error::Error for Error {}
@@ -96,7 +94,6 @@ impl fmt::Display for Error {
9694
decoded value: size = {}, value.len() = {}",
9795
size, len
9896
),
99-
IoError(err) => write!(f, "fail to handle request: {}", err),
10097
}
10198
}
10299
}

src/transport/fusedev/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ impl<'a> Writer<'a> {
163163
if !buf.is_empty() {
164164
return writev(self.fd, buf.as_slice()).map_err(|e| {
165165
error! {"fail to write to fuse device on commit: {}", e};
166-
io::Error::new(io::ErrorKind::Other, format!("{}", e))
166+
e.as_errno()
167+
.and_then(|r| Some(io::Error::from_raw_os_error(r as i32)))
168+
.unwrap_or_else(|| io::Error::new(io::ErrorKind::Other, format!("{}", e)))
167169
});
168170
}
169171
Ok(0)

0 commit comments

Comments
 (0)