Questions tagged [fsync]

The fsync system call causes all modified data and attributes associated to a given file descriptor to be moved to a permanent storage device.

The fsync system call causes all modified data and attributes associated to a given file descriptor to be moved to a permanent storage device.

http://www.freebsd.org/cgi/man.cgi?query=fsync&sektion=2

101 questions
2
votes
1 answer

Does fsync of a parent directory guarantee synchronization of meta data of all recursive sub directories?

Currently I am writing an Android application which needs to work with lot of files at native side. Recently I ran into several data loss or inconsistency problems while updating or renaming these files. (All these files are stored within several…
sdare
  • 237
  • 1
  • 2
  • 9
2
votes
1 answer

any reason to call fsync before a call to fstat

I have a piece of legacy code that issues a call to fsync before a call to fstat to determine the filesize of the target file. (specifically the code is only accessing st_size out of the stat struct.) Having looked at the docs, I don't believe this…
Pablitorun
  • 1,035
  • 1
  • 8
  • 18
1
vote
2 answers

Does msync sync all files on the filesystem to the disk like fsync on ext3?

as far as I know, on most ext3 system with log mode "data=ordered", fsync will not only sync the file specified with the fd, but will sync all files on the filesystem, and this problem has not been fixed before kernel 2.6.30 And I got a question,…
SSolid
  • 135
  • 1
  • 3
  • 11
1
vote
0 answers

libaio and syncing file output

I've asked a similar question to this previously, but the comments I got make me think I didn't express myself well or something, so I deleted it and will try again. I have C code that is using libaio asynchronous I/O threads to write to a file. …
bob.sacamento
  • 6,283
  • 10
  • 56
  • 115
1
vote
1 answer

What do fsync() do when open() with O_DIRECT in ext4

I know XFS does not sync metadata even though the file being written is open with O_DIRECT and the metadata of the file is changed. But for ext4, I notice that MySQL support O_DIRECT_NO_FSYNC which means MySQL does not call fsync() and lets the…
Tim He
  • 350
  • 2
  • 13
1
vote
1 answer

What is the difference between `O_DIRECT | O_SYNC` + write() and `O_DIRECT` + write() + fsync()

I want to know the difference between char *text = (char *)malloc(4096); memset(text, 'a', 4096); int fd = open(filepath, O_RDWR | O_CREAT | O_DIRECT); for(int i=0; i<1000; i++) { write(fd, (void *)text, 4096); …
Tim He
  • 350
  • 2
  • 13
1
vote
0 answers

Do Kafka consumers receive messages that have already been flushed (fsynched) to disk?

I have read an outdated pdf on Kafka that states that consumers will receive messages that have already been committed to durable storage (disk). However more recent search results do not clearly state such a specification. Can anyone please confirm…
1
vote
1 answer

node fs.fsync (when to use?)

I want to safely write a file and I wan't to understand the proper use/place for fsync. https://linux.die.net/man/2/fsync After reading ^ that, I am puzzled as to where to effectively use it. Question, do…
Ben Muircroft
  • 2,936
  • 8
  • 39
  • 66
1
vote
1 answer

Do we need to fsync the parent directory in UBIFS for atomic *and* durable file updates

Here's the typical and well-known approach for atomic file updates: fd = open(“foo.new”, O_WRONLY); write(fd, buf, bufsize); fsync(fd); close(fd); rename(“foo.new”, “foo”); In general, if we also want durability (i.e. a guarantee that the new…
Grodriguez
  • 21,501
  • 10
  • 63
  • 107
1
vote
0 answers

How do I fix git fsync errors when checking out code on mapped network drives

I have a Jenkins job that checks out git code to a mapped network file share so that multiple executors can work on and test code in parallel. I would estimate that a good 90% of the time everything is wonderful and works and then seemingly out of…
Slushba132
  • 423
  • 2
  • 5
  • 20
1
vote
0 answers

Why does redis 3.2 refuse to create a background fsync?

Here is the code snippet in the end of flushAppendOnlyFile function in aof.c, which writes aof buffer on disk. /* Perform the fsync if needed. */ if (server.aof_fsync == AOF_FSYNC_ALWAYS) { server.aof_last_fsync = server.unixtime; } else if…
lorneli
  • 252
  • 3
  • 11
1
vote
2 answers

Do I need to close a file before calling syncfs()

On my embedded system, I want to make sure that the data is safely written when I close a file - if the system reports that the data was saved, the user should be able to remove power immediately. I know that the proper way to do this is fsync(),…
Arnout
  • 2,927
  • 16
  • 24
1
vote
1 answer

PostgreSQL 9: could not fsync file "base/16386": Invalid argument

I'm trying to test a small PostgreSQL setup, so I cobbled together a quick local install. However, when I'm trying to create my personal db with createdb, it chokes on errors like this (notably, it starts with base/16384 the first time, and…
user508633
  • 406
  • 3
  • 13
1
vote
1 answer

How to prevent data loss when closing a file descriptor?

When I issue write(), my data goes to some kernel space buffers. The actual commit to physical layer ("phy-commit") is (likely) deferred, until.. (exactly until what events?) When I issue a close() for a file descriptor, then If [...], the…
user7076126
1
vote
0 answers

Replacing multiple fdatasync() calls with a single sync() call

I have an application with thousands of files being updated. Periodically the application needs to commit the changes to the disk, and currently I am calling fdatasync(), which takes significant amount of time (minutes). [Reducing the number of…
Alexey
  • 406
  • 3
  • 6