Skip to content

Commit

Permalink
Added Filename in InodeError
Browse files Browse the repository at this point in the history
Signed-off-by: Ankit Saurabh <[email protected]>
  • Loading branch information
Ankit Saurabh committed Nov 27, 2023
1 parent 801e4c1 commit c0c74e0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mountpoint-s3/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ where
let len = {
let mut request = match &handle.typ {
FileHandleType::Write(request) => request.lock().await,
FileHandleType::Read { .. } => return Err(err!(libc::EBADF, "file handle is not open for writes")),
FileHandleType::Read { .. } => return Err(err!(libc::EBADF, "file handle is not open for writes (key={:?})", handle.full_key)),
};
request.write(offset, data, &handle.full_key).await?
};
Expand Down
2 changes: 1 addition & 1 deletion mountpoint-s3/src/fs/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl ToErrno for InodeError {
fn to_errno(&self) -> libc::c_int {
match self {
InodeError::ClientError(_) => libc::EIO,
InodeError::FileDoesNotExist => libc::ENOENT,
InodeError::FileDoesNotExist(_) => libc::ENOENT,
InodeError::InodeDoesNotExist(_) => libc::ENOENT,
InodeError::InvalidFileName(_) => libc::EINVAL,
InodeError::NotADirectory(_) => libc::ENOTDIR,
Expand Down
14 changes: 7 additions & 7 deletions mountpoint-s3/src/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl Superblock {
.await;
match existing {
Ok(lookup) => return Err(InodeError::FileAlreadyExists(lookup.inode.err())),
Err(InodeError::FileDoesNotExist) => (),
Err(InodeError::FileDoesNotExist(_)) => (),
Err(e) => return Err(e),
}

Expand Down Expand Up @@ -787,7 +787,7 @@ impl SuperblockInner {
InodeKindData::Directory { children, .. } => children.get(name),
};
match (remote, inode) {
(None, None) => Err(InodeError::FileDoesNotExist),
(None, None) => Err(InodeError::FileDoesNotExist(name.into())),
(Some(remote), Some(existing_inode)) => {
let mut existing_state = existing_inode.get_mut_inode_state()?;
let existing_is_remote = existing_state.write_status == WriteStatus::Remote;
Expand Down Expand Up @@ -824,7 +824,7 @@ impl SuperblockInner {
InodeKindData::Directory { children, .. } => children.get(name).cloned(),
};
match (remote, inode) {
(None, None) => Err(InodeError::FileDoesNotExist),
(None, None) => Err(InodeError::FileDoesNotExist(name.into())),
(None, Some(existing_inode)) => {
let InodeKindData::Directory {
children,
Expand Down Expand Up @@ -854,7 +854,7 @@ impl SuperblockInner {
// being written. It must have previously existed but been removed on the remote
// side.
children.remove(name);
Err(InodeError::FileDoesNotExist)
Err(InodeError::FileDoesNotExist(name.into()))
}
}
(Some(remote), None) => {
Expand Down Expand Up @@ -1471,8 +1471,8 @@ impl InodeStat {
pub enum InodeError {
#[error("error from ObjectClient")]
ClientError(#[source] anyhow::Error),
#[error("file does not exist")]
FileDoesNotExist,
#[error("file {0:?} does not exist")]
FileDoesNotExist(OsString),
#[error("inode {0} does not exist")]
InodeDoesNotExist(InodeNo),
#[error("invalid file name {0:?}")]
Expand Down Expand Up @@ -2315,7 +2315,7 @@ mod tests {
// All nested dirs disappear
let dirname = nested_dirs.first().unwrap();
let lookedup = superblock.lookup(&client, FUSE_ROOT_INODE, dirname.as_ref()).await;
assert!(matches!(lookedup, Err(InodeError::FileDoesNotExist)));
assert!(matches!(lookedup, Err(InodeError::FileDoesNotExist(_))));
}

#[tokio::test]
Expand Down
4 changes: 2 additions & 2 deletions mountpoint-s3/src/prefetch/part_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ where
{
Ok(get_object_result) => get_object_result,
Err(e) => {
error!(error=?e, "GetObject request failed");
error!(key, error=?e, "GetObject request failed");
part_queue_producer.push(Err(PrefetchReadError::GetRequestFailed(e)));
return;
}
Expand Down Expand Up @@ -227,7 +227,7 @@ where
}
}
Some(Err(e)) => {
error!(error=?e, "GetObject body part failed");
error!(key, error=?e, "GetObject body part failed");
part_queue_producer.push(Err(PrefetchReadError::GetRequestFailed(e)));
break;
}
Expand Down

0 comments on commit c0c74e0

Please sign in to comment.