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

os/bluestore: fix error handling of posix_fallocate() #10277

Merged
merged 2 commits into from Jul 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -2432,7 +2432,7 @@ int BlueStore::_setup_block_symlink_or_file(
if (create)
flags |= O_CREAT;
if (epath.length()) {
if (!epath.compare(0, sizeof(SPDK_PREFIX)-1, SPDK_PREFIX)) {
if (!epath.compare(0, strlen(SPDK_PREFIX), SPDK_PREFIX)) {
r = ::symlinkat(epath.c_str(), path_fd, name.c_str());
if (r < 0) {
r = -errno;
Expand All @@ -2447,7 +2447,7 @@ int BlueStore::_setup_block_symlink_or_file(
<< cpp_strerror(r) << dendl;
return r;
}
string serial_number = epath.substr(sizeof(SPDK_PREFIX)-1);
string serial_number = epath.substr(strlen(SPDK_PREFIX));
r = ::write(fd, serial_number.c_str(), serial_number.size());
assert(r == (int)serial_number.size());
dout(1) << __func__ << " created " << name << " file with " << dendl;
Expand Down Expand Up @@ -2483,12 +2483,11 @@ int BlueStore::_setup_block_symlink_or_file(
if (g_conf->bluestore_block_preallocate_file) {
#ifdef HAVE_POSIX_FALLOCATE
r = ::posix_fallocate(fd, 0, size);
if (r < 0) {
r = -errno;
if (r) {
derr << __func__ << " failed to prefallocate " << name << " file to "
<< size << ": " << cpp_strerror(r) << dendl;
VOID_TEMP_FAILURE_RETRY(::close(fd));
return r;
return -r;
}
#else
char data[1024*128];
Expand Down