-
Notifications
You must be signed in to change notification settings - Fork 837
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
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5326dfb
Fix ObjectStore.LocalFileSystem.put_opts for blobfuse
RobinLin666 f107dc0
Fix ObjectStore.LocalFileSystem.put_opts for blobfuse
RobinLin666 2fffc37
fix comment
RobinLin666 f25ace3
fix race condition
RobinLin666 f5677bf
add comment
RobinLin666 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -338,28 +338,39 @@ impl ObjectStore for LocalFileSystem { | |
maybe_spawn_blocking(move || { | ||
let (mut file, suffix) = new_staged_upload(&path)?; | ||
let staging_path = staged_upload_path(&path, &suffix); | ||
let mut e_tag = None; | ||
|
||
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::Create => match std::fs::hard_link(&staging_path, &path) { | ||
Ok(_) => { | ||
let _ = std::fs::remove_file(&staging_path); // Attempt to cleanup | ||
None | ||
Ok(_) => { | ||
let metadata = file.metadata().map_err(|e| Error::Metadata { | ||
source: e.into(), | ||
path: path.to_string_lossy().to_string(), | ||
})?; | ||
e_tag = Some(get_etag(&metadata)); | ||
match opts.mode { | ||
PutMode::Overwrite => { | ||
std::mem::drop(file); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we get a comment explaining the purpose of this to future readers, otherwise it is likely to be accidentally removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, thanks |
||
match std::fs::rename(&staging_path, &path) { | ||
Ok(_) => None, | ||
Err(source) => Some(Error::UnableToRenameFile { source }), | ||
} | ||
} | ||
Err(source) => match source.kind() { | ||
ErrorKind::AlreadyExists => Some(Error::AlreadyExists { | ||
path: path.to_str().unwrap().to_string(), | ||
source, | ||
}), | ||
_ => Some(Error::UnableToRenameFile { source }), | ||
PutMode::Create => match std::fs::hard_link(&staging_path, &path) { | ||
Ok(_) => { | ||
let _ = std::fs::remove_file(&staging_path); // Attempt to cleanup | ||
None | ||
} | ||
Err(source) => match source.kind() { | ||
ErrorKind::AlreadyExists => Some(Error::AlreadyExists { | ||
path: path.to_str().unwrap().to_string(), | ||
source, | ||
}), | ||
_ => Some(Error::UnableToRenameFile { source }), | ||
}, | ||
}, | ||
}, | ||
PutMode::Update(_) => unreachable!(), | ||
}, | ||
PutMode::Update(_) => unreachable!(), | ||
} | ||
} | ||
Err(source) => Some(Error::UnableToCopyDataToFile { source }), | ||
}; | ||
|
||
|
@@ -368,13 +379,8 @@ impl ObjectStore for LocalFileSystem { | |
return Err(err.into()); | ||
} | ||
|
||
let metadata = file.metadata().map_err(|e| Error::Metadata { | ||
source: e.into(), | ||
path: path.to_string_lossy().to_string(), | ||
})?; | ||
|
||
Ok(PutResult { | ||
e_tag: Some(get_etag(&metadata)), | ||
e_tag, | ||
version: None, | ||
}) | ||
}) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work with blobfuse, the original description suggested the file had to be closed before the metadata could be retrieved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it works with blobfuse. Because when it sends
stat
system call, blobfuse will look for local file cache firstly and it will success.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm if this works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have tested it in local and it worked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tustvold, you can see https://github.com/Azure/azure-storage-fuse/blob/master/blobfuse/utilities.cpp#L136
For
metadate
request, blobfuse will check local cache firstly and skip remote request. It's different with rename requests.