-
Notifications
You must be signed in to change notification settings - Fork 37
issue-1751: Make behavior for read/write requests with O_DIRECT consistent with Linux behavior for write-back cache #4723
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| struct TReadRequest | ||
| : public TRequestBase<fuse_read_in, ui32, ui32> | ||
| : public TRequestBase<fuse_read_in, void, ui32> |
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.
Странно, но этот код вообще нигде не тестировался.
Операция FUSE_READ не возвращает число прочитанных байт, а сразу содержит буфер переменного размера.
https://github.com/libfuse/libfuse/blob/ab5033f5d1bd1630870dc725eb3eae6ef3ef4859/doc/libfuse-operations.txt#L115
|
|
||
| TFuture<NProto::TReadDataResponse> future; | ||
| if (WriteBackCache) { | ||
| if (useWriteBackCache) { |
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.
shouldUseServerWriteBackCache or ShouldUseServerWriteBackCache(fi) in place
|
|
||
| bootstrap.Service->ReadDataHandler = [&] (auto, auto) { | ||
| NProto::TReadDataResponse result; | ||
| *result.MutableBuffer() = TString("direct_data"); |
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.
suggest to use as in other places "result.MutableBuffer()->assign", just for consistency
|
|
||
| { | ||
| // write request without O_DIRECT should go to write-back cache | ||
| auto reqWrite = std::make_shared<TWriteRequest>( |
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 we add counter to writedatahandler and check it explicitly in test?
| reinterpret_cast<const char*>(reqRead->Out->Data()), | ||
| rspRead.GetValue()); | ||
|
|
||
| UNIT_ASSERT_VALUES_EQUAL("cached_data", readData); |
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.
check counter in handler? blow as well
#1751
Linux behavior
https://github.com/torvalds/linux/blob/30f09200cc4aefbd8385b01e41bde2e4565a6f0e/mm/filemap.c#L2907
https://github.com/torvalds/linux/blob/30f09200cc4aefbd8385b01e41bde2e4565a6f0e/mm/filemap.c#L4181
Note: O_DIRECT flag is a non-POSIX feature so we should follow Linux behavior.
Current behavior in filestore
Proposed behavior
Add new state for
WriteDataEntry—PendingDirect, indicating that the request hasO_DIRECTflag and cannot become cached. These requests share the same pending queue with non-direct requests. Queue rules make processing direct and non-direct requests mutually exclusive:Note: cache invalidation is not an acceptable option here as it may result in data corruption.
For ReadData requests — the same logic as for write requests:
Additional: presence of direct requests in the pending queue trigger Flush immediately for the node.