-
Notifications
You must be signed in to change notification settings - Fork 211
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
base: blobfuse/2.4.1
Are you sure you want to change the base?
Conversation
…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.
@@ -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 { |
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.
We shall add a UT case around this validating that truncate clears the file contents while wronly does not.
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.
Added, Please review it
@syeleti-msft Can you please add the steps to validate this flow? |
@syeleti-msft Also tag the related issue with this PR. |
7e2b180
to
3c5317e
Compare
Added in the description part of the PR |
✅ 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.