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

bug in block cache open call #1580

Open
wants to merge 7 commits into
base: blobfuse/2.4.1
Choose a base branch
from
Open

Conversation

syeleti-msft
Copy link
Member

@syeleti-msft syeleti-msft commented Nov 28, 2024

✅ What

Current implementation of open file when opened in O_WRONLY mode truncates the file to zero.
While this mode - means we should have opened the file in read write mode, not truncate it.
So, This is incorrect behaviour.

👩‍🔬 How to validate

We don't see it in the normal scenario as write-back cache is on by default. All the open calls with O_WRONLY will be redirected to O_RDWR mode.
So, To simulate this issue, turn off the write-back cache while mounting with --disable-writeback-cache=true and then open file in O_WRONLY mode, you see that the file is truncated to size zero.

…cate the file to zero. This is incorrect behaviour.

We don't see it in the normal scenario as write-back cache is on by default. Hence all the open calls with O_WRONLY will be redirected O_RDWR.
To simulate this turn of the write-back cache and then open file in O_WRONLY.
@vibhansa-msft vibhansa-msft added this to the v2-2.4.1 milestone Nov 29, 2024
@vibhansa-msft vibhansa-msft changed the base branch from main to blobfuse/2.4.1 November 29, 2024 07:52
@@ -397,7 +397,7 @@ func (bc *BlockCache) OpenFile(options internal.OpenFileOptions) (*handlemap.Han
log.Debug("BlockCache::OpenFile : Size of file handle.Size %v", handle.Size)
bc.prepareHandleForBlockCache(handle)

if options.Flags&os.O_TRUNC != 0 || (options.Flags&os.O_WRONLY != 0 && options.Flags&os.O_APPEND == 0) {
if options.Flags&os.O_TRUNC != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

We shall add a UT case around this validating that truncate clears the file contents while wronly does not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added, Please review it

@jainakanksha-msft
Copy link
Collaborator

@syeleti-msft Can you please add the steps to validate this flow?

@jainakanksha-msft
Copy link
Collaborator

@syeleti-msft Also tag the related issue with this PR.

@syeleti-msft
Copy link
Member Author

@syeleti-msft Can you please add the steps to validate this flow?

Added in the description part of the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants