mirror of
https://github.com/google/leveldb.git
synced 2025-06-07 18:02:42 +08:00
Merge 93e3279233
into ac691084fd
This commit is contained in:
commit
9bdf98ea37
@ -347,7 +347,7 @@ class PosixWritableFile final : public WritableFile {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SyncFd(fd_, filename_);
|
return SyncFd(fd_, filename_, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -382,7 +382,7 @@ class PosixWritableFile final : public WritableFile {
|
|||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
status = PosixError(dirname_, errno);
|
status = PosixError(dirname_, errno);
|
||||||
} else {
|
} else {
|
||||||
status = SyncFd(fd, dirname_);
|
status = SyncFd(fd, dirname_, true);
|
||||||
::close(fd);
|
::close(fd);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
@ -394,7 +394,7 @@ class PosixWritableFile final : public WritableFile {
|
|||||||
//
|
//
|
||||||
// The path argument is only used to populate the description string in the
|
// The path argument is only used to populate the description string in the
|
||||||
// returned Status if an error occurs.
|
// returned Status if an error occurs.
|
||||||
static Status SyncFd(int fd, const std::string& fd_path) {
|
static Status SyncFd(int fd, const std::string& fd_path, bool syncing_dir) {
|
||||||
#if HAVE_FULLFSYNC
|
#if HAVE_FULLFSYNC
|
||||||
// On macOS and iOS, fsync() doesn't guarantee durability past power
|
// On macOS and iOS, fsync() doesn't guarantee durability past power
|
||||||
// failures. fcntl(F_FULLFSYNC) is required for that purpose. Some
|
// failures. fcntl(F_FULLFSYNC) is required for that purpose. Some
|
||||||
@ -414,6 +414,11 @@ class PosixWritableFile final : public WritableFile {
|
|||||||
if (sync_success) {
|
if (sync_success) {
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
// Do not crash if filesystem can't fsync directories
|
||||||
|
// (see https://github.com/bitcoin/bitcoin/pull/10000)
|
||||||
|
if (syncing_dir && errno == EINVAL) {
|
||||||
|
return Status::OK();
|
||||||
|
}
|
||||||
return PosixError(fd_path, errno);
|
return PosixError(fd_path, errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user