Merge pull request #3305 from majianpeng/fix5

fix bugs about sync_filesystem

Reviewed-by: Samuel Just <sjust@redhat.com>
Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Samuel Just 2015-01-13 10:53:34 -08:00
commit c82f8177f7
3 changed files with 25 additions and 8 deletions

View File

@ -34,17 +34,18 @@ inline int sync_filesystem(int fd)
#ifdef HAVE_SYS_SYNCFS
if (syncfs(fd) == 0)
return 0;
else
return -errno;
#elif defined(SYS_syncfs)
if (syscall(SYS_syncfs, fd) == 0)
return 0;
else
return -errno;
#elif defined(__NR_syncfs)
if (syscall(__NR_syncfs, fd) == 0)
return 0;
#endif
#ifdef BTRFS_IOC_SYNC
if (::ioctl(fd, BTRFS_IOC_SYNC) == 0)
return 0;
else
return -errno;
#endif
sync();

View File

@ -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);
@ -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);
}

View File

@ -2005,7 +2005,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));