]> git.proxmox.com Git - proxmox-backup.git/commit
datastore: implement sync-level tuning for datastores
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 20 Oct 2022 07:40:56 +0000 (09:40 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 20 Oct 2022 12:59:15 +0000 (14:59 +0200)
commit647186ddf9632a56b7b2337efa9561aaf175332b
treec614f1296ea0a85e995ef2243f3c32771c7ec1c0
parent37495b8eeb5cc19abff0833fa903401375a7caac
datastore: implement sync-level tuning for datastores

currently, we don't (f)sync on chunk insertion (or at any point after
that), which can lead to broken chunks in case of e.g. an unexpected
powerloss. To fix that, offer a tuning option for datastores that
controls the level of syncs it does:

* None (default): same as current state, no (f)syncs done at any point
* Filesystem: at the end of a backup, the datastore issues
  a syncfs(2) to the filesystem of the datastore
* File: issues an fsync on each chunk as they get inserted
  (using our 'replace_file' helper) and a fsync on the directory handle

a small benchmark showed the following (times in mm:ss):
setup: virtual pbs, 4 cores, 8GiB memory, ext4 on spinner

size                none    filesystem  file
2GiB (fits in ram)   00:13   0:41        01:00
33GiB                05:21   05:31       13:45

so if the backup fits in memory, there is a large difference between all
of the modes (expected), but as soon as it exceeds the memory size,
the difference between not syncing and syncing the fs at the end becomes
much smaller.

i also tested on an nvme, but there the syncs basically made no difference

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
pbs-api-types/src/datastore.rs
pbs-datastore/src/chunk_store.rs
pbs-datastore/src/datastore.rs
src/api2/backup/environment.rs
src/api2/config/datastore.rs