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

common: FileStore calls syncfs(2) even it is not supported #5529

Merged
5 commits merged into from Oct 22, 2015
Merged
Show file tree
Hide file tree
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
12 changes: 8 additions & 4 deletions src/common/sync_filesystem.h
Expand Up @@ -42,13 +42,17 @@ inline int sync_filesystem(int fd)
return 0;
#endif

#ifdef BTRFS_IOC_SYNC
if (::ioctl(fd, BTRFS_IOC_SYNC) == 0)
#if defined(HAVE_SYS_SYNCFS) || defined(SYS_syncfs) || defined(__NR_syncfs)
else if (errno == ENOSYS) {
sync();
return 0;
#endif

} else {
return -errno;
}
#else
sync();
return 0;
#endif
}

#endif
16 changes: 14 additions & 2 deletions src/mon/MonitorStore.cc
Expand Up @@ -437,7 +437,13 @@ void MonitorStore::put_bl_sn_map(const char *a,
derr << "failed to open " << dir << ": " << cpp_strerror(err) << dendl;
assert(0 == "failed to open temp file");
}
sync_filesystem(dirfd);

err = sync_filesystem(dirfd);
if (err < 0) {
derr << "sync_filesystem error " << cpp_strerror(err) << dendl;
assert(0 == "failed to sync_filesystem");
}

close_err = TEMP_FAILURE_RETRY(::close(dirfd));
assert (0 == close_err);

Expand Down Expand Up @@ -481,7 +487,13 @@ void MonitorStore::sync()
<< ": " << cpp_strerror(err) << dendl;
assert(0 == "failed to open dir for syncing");
}
sync_filesystem(dirfd);

int ret = sync_filesystem(dirfd);
if (ret < 0) {
derr << __func__ << " sync_filesystem error " << cpp_strerror(ret) << dendl;
assert(0 == "failed to sync_filesystem");
}

int close_err = TEMP_FAILURE_RETRY(::close(dirfd));
assert (0 == close_err);
}
6 changes: 5 additions & 1 deletion src/os/FileStore.cc
Expand Up @@ -1901,7 +1901,11 @@ void FileStore::_set_global_replay_guard(coll_t cid,
return;

// sync all previous operations on this sequencer
sync_filesystem(basedir_fd);
int ret = sync_filesystem(basedir_fd);
if (ret < 0) {
derr << __func__ << " :sync_filesytem error " << cpp_strerror(ret) << dendl;
assert(0 == "_set_global_replay_guard failed");
}

char fn[PATH_MAX];
get_cdir(cid, fn, sizeof(fn));
Expand Down