@@ -347,7 +347,7 @@ class PosixWritableFile final : public WritableFile {
347
347
return status;
348
348
}
349
349
350
- return SyncFd (fd_, filename_);
350
+ return SyncFd (fd_, filename_, false );
351
351
}
352
352
353
353
private:
@@ -382,7 +382,7 @@ class PosixWritableFile final : public WritableFile {
382
382
if (fd < 0 ) {
383
383
status = PosixError (dirname_, errno);
384
384
} else {
385
- status = SyncFd (fd, dirname_);
385
+ status = SyncFd (fd, dirname_, true );
386
386
::close (fd);
387
387
}
388
388
return status;
@@ -394,7 +394,7 @@ class PosixWritableFile final : public WritableFile {
394
394
//
395
395
// The path argument is only used to populate the description string in the
396
396
// returned Status if an error occurs.
397
- static Status SyncFd (int fd, const std::string& fd_path) {
397
+ static Status SyncFd (int fd, const std::string& fd_path, bool syncing_dir ) {
398
398
#if HAVE_FULLFSYNC
399
399
// On macOS and iOS, fsync() doesn't guarantee durability past power
400
400
// failures. fcntl(F_FULLFSYNC) is required for that purpose. Some
@@ -414,6 +414,11 @@ class PosixWritableFile final : public WritableFile {
414
414
if (sync_success) {
415
415
return Status::OK ();
416
416
}
417
+ // Do not crash if filesystem can't fsync directories
418
+ // (see https://github.com/bitcoin/bitcoin/pull/10000)
419
+ if (syncing_dir && errno == EINVAL) {
420
+ return Status::OK ();
421
+ }
417
422
return PosixError (fd_path, errno);
418
423
}
419
424
0 commit comments