zfsonlinux / zfs-auto-snapshot

ZFS Automatic Snapshot Service for Linux
GNU General Public License v2.0
858 stars 244 forks source link

Possibility to use fanotify to trigger snapshots #73

Open Harvie opened 7 years ago

Harvie commented 7 years ago

NILFS2 is filesystem that by design creates snapshot after any data change, so it can be easily rolled back to any time without specificaly making snapshots at that time using cron... Is it possible to mimick such feature using inotify to watch file changes and make snapshots accordingly? Maybe not for every inotify event, but at least for some.

linsomniac commented 5 years ago

I haven't done much research lately, but many years ago I was looking at inotify and found that you have to have a watch on every directory in the filesystem to get all change events. For a big file-system, this may be problematic. It probably would be ok for smaller filesystems.

I wonder if there's another mechanism that would be better? Like dtrace, or is there some way to see if the ZFS master block has been updated? Or maybe take regular snapshots, but then go through and preen the older ones that have a "USED" size of 0 (which I think means it contains no deltas, so no written data).

Harvie commented 5 years ago

I was looking at inotify and found that you have to have a watch on every directory in the filesystem to get all change events.

I've recently saw there is some newer API, which solves this problem, but some features were not implemented yet... but i don't remember the name...

update: it's called fanotify (not to be confused with even older dnotify)

https://www.phoronix.com/scan.php?page=news_item&px=Linux-5.1-Fanotify-Improvements