You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.5 KiB

  1. # Recommendations and Warnings
  2. ## What should mergerfs NOT be used for?
  3. - databases: Even if the database stored data in separate files
  4. (mergerfs wouldn't offer much otherwise) the higher latency of the
  5. indirection will really harm performance. If it is a lightly used
  6. sqlite3 database then it should be fine.
  7. - VM images: For the same reasons as databases. VM images are accessed
  8. very aggressively and mergerfs will introduce a lot of extra latency.
  9. - As replacement for RAID: mergerfs is just for pooling branches. If
  10. you need that kind of device performance aggregation or high
  11. availability you should stick with RAID. However, it is fine to put
  12. a filesystem which is on a RAID setup in mergerfs.
  13. ## It's mentioned that there are some security issues with mhddfs. What are they? How does mergerfs address them?
  14. [mhddfs](https://github.com/trapexit/mhddfs) manages running as
  15. `root` by calling
  16. [getuid()](https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
  17. and if it returns `0` then it will
  18. [chown](http://linux.die.net/man/1/chown) the file. Not only is that a
  19. race condition but it doesn't handle other situations. Rather than
  20. attempting to simulate POSIX ACL behavior the proper way to manage
  21. this is to use [seteuid](http://linux.die.net/man/2/seteuid) and
  22. [setegid](http://linux.die.net/man/2/setegid), in effect, becoming the
  23. user making the original call, and perform the action as them. This is
  24. what mergerfs does and why mergerfs should always run as root.
  25. In Linux setreuid syscalls apply only to the thread. glibc hides this
  26. away by using realtime signals to inform all threads to change
  27. credentials. Taking after Samba, mergerfs uses
  28. `syscall(SYS_setreuid,...)` to set the callers credentials for that
  29. thread only. Jumping back to `root` as necessary should escalated
  30. privileges be needed (for instance: to clone paths between
  31. filesystems).
  32. For non-Linux systems, mergerfs uses a read-write lock and changes
  33. credentials only when necessary. If multiple threads are to be user X
  34. then only the first one will need to change the processes
  35. credentials. So long as the other threads need to be user X they will
  36. take a readlock allowing multiple threads to share the
  37. credentials. Once a request comes in to run as user Y that thread will
  38. attempt a write lock and change to Y's credentials when it can. If the
  39. ability to give writers priority is supported then that flag will be
  40. used so threads trying to change credentials don't starve. This isn't
  41. the best solution but should work reasonably well assuming there are
  42. few users.