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

zvol for swap and sync=? #229

Open
HRio opened this issue Mar 13, 2019 · 5 comments
Open

zvol for swap and sync=? #229

HRio opened this issue Mar 13, 2019 · 5 comments

Comments

@HRio
Copy link

HRio commented Mar 13, 2019

Looking in:
https://github.com/zfsonlinux/pkg-zfs/wiki/HOWTO-use-a-zvol-as-a-swap-device
I see

zfs create -V 4G -b $(getconf PAGESIZE) -o compression=zle \
      -o logbias=throughput -o sync=always \
      -o primarycache=metadata -o secondarycache=none \
      -o com.sun:auto-snapshot=false rpool/swap

why sync=always? if the system crashes all RAM will be lost. hence writing swap synchronously seems a bit too much.

sync=always
  For the ultra-cautious, every file system transaction is
  written and flushed to stable storage by a system call return.
  This obviously has a big performance penalty.

FreeBSD docs for reference:
https://wiki.freebsd.org/RootOnZFS#ZFS_Swap_Volume

zfs create -V 2G -o org.freebsd:swap=on -o checksum=off -o compression=off -o dedup=off -o sync=disabled -o primarycache=none zroot/swap

Why should it be sync=always when using zfs on linux, or is it a typo?

@Temtaime
Copy link

Temtaime commented Dec 5, 2019

Ping. Any response?

@HRio
Copy link
Author

HRio commented Jun 29, 2020

sync-always will just add latency, whats the need for it? I feel it will only add to the problems when we are in a state where we need to swap

@RSully
Copy link

RSully commented Jun 29, 2020

My guess: I assume the reasoning here is that if we are under a condition of extreme memory pressure (e.g. swapping is required) then it doesn't make sense to use more memory to buffer these writes which would compound the problem

@HRio
Copy link
Author

HRio commented Jun 29, 2020

sync=always means that the data first i written to the ZIL and then after that to the final media. Its in memory also when the write to the ZIL is done. Its not free'd from the memory until both the zil write and the write to final storage is fully ready. I.e. sync always in this case only ads to the time before we can free the memory

@yennor
Copy link

yennor commented Jun 20, 2022

Actually I've also just stumpled over that. I've wanted to checkout what are recommended settings for swap devices, and noticed, that everybody recommends sync=always (but their commands look al the same, so I guess they've all copied from the same place). Could anybody with more insight tell if there is any reason why sync=always should be used than sync=disabled (Which seems to be the logical choice for me)

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

No branches or pull requests

4 participants