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
3
votes
3 answers

How do I ensure data is written to the physical media?

I have a program that is called by a script. This program writes a lot of data to a file on the disk and then terminates. As soon as it is done running, the script kills power to the entire system. The problem I am having is that the file does not…
J. Doe
  • 127
  • 9
3
votes
1 answer

fsync() atomicity across data blocks

When calling fsync() on a file, can the file become corrupted? For example, say my file spreads across to disk blocks: A B |---------| |--------| | Hello, | -> | World! | |---------| |--------| | 1234567 | | 89abcd…
magnus
  • 4,031
  • 7
  • 26
  • 48
3
votes
0 answers

How docker treats fsync on guest filesystem? Is it possible to lost data during host system crash?

Consider the following scenario: We work with DBMS inside docker container; DBMS writes WAL or REDO log, and calls fsync on transaction commits; fsync instructs guest OS to flush 'dirty' IO buffers to disk; Data stays in IO buffer on host OS; Host…
3
votes
1 answer

python fsync() on network drive hangs

I write some data to a file using the following function: def WriteTo1File(self, output_file, text): output_file.write(text) output_file.flush() os.fsync(output_file.fileno()) The fsync() call is mandatory to handle IOError: if I don't…
Mickael_86130
  • 183
  • 1
  • 1
  • 8
3
votes
1 answer

Is pg_test_fsync contrib module in postgresql 9.2 deprecated?

I have installed postgresql 9.2.4 on my machine with Ubuntu 12.04.1 LTS. Based on this documentation page (http://www.postgresql.org/docs/9.2/static/pgtestfsync.html), it seems *pg_test_fsync* contrib module is part of postgresql 9.2.4 . But when I…
invinc4u
  • 1,125
  • 3
  • 15
  • 26
2
votes
1 answer

What will be if I use libaio + fsync()?

I know that when I write files using write() + fsync() (or O_SYNC + write(), I think they are same ref #1 ref #2), it means I am using blocking synchronous I/O, and the if the write()(with O_SYNC) or fsync() returns, it means the data is safely on…
Tim He
  • 350
  • 2
  • 13
2
votes
1 answer

C++: How to correctly actualize a file against power loss?

I have a linux embedded environment. Here I have 2 scenarios: A: Open and write a temporary file. Rename temporary file to the original file. Power loss Result: After reboot, what I have is: 0-size original file and there is no temporary…
Mert Mertce
  • 1,049
  • 7
  • 34
2
votes
1 answer

Does fsync/FlushFileBuffers wait for outstanding asynchronous IOs to finish?

The background is developing DBMS kernel, specifically database checkpoint processing. Rules of the game are such that we need to wait for outstanding asynchronous IOs on the file to finish, before issuing fsync(). Current solution we deploy, is to…
Vladislav Vaintroub
  • 5,308
  • 25
  • 31
2
votes
1 answer

Linux API: is it possible to specify `O_SYNC` option for a single `write` syscall

Such flags as O_DIRECT, O_SYNC, O_DSYNC can be used to specify synchronous / asynchronous IO at the time when descriptor is created (create syscall). But is it possible to use this flags for distinct write (or similar) syscalls in order to make some…
Vitaly Isaev
  • 5,392
  • 6
  • 45
  • 64
2
votes
1 answer

Risks of changing flushes frequency

Through iostat I could find spikes in disk writes once per minute. I think these spikes are caused by fsync, since MongoDB by default flush data to disk every 60 seconds. I could also find out that coinciding with the spikes slow queries are…
Antonio Val
  • 3,200
  • 1
  • 14
  • 27
2
votes
3 answers

how to (f)sync a directory under linux in c

I've some c application under linux. I'm renaming some files with rename(...) How can I ensure that the renaming is written persistent to the underlaying disk? With a file I can do something like: FILE * f =…
powerpete
  • 2,663
  • 2
  • 23
  • 49
2
votes
0 answers

How to get file descriptor from ofstream

I need to call fsync() to secure my data. Can you please help me to get file descriptor from ofstream. string tmpconfig("config.tmp"); ofstream tcfg(tmpconfig.c_str()); if(tcfg) { tcfgNV.compactPrint(tcfg); tcfg.flush(); if(!tcfg.good()) { …
2
votes
1 answer

fflush or sync need after boost::filesystem::copy?

I have a problem when using boot library for copying files. After copying a file, sometimes the file size if 0kb. Here is my code: boost::filesystem::copy("from.txt", "to.txt"); I just want to know whether should I call sync(), fsync(), or …
2
votes
2 answers

Possible to implement journaling with a single fsync per commit?

Let's say you're building a journaling/write-ahead-logging storage system. Can you simply implement this by (for each transaction) appending the data (with write(2)), appending a commit marker, and then fsync-ing? The scenario to consider is if you…
Yang
  • 16,037
  • 15
  • 100
  • 142
2
votes
1 answer

Has Boost something to the effect of fsync()?

Does the Boost library provide something similar to fsync()? Motivation: to be portable beyond POSIX - e.g. such that on Windows a similar function is used.
maxschlepzig
  • 35,645
  • 14
  • 145
  • 182