@@ -325,7 +325,7 @@ class PosixWritableFile final : public WritableFile {
325
325
return status;
326
326
}
327
327
328
- return SyncFd (fd_, filename_);
328
+ return SyncFd (fd_, filename_, false );
329
329
}
330
330
331
331
private:
@@ -360,7 +360,7 @@ class PosixWritableFile final : public WritableFile {
360
360
if (fd < 0 ) {
361
361
status = PosixError (dirname_, errno);
362
362
} else {
363
- status = SyncFd (fd, dirname_);
363
+ status = SyncFd (fd, dirname_, true );
364
364
::close (fd);
365
365
}
366
366
return status;
@@ -372,7 +372,7 @@ class PosixWritableFile final : public WritableFile {
372
372
//
373
373
// The path argument is only used to populate the description string in the
374
374
// returned Status if an error occurs.
375
- static Status SyncFd (int fd, const std::string& fd_path) {
375
+ static Status SyncFd (int fd, const std::string& fd_path, bool syncing_dir ) {
376
376
#if HAVE_FULLFSYNC
377
377
// On macOS and iOS, fsync() doesn't guarantee durability past power
378
378
// failures. fcntl(F_FULLFSYNC) is required for that purpose. Some
@@ -392,6 +392,11 @@ class PosixWritableFile final : public WritableFile {
392
392
if (sync_success) {
393
393
return Status::OK ();
394
394
}
395
+ // Do not crash if filesystem can't fsync directories
396
+ // (see https://github.com/bitcoin/bitcoin/pull/10000)
397
+ if (syncing_dir && errno == EINVAL) {
398
+ return Status::OK ();
399
+ }
395
400
return PosixError (fd_path, errno);
396
401
}
397
402
0 commit comments