Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fsync()/fdatasync() to prevent possible data corruption #13

Closed
socketpair opened this issue Jan 10, 2018 · 9 comments
Closed

Use fsync()/fdatasync() to prevent possible data corruption #13

socketpair opened this issue Jan 10, 2018 · 9 comments
Labels

Comments

@socketpair
Copy link

No description provided.

@joachimmetz
Copy link
Member

Can you be more descriptive what possible corruption, where?

If you want things to get addressed you'll have to be more descriptive and explain what and why you want things changed.

@joachimmetz joachimmetz changed the title DATA CORRUPTION possible: You do not use fsync()/fdatasync() Use fsync()/fdatasync() to prevent possible data corruption Jan 10, 2018
@joachimmetz
Copy link
Member

Also how portable are fsync()/fdatasync()?

@socketpair
Copy link
Author

socketpair commented Jan 10, 2018

Simple scenario:

  1. write some data to qcow2 file. program complete.
  2. powerfail.
  3. power-on
  4. image is corrupted.

The same may happen during internal qcow2 data manipulation. You should understand that any incomplete write (not acknowledged by fsync() or fadasync()) may corrupt image. So, you should fdatasync() opened file descriptor at appropriate time. and maybe change data manipulation agorithms in a way that incomplete write never corrupt them.

For example, qemu-img never corrupts image structure. And if write operations in it is complete, data is really permanent.

@socketpair
Copy link
Author

fdatasync:

Conforming To
4.3BSD, POSIX.1-2001.

@socketpair
Copy link
Author

socketpair commented Jan 10, 2018

Also, we need an option to inhibit fsyncing like qemu-img's cache=unsafe. And fdatasync only at image closing. (or even never)

@joachimmetz
Copy link
Member

https://www.humboldt.co.uk/fsync-across-platforms/

write some data to qcow2 file. program complete.

Libqcow does not write images at this point in time.

@socketpair
Copy link
Author

Much better would be implementing of all caching modes of qemu - i.e. write-back, write-through, unsafe, none, directsync. Don't know if it is possible to work with qcow2 file in O_DIRECT mode, since it requires all IO to be page-aligned.

@socketpair
Copy link
Author

O! sorry, I did not know that libqcow2 is read-only. Just started to do experiments (and read really works).

@joachimmetz
Copy link
Member

Thx for the suggestion. I close this issue for now and revisit if/when write is added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants