Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ObjectStore.LocalFileSystem.put_opts for blobfuse #5094

Merged
merged 5 commits into from
Nov 27, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions object_store/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,13 @@ impl ObjectStore for LocalFileSystem {

let err = match file.write_all(&bytes) {
Ok(_) => match opts.mode {
PutMode::Overwrite => match std::fs::rename(&staging_path, &path) {
Ok(_) => None,
Err(source) => Some(Error::UnableToRenameFile { source }),
},
PutMode::Overwrite => {
std::mem::drop(file);
match std::fs::rename(&staging_path, &path) {
Ok(_) => None,
Err(source) => Some(Error::UnableToRenameFile { source }),
}
}
PutMode::Create => match std::fs::hard_link(&staging_path, &path) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this behave correctly on blobfuse, I'm not sure it does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, blobfuse,s3fs and goofys all don't support hard link. But they can choose override mode.

Ok(_) => {
let _ = std::fs::remove_file(&staging_path); // Attempt to cleanup
Expand All @@ -368,7 +371,7 @@ impl ObjectStore for LocalFileSystem {
return Err(err.into());
}

let metadata = file.metadata().map_err(|e| Error::Metadata {
let metadata = metadata(&path).map_err(|e| Error::Metadata {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now racy in the event of a concurrent put

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, fixed.

source: e.into(),
path: path.to_string_lossy().to_string(),
})?;
Expand Down