Skip to content

Commit

Permalink
Merge pull request #5529 from SUSE/wip-12586-firefly
Browse files Browse the repository at this point in the history
FileStore calls syncfs(2) even it is not supported

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
Loic Dachary committed Oct 22, 2015
2 parents eaf7dc3 + d0d6727 commit 07e90f5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
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

0 comments on commit 07e90f5

Please sign in to comment.