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

detect logical sector size #1875

Closed

Conversation

lightmark
Copy link
Contributor

querying logical sector size from the device instead of hardcoding it for linux platform.

@facebook-github-bot
Copy link
Contributor

@lightmark updated the pull request - view changes

@facebook-github-bot
Copy link
Contributor

@lightmark updated the pull request - view changes

@facebook-github-bot
Copy link
Contributor

@lightmark updated the pull request - view changes

@facebook-github-bot
Copy link
Contributor

@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

util/io_posix.cc Outdated
return size;
}
}
#endif // namespace
Copy link
Contributor

Choose a reason for hiding this comment

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

this line doesn't end the namespace :p

@@ -684,40 +684,39 @@ class IoctlFriendlyTmpdir {
std::string dir_;
};

TEST_P(EnvPosixTestWithParam, PositionedAppend) {
if (direct_io_ && env_ == Env::Default()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks

util/io_posix.cc Outdated
std::string fname = device_dir + "/queue/logical_block_size";
FILE* fp;
char* line = nullptr;
size_t len;
Copy link
Contributor

Choose a reason for hiding this comment

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

from the man-page:

If *lineptr is set to NULL and *n is set 0 before the call, then getline() will allocate a buffer for storing the line. This buffer should be freed by the user program even if getline() failed.

I think you need to (1) initialize len to zero, (2) free "line" if it's non-nullptr on line 98.

util/io_posix.cc Outdated
size_t len;
fp = fopen(fname.c_str(), "r");
if (fp == nullptr || getline(&line, &len, fp) == -1) {
return kDefaultPageSize;
Copy link
Contributor

Choose a reason for hiding this comment

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

you also may need to close fp here

@facebook-github-bot
Copy link
Contributor

@lightmark updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@lightmark updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@lightmark updated the pull request - view changes - changes since last import

Copy link
Contributor

@ajkr ajkr left a comment

Choose a reason for hiding this comment

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

LGTM!

util/io_posix.cc Outdated
use_direct_io_(options.use_direct_reads) {
use_direct_io_(options.use_direct_reads),
logical_sector_size_(kDefaultPageSize) {
#ifdef OS_LINUX
Copy link
Contributor

Choose a reason for hiding this comment

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

consider returning kDefaultPageSize from GetLogicalBufferSize() if OS_LINUX not defined, then you don't need to set it twice everywhere

@facebook-github-bot
Copy link
Contributor

@lightmark updated the pull request - view changes - changes since last import

@facebook-github-bot
Copy link
Contributor

@lightmark has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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

Successfully merging this pull request may close these issues.

None yet

3 participants