News for hackers. Stuff that matters.
Re:Asynchronous filesystem replication with FUSE and rsync by 0x0 on Thursday December 11, 2014 @09:18AM (#8734784)
Wouldn't the inotify API be a better way to detect file writes rather than writing a full FUSE wrapper?
Re:Asynchronous filesystem replication with FUSE and rsync by Lethalman on Thursday December 11, 2014 @09:34AM (#8734885)
Yes, we've thought a lot about using inotify, our first prototype was also using inotify.

- Our system needs to cope with millions of directories. Millions of directories for inotify mean a lot of structures in the kernel. For large numbers it can also mean gigabytes of ram. Add to that the mapping in userspace of file descriptors for rename operations.

- Using inotify would take a lot of time at startup to recurse into millions of subdirectories.

- inotify will not automatically watch new directories. You have to list all the files right after the creation of a directory and watch the subdirectories, etc. Not a problem at all, but way simpler with FUSE.

- If your system is not able to keep up with inotify events, you miss events because the kernel cannot buffer all the events. For us it's better to slow down the system but never miss an event.

- inotify is attached to the original filesystem. That means it's hard (not impossible) to handle loops in an active/active replication setup. Whereas with SFS, replication is done on straight to the original filesystem.

- If the inotify application crashes, you lose events because software keeps writing to the filesystem. If SFS crashes the mountpoint is unwritable by the application which reports an error and can switch to a different storage.

Some choices as you can read depends on the requirements, our requirements where not met by inotify.

Re:Asynchronous filesystem replication with FUSE and rsync by rwmj on Thursday December 11, 2014 @10:09AM (#8735097)
There's a new thing (fanotify). LWN did a short series on different filesystem notification methods in July:

https://lwn.net/Articles/604686/

https://lwn.net/Articles/605128/

Unfortunately the fanotify article is yet to come!

(Having said that, I certainly appreciate your pain trying to use inotify to track write events on an entire filesystem)

Re:Asynchronous filesystem replication with FUSE and rsync by mopo2000 on Thursday December 11, 2014 @02:38PM (#8736645)
fanotify is super limited, and not useful for this app. It's from 2009, but has seen little use.
Re:Asynchronous filesystem replication with FUSE and rsync by dezgeg on Thursday December 11, 2014 @09:20AM (#8734795)
AFAIK inotify isn't especially great for recursively watching a large directory.
Re:Asynchronous filesystem replication with FUSE and rsync by 0x0 on Thursday December 11, 2014 @09:22AM (#8734818)
Interesting, I haven't looked at the details and assumed it was similar to the osx FSEvents API. Maybe Linux has some catching up to do in this area?
Re:Asynchronous filesystem replication with FUSE and rsync by vidarh on Thursday December 11, 2014 @10:03AM (#8735060)
We've done that as a workaround for old legacy web apps where nobody had originally thought about failover (and had spread data updates all over the filesystem, intermingled with code... It was not fun to untangle).It works, but we've always supplemented it with regular full filesystem rsync's.

Our cases have also had very limited semantics (uploads that adds new files or modify files, but no deletions ever) that made things easier.

This seems a lot cleaner...

Though these days we mostly use glusterfs and most of those old apps have thankfully been retired or cleaned up.

Re:Asynchronous filesystem replication with FUSE and rsync by Lethalman on Thursday December 11, 2014 @10:16AM (#8735146)
Glusterfs is for synchronous replication. Glusterfs asynchronous replication, at the time of writing SFS, only supported master-slave.
Re:Asynchronous filesystem replication with FUSE and rsync by vidarh on Thursday December 11, 2014 @06:44PM (#8737718)
Yes, the point with bringing up gluster is that synchronous replication is the best solution for our use case (we have relatively low amount of filesystem writes, but need the files to be consistently replicated near-instantly).

But for applications where async is a good fit, your solution does definitively seem much nicer than the inotify + rsync stuff we were doing (we ended up with that - temporary - solution after writing off lsyncd, though I don't remember why).