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.

2038 lines
78 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
9 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
9 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
8 years ago
8 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
  1. .\"t
  2. .\" Automatically generated by Pandoc 1.19.2.4
  3. .\"
  4. .TH "mergerfs" "1" "2019\-05\-03" "mergerfs user manual" ""
  5. .hy
  6. .SH NAME
  7. .PP
  8. mergerfs \- a featureful union filesystem
  9. .SH SYNOPSIS
  10. .PP
  11. mergerfs \-o<options> <branches> <mountpoint>
  12. .SH DESCRIPTION
  13. .PP
  14. \f[B]mergerfs\f[] is a union filesystem geared towards simplifying
  15. storage and management of files across numerous commodity storage
  16. devices.
  17. It is similar to \f[B]mhddfs\f[], \f[B]unionfs\f[], and \f[B]aufs\f[].
  18. .SH FEATURES
  19. .IP \[bu] 2
  20. Runs in userspace (FUSE)
  21. .IP \[bu] 2
  22. Configurable behaviors / file placement
  23. .IP \[bu] 2
  24. Support for extended attributes (xattrs)
  25. .IP \[bu] 2
  26. Support for file attributes (chattr)
  27. .IP \[bu] 2
  28. Runtime configurable (via xattrs)
  29. .IP \[bu] 2
  30. Safe to run as root
  31. .IP \[bu] 2
  32. Opportunistic credential caching
  33. .IP \[bu] 2
  34. Works with heterogeneous filesystem types
  35. .IP \[bu] 2
  36. Handling of writes to full drives (transparently move file to drive with
  37. capacity)
  38. .IP \[bu] 2
  39. Handles pool of read\-only and read/write drives
  40. .IP \[bu] 2
  41. Can turn read\-only files into symlinks to underlying file
  42. .IP \[bu] 2
  43. Hard link copy\-on\-write / CoW
  44. .SH How it works
  45. .PP
  46. mergerfs logically merges multiple paths together.
  47. Think a union of sets.
  48. The file/s or directory/s acted on or presented through mergerfs are
  49. based on the policy chosen for that particular action.
  50. Read more about policies below.
  51. .IP
  52. .nf
  53. \f[C]
  54. A\ \ \ \ \ \ \ \ \ +\ \ \ \ \ \ B\ \ \ \ \ \ \ \ =\ \ \ \ \ \ \ C
  55. /disk1\ \ \ \ \ \ \ \ \ \ \ /disk2\ \ \ \ \ \ \ \ \ \ \ /merged
  56. |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |
  57. +\-\-\ /dir1\ \ \ \ \ \ \ \ +\-\-\ /dir1\ \ \ \ \ \ \ \ +\-\-\ /dir1
  58. |\ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ |
  59. |\ \ \ +\-\-\ file1\ \ \ \ |\ \ \ +\-\-\ file2\ \ \ \ |\ \ \ +\-\-\ file1
  60. |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file3\ \ \ \ |\ \ \ +\-\-\ file2
  61. +\-\-\ /dir2\ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file3
  62. |\ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ /dir3\ \ \ \ \ \ \ \ |
  63. |\ \ \ +\-\-\ file4\ \ \ \ \ \ \ \ |\ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ /dir2
  64. |\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ file5\ \ \ |\ \ \ |
  65. +\-\-\ file6\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file4
  66. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |
  67. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ /dir3
  68. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ |
  69. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |\ \ \ +\-\-\ file5
  70. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ |
  71. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ +\-\-\ file6
  72. \f[]
  73. .fi
  74. .PP
  75. mergerfs does \f[B]not\f[] support the copy\-on\-write (CoW) behavior
  76. found in \f[B]aufs\f[] and \f[B]overlayfs\f[].
  77. You can \f[B]not\f[] mount a read\-only filesystem and write to it.
  78. However, mergerfs will ignore read\-only drives when creating new files
  79. so you can mix read\-write and read\-only drives.
  80. .SH OPTIONS
  81. .SS mount options
  82. .IP \[bu] 2
  83. \f[B]allow_other\f[]: a libfuse option which allows users besides the
  84. one which ran mergerfs to see the filesystem.
  85. This is required for most use\-cases.
  86. .IP \[bu] 2
  87. \f[B]direct_io\f[]: causes FUSE to bypass caching which can increase
  88. write speeds at the detriment of reads.
  89. Note that not enabling \f[C]direct_io\f[] will cause double caching of
  90. files and therefore less memory for caching generally (enable
  91. \f[B]dropcacheonclose\f[] to help with this problem).
  92. However, \f[C]mmap\f[] does not work when \f[C]direct_io\f[] is enabled.
  93. .IP \[bu] 2
  94. \f[B]minfreespace=value\f[]: the minimum space value used for creation
  95. policies.
  96. Understands \[aq]K\[aq], \[aq]M\[aq], and \[aq]G\[aq] to represent
  97. kilobyte, megabyte, and gigabyte respectively.
  98. (default: 4G)
  99. .IP \[bu] 2
  100. \f[B]moveonenospc=true|false\f[]: when enabled (set to \f[B]true\f[]) if
  101. a \f[B]write\f[] fails with \f[B]ENOSPC\f[] or \f[B]EDQUOT\f[] a scan of
  102. all drives will be done looking for the drive with the most free space
  103. which is at least the size of the file plus the amount which failed to
  104. write.
  105. An attempt to move the file to that drive will occur (keeping all
  106. metadata possible) and if successful the original is unlinked and the
  107. write retried.
  108. (default: false)
  109. .IP \[bu] 2
  110. \f[B]use_ino\f[]: causes mergerfs to supply file/directory inodes rather
  111. than libfuse.
  112. While not a default it is recommended it be enabled so that linked files
  113. share the same inode value.
  114. .IP \[bu] 2
  115. \f[B]dropcacheonclose=true|false\f[]: when a file is requested to be
  116. closed call \f[C]posix_fadvise\f[] on it first to instruct the kernel
  117. that we no longer need the data and it can drop its cache.
  118. Recommended when \f[B]direct_io\f[] is not enabled to limit double
  119. caching.
  120. (default: false)
  121. .IP \[bu] 2
  122. \f[B]symlinkify=true|false\f[]: when enabled (set to \f[B]true\f[]) and
  123. a file is not writable and its mtime or ctime is older than
  124. \f[B]symlinkify_timeout\f[] files will be reported as symlinks to the
  125. original files.
  126. Please read more below before using.
  127. (default: false)
  128. .IP \[bu] 2
  129. \f[B]symlinkify_timeout=value\f[]: time to wait, in seconds, to activate
  130. the \f[B]symlinkify\f[] behavior.
  131. (default: 3600)
  132. .IP \[bu] 2
  133. \f[B]nullrw=true|false\f[]: turns reads and writes into no\-ops.
  134. The request will succeed but do nothing.
  135. Useful for benchmarking mergerfs.
  136. (default: false)
  137. .IP \[bu] 2
  138. \f[B]ignorepponrename=true|false\f[]: ignore path preserving on rename.
  139. Typically rename and link act differently depending on the policy of
  140. \f[C]create\f[] (read below).
  141. Enabling this will cause rename and link to always use the non\-path
  142. preserving behavior.
  143. This means files, when renamed or linked, will stay on the same drive.
  144. (default: false)
  145. .IP \[bu] 2
  146. \f[B]security_capability=true|false\f[]: If false return ENOATTR when
  147. xattr security.capability is queried.
  148. (default: true)
  149. .IP \[bu] 2
  150. \f[B]xattr=passthrough|noattr|nosys\f[]: Runtime control of xattrs.
  151. Default is to passthrough xattr requests.
  152. \[aq]noattr\[aq] will short circuit as if nothing exists.
  153. \[aq]nosys\[aq] will respond with ENOSYS as if xattrs are not supported
  154. or disabled.
  155. (default: passthrough)
  156. .IP \[bu] 2
  157. \f[B]link_cow=true|false\f[]: When enabled if a regular file is opened
  158. which has a link count > 1 it will copy the file to a temporary file and
  159. rename over the original.
  160. Breaking the link and providing a basic copy\-on\-write function similar
  161. to cow\-shell.
  162. (default: false)
  163. .IP \[bu] 2
  164. \f[B]statfs=base|full\f[]: Controls how statfs works.
  165. \[aq]base\[aq] means it will always use all branches in statfs
  166. calculations.
  167. \[aq]full\[aq] is in effect path preserving and only includes drives
  168. where the path exists.
  169. (default: base)
  170. .IP \[bu] 2
  171. \f[B]statfs_ignore=none|ro|nc\f[]: \[aq]ro\[aq] will cause statfs
  172. calculations to ignore available space for branches mounted or tagged as
  173. \[aq]read\-only\[aq] or \[aq]no create\[aq].
  174. \[aq]nc\[aq] will ignore available space for branches tagged as \[aq]no
  175. create\[aq].
  176. (default: none)
  177. .IP \[bu] 2
  178. \f[B]threads=num\f[]: number of threads to use in multithreaded mode.
  179. When set to zero (the default) it will attempt to discover and use the
  180. number of logical cores.
  181. If the lookup fails it will fall back to using 4.
  182. If the thread count is set negative it will look up the number of cores
  183. then divide by the absolute value.
  184. ie.
  185. threads=\-2 on an 8 core machine will result in 8 / 2 = 4 threads.
  186. There will always be at least 1 thread.
  187. NOTE: higher number of threads increases parallelism but usually
  188. decreases throughput.
  189. (default: number of cores) \f[I]NOTE2:\f[] the option is unavailable
  190. when built with system libfuse.
  191. .IP \[bu] 2
  192. \f[B]fsname=name\f[]: sets the name of the filesystem as seen in
  193. \f[B]mount\f[], \f[B]df\f[], etc.
  194. Defaults to a list of the source paths concatenated together with the
  195. longest common prefix removed.
  196. .IP \[bu] 2
  197. \f[B]func.<func>=<policy>\f[]: sets the specific FUSE function\[aq]s
  198. policy.
  199. See below for the list of value types.
  200. Example: \f[B]func.getattr=newest\f[]
  201. .IP \[bu] 2
  202. \f[B]category.<category>=<policy>\f[]: Sets policy of all FUSE functions
  203. in the provided category.
  204. Example: \f[B]category.create=mfs\f[]
  205. .IP \[bu] 2
  206. \f[B]cache.open=<int>\f[]: \[aq]open\[aq] policy cache timeout in
  207. seconds.
  208. (default: 0)
  209. .IP \[bu] 2
  210. \f[B]cache.statfs=<int>\f[]: \[aq]statfs\[aq] cache timeout in seconds.
  211. (default: 0)
  212. .IP \[bu] 2
  213. \f[B]cache.attr=<int>\f[]: file attribute cache timeout in seconds.
  214. (default: 1)
  215. .IP \[bu] 2
  216. \f[B]cache.entry=<int>\f[]: file name lookup cache timeout in seconds.
  217. (default: 1)
  218. .IP \[bu] 2
  219. \f[B]cache.negative_entry=<int>\f[]: negative file name lookup cache
  220. timeout in seconds.
  221. (default: 0)
  222. .PP
  223. \f[B]NOTE:\f[] Options are evaluated in the order listed so if the
  224. options are \f[B]func.rmdir=rand,category.action=ff\f[] the
  225. \f[B]action\f[] category setting will override the \f[B]rmdir\f[]
  226. setting.
  227. .SS branches
  228. .PP
  229. The \[aq]branches\[aq] (formerly \[aq]srcmounts\[aq]) argument is a
  230. colon (\[aq]:\[aq]) delimited list of paths to be pooled together.
  231. It does not matter if the paths are on the same or different drives nor
  232. does it matter the filesystem.
  233. Used and available space will not be duplicated for paths on the same
  234. device and any features which aren\[aq]t supported by the underlying
  235. filesystem (such as file attributes or extended attributes) will return
  236. the appropriate errors.
  237. .PP
  238. To make it easier to include multiple branches mergerfs supports
  239. globbing (http://linux.die.net/man/7/glob).
  240. \f[B]The globbing tokens MUST be escaped when using via the shell else
  241. the shell itself will apply the glob itself.\f[]
  242. .PP
  243. Each branch can have a suffix of \f[C]=RW\f[] (read / write),
  244. \f[C]=RO\f[] (read\-only), or \f[C]=NC\f[] (no create).
  245. These suffixes work with globs as well and will apply to each path
  246. found.
  247. \f[C]RW\f[] is the default behavior and those paths will be eligible for
  248. all policy categories.
  249. \f[C]RO\f[] will exclude those paths from \f[C]create\f[] and
  250. \f[C]action\f[] policies (just as a filesystem being mounted \f[C]ro\f[]
  251. would).
  252. \f[C]NC\f[] will exclude those paths from \f[C]create\f[] policies (you
  253. can\[aq]t create but you can change / delete).
  254. .IP
  255. .nf
  256. \f[C]
  257. #\ mergerfs\ \-o\ allow_other,use_ino\ /mnt/disk\\*:/mnt/cdrom\ /media/drives
  258. \f[]
  259. .fi
  260. .PP
  261. The above line will use all mount points in /mnt prefixed with
  262. \f[B]disk\f[] and the \f[B]cdrom\f[].
  263. .PP
  264. To have the pool mounted at boot or otherwise accessable from related
  265. tools use \f[B]/etc/fstab\f[].
  266. .IP
  267. .nf
  268. \f[C]
  269. #\ <file\ system>\ \ \ \ \ \ \ \ <mount\ point>\ \ <type>\ \ \ \ \ \ \ \ \ <options>\ \ \ \ \ \ \ \ \ \ \ \ \ <dump>\ \ <pass>
  270. /mnt/disk*:/mnt/cdrom\ \ /media/drives\ \ fuse.mergerfs\ \ allow_other,use_ino\ \ \ 0\ \ \ \ \ \ \ 0
  271. \f[]
  272. .fi
  273. .PP
  274. \f[B]NOTE:\f[] the globbing is done at mount or xattr update time (see
  275. below).
  276. If a new directory is added matching the glob after the fact it will not
  277. be automatically included.
  278. .PP
  279. \f[B]NOTE:\f[] for mounting via \f[B]fstab\f[] to work you must have
  280. \f[B]mount.fuse\f[] installed.
  281. For Ubuntu/Debian it is included in the \f[B]fuse\f[] package.
  282. .SS symlinkify
  283. .PP
  284. Due to the levels of indirection introduced by mergerfs and the
  285. underlying technology FUSE there can be varying levels of performance
  286. degredation.
  287. This feature will turn non\-directories which are not writable into
  288. symlinks to the original file found by the \f[C]readlink\f[] policy
  289. after the mtime and ctime are older than the timeout.
  290. .PP
  291. \f[B]WARNING:\f[] The current implementation has a known issue in which
  292. if the file is open and being used when the file is converted to a
  293. symlink then the application which has that file open will receive an
  294. error when using it.
  295. This is unlikely to occur in practice but is something to keep in mind.
  296. .PP
  297. \f[B]WARNING:\f[] Some backup solutions, such as CrashPlan, do not
  298. backup the target of a symlink.
  299. If using this feature it will be necessary to point any backup software
  300. to the original drives or configure the software to follow symlinks if
  301. such an option is available.
  302. Alternatively create two mounts.
  303. One for backup and one for general consumption.
  304. .SS nullrw
  305. .PP
  306. Due to how FUSE works there is an overhead to all requests made to a
  307. FUSE filesystem.
  308. Meaning that even a simple passthrough will have some slowdown.
  309. However, generally the overhead is minimal in comparison to the cost of
  310. the underlying I/O.
  311. By disabling the underlying I/O we can test the theoretical performance
  312. boundries.
  313. .PP
  314. By enabling \f[C]nullrw\f[] mergerfs will work as it always does
  315. \f[B]except\f[] that all reads and writes will be no\-ops.
  316. A write will succeed (the size of the write will be returned as if it
  317. were successful) but mergerfs does nothing with the data it was given.
  318. Similarly a read will return the size requested but won\[aq]t touch the
  319. buffer.
  320. .PP
  321. Example:
  322. .IP
  323. .nf
  324. \f[C]
  325. $\ dd\ if=/dev/zero\ of=/path/to/mergerfs/mount/benchmark\ ibs=1M\ obs=512\ count=1024\ conv=fdatasync
  326. 1024+0\ records\ in
  327. 2097152+0\ records\ out
  328. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 15.4067\ s,\ 69.7\ MB/s
  329. $\ dd\ if=/dev/zero\ of=/path/to/mergerfs/mount/benchmark\ ibs=1M\ obs=1M\ count=1024\ conv=fdatasync
  330. 1024+0\ records\ in
  331. 1024+0\ records\ out
  332. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 0.219585\ s,\ 4.9\ GB/s
  333. $\ dd\ if=/path/to/mergerfs/mount/benchmark\ of=/dev/null\ bs=512\ count=102400\ conv=fdatasync
  334. 102400+0\ records\ in
  335. 102400+0\ records\ out
  336. 52428800\ bytes\ (52\ MB,\ 50\ MiB)\ copied,\ 0.757991\ s,\ 69.2\ MB/s
  337. $\ dd\ if=/path/to/mergerfs/mount/benchmark\ of=/dev/null\ bs=1M\ count=1024\ conv=fdatasync
  338. 1024+0\ records\ in
  339. 1024+0\ records\ out
  340. 1073741824\ bytes\ (1.1\ GB,\ 1.0\ GiB)\ copied,\ 0.18405\ s,\ 5.8\ GB/s
  341. \f[]
  342. .fi
  343. .PP
  344. It\[aq]s important to test with different \f[C]obs\f[] (output block
  345. size) values since the relative overhead is greater with smaller values.
  346. As you can see above the size of a read or write can massively impact
  347. theoretical performance.
  348. If an application performs much worse through mergerfs it could very
  349. well be that it doesn\[aq]t optimally size its read and write requests.
  350. In such cases contact the mergerfs author so it can be investigated.
  351. .SS xattr
  352. .PP
  353. Runtime extended attribute support can be managed via the \f[C]xattr\f[]
  354. option.
  355. By default it will passthrough any xattr calls.
  356. Given xattr support is rarely used and can have significant performance
  357. implications mergerfs allows it to be disabled at runtime.
  358. .PP
  359. \f[C]noattr\f[] will cause mergerfs to short circuit all xattr calls and
  360. return ENOATTR where appropriate.
  361. mergerfs still gets all the requests but they will not be forwarded on
  362. to the underlying filesystems.
  363. The runtime control will still function in this mode.
  364. .PP
  365. \f[C]nosys\f[] will cause mergerfs to return ENOSYS for any xattr call.
  366. The difference with \f[C]noattr\f[] is that the kernel will cache this
  367. fact and itself short circuit future calls.
  368. This will be more efficient than \f[C]noattr\f[] but will cause
  369. mergerfs\[aq] runtime control via the hidden file to stop working.
  370. .SH FUNCTIONS / POLICIES / CATEGORIES
  371. .PP
  372. The POSIX filesystem API is made up of a number of functions.
  373. \f[B]creat\f[], \f[B]stat\f[], \f[B]chown\f[], etc.
  374. In mergerfs most of the core functions are grouped into 3 categories:
  375. \f[B]action\f[], \f[B]create\f[], and \f[B]search\f[].
  376. These functions and categories can be assigned a policy which dictates
  377. what file or directory is chosen when performing that behavior.
  378. Any policy can be assigned to a function or category though some may not
  379. be very useful in practice.
  380. For instance: \f[B]rand\f[] (random) may be useful for file creation
  381. (create) but could lead to very odd behavior if used for \f[C]chmod\f[]
  382. if there were more than one copy of the file.
  383. .PP
  384. Some functions, listed in the category \f[C]N/A\f[] below, can not be
  385. assigned the normal policies.
  386. All functions which work on file handles use the handle which was
  387. acquired by \f[C]open\f[] or \f[C]create\f[].
  388. \f[C]readdir\f[] has no real need for a policy given the purpose is
  389. merely to return a list of entries in a directory.
  390. \f[C]statfs\f[]\[aq]s behavior can be modified via other options.
  391. That said many times the current FUSE kernel driver will not always
  392. provide the file handle when a client calls \f[C]fgetattr\f[],
  393. \f[C]fchown\f[], \f[C]fchmod\f[], \f[C]futimens\f[], \f[C]ftruncate\f[],
  394. etc.
  395. This means it will call the regular, path based, versions.
  396. .PP
  397. When using policies which are based on a branch\[aq]s available space
  398. the base path provided is used.
  399. Not the full path to the file in question.
  400. Meaning that sub mounts won\[aq]t be considered in the space
  401. calculations.
  402. The reason is that it doesn\[aq]t really work for non\-path preserving
  403. policies and can lead to non\-obvious behaviors.
  404. .SS Function / Category classifications
  405. .PP
  406. .TS
  407. tab(@);
  408. lw(7.9n) lw(62.1n).
  409. T{
  410. Category
  411. T}@T{
  412. FUSE Functions
  413. T}
  414. _
  415. T{
  416. action
  417. T}@T{
  418. chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate,
  419. unlink, utimens
  420. T}
  421. T{
  422. create
  423. T}@T{
  424. create, mkdir, mknod, symlink
  425. T}
  426. T{
  427. search
  428. T}@T{
  429. access, getattr, getxattr, ioctl (directories), listxattr, open,
  430. readlink
  431. T}
  432. T{
  433. N/A
  434. T}@T{
  435. fchmod, fchown, futimens, ftruncate, fallocate, fgetattr, fsync, ioctl
  436. (files), read, readdir, release, statfs, write
  437. T}
  438. .TE
  439. .PP
  440. In cases where something may be searched (to confirm a directory exists
  441. across all source mounts) \f[B]getattr\f[] will be used.
  442. .SS Path Preservation
  443. .PP
  444. Policies, as described below, are of two basic types.
  445. \f[C]path\ preserving\f[] and \f[C]non\-path\ preserving\f[].
  446. .PP
  447. All policies which start with \f[C]ep\f[] (\f[B]epff\f[],
  448. \f[B]eplfs\f[], \f[B]eplus\f[], \f[B]epmfs\f[], \f[B]eprand\f[]) are
  449. \f[C]path\ preserving\f[].
  450. \f[C]ep\f[] stands for \f[C]existing\ path\f[].
  451. .PP
  452. A path preserving policy will only consider drives where the relative
  453. path being accessed already exists.
  454. .PP
  455. When using non\-path preserving policies paths will be cloned to target
  456. drives as necessary.
  457. .SS Filters
  458. .PP
  459. Policies basically search branches and create a list of files / paths
  460. for functions to work on.
  461. The policy is responsible for filtering and sorting.
  462. The policy type defines the sorting but filtering is mostly uniform as
  463. described below.
  464. .IP \[bu] 2
  465. No \f[B]search\f[] policies filter.
  466. .IP \[bu] 2
  467. All \f[B]action\f[] policies will filter out branches which are mounted
  468. \f[B]read\-only\f[] or tagged as \f[B]RO (read\-only)\f[].
  469. .IP \[bu] 2
  470. All \f[B]create\f[] policies will filter out branches which are mounted
  471. \f[B]read\-only\f[], tagged \f[B]RO (read\-only)\f[] or \f[B]NC (no
  472. create)\f[], or has available space less than \f[C]minfreespace\f[].
  473. .PP
  474. If all branches are filtered an error will be returned.
  475. Typically \f[B]EROFS\f[] or \f[B]ENOSPC\f[] depending on the reasons.
  476. .SS Policy descriptions
  477. .PP
  478. .TS
  479. tab(@);
  480. lw(16.6n) lw(53.4n).
  481. T{
  482. Policy
  483. T}@T{
  484. Description
  485. T}
  486. _
  487. T{
  488. all
  489. T}@T{
  490. Search category: same as \f[B]epall\f[].
  491. Action category: same as \f[B]epall\f[].
  492. Create category: for \f[B]mkdir\f[], \f[B]mknod\f[], and
  493. \f[B]symlink\f[] it will apply to all branches.
  494. \f[B]create\f[] works like \f[B]ff\f[].
  495. T}
  496. T{
  497. epall (existing path, all)
  498. T}@T{
  499. Search category: same as \f[B]epff\f[] (but more expensive because it
  500. doesn\[aq]t stop after finding a valid branch).
  501. Action category: apply to all found.
  502. Create category: for \f[B]mkdir\f[], \f[B]mknod\f[], and
  503. \f[B]symlink\f[] it will apply to all found.
  504. \f[B]create\f[] works like \f[B]epff\f[] (but more expensive because it
  505. doesn\[aq]t stop after finding a valid branch).
  506. T}
  507. T{
  508. epff (existing path, first found)
  509. T}@T{
  510. Given the order of the branches, as defined at mount time or configured
  511. at runtime, act on the first one found where the relative path exists.
  512. T}
  513. T{
  514. eplfs (existing path, least free space)
  515. T}@T{
  516. Of all the branches on which the relative path exists choose the drive
  517. with the least free space.
  518. T}
  519. T{
  520. eplus (existing path, least used space)
  521. T}@T{
  522. Of all the branches on which the relative path exists choose the drive
  523. with the least used space.
  524. T}
  525. T{
  526. epmfs (existing path, most free space)
  527. T}@T{
  528. Of all the branches on which the relative path exists choose the drive
  529. with the most free space.
  530. T}
  531. T{
  532. eprand (existing path, random)
  533. T}@T{
  534. Calls \f[B]epall\f[] and then randomizes.
  535. T}
  536. T{
  537. erofs
  538. T}@T{
  539. Exclusively return \f[B]\-1\f[] with \f[B]errno\f[] set to
  540. \f[B]EROFS\f[] (read\-only filesystem).
  541. T}
  542. T{
  543. ff (first found)
  544. T}@T{
  545. Search category: same as \f[B]epff\f[].
  546. Action category: same as \f[B]epff\f[].
  547. Create category: Given the order of the drives, as defined at mount time
  548. or configured at runtime, act on the first one found.
  549. T}
  550. T{
  551. lfs (least free space)
  552. T}@T{
  553. Search category: same as \f[B]eplfs\f[].
  554. Action category: same as \f[B]eplfs\f[].
  555. Create category: Pick the drive with the least available free space.
  556. T}
  557. T{
  558. lus (least used space)
  559. T}@T{
  560. Search category: same as \f[B]eplus\f[].
  561. Action category: same as \f[B]eplus\f[].
  562. Create category: Pick the drive with the least used space.
  563. T}
  564. T{
  565. mfs (most free space)
  566. T}@T{
  567. Search category: same as \f[B]epmfs\f[].
  568. Action category: same as \f[B]epmfs\f[].
  569. Create category: Pick the drive with the most available free space.
  570. T}
  571. T{
  572. newest
  573. T}@T{
  574. Pick the file / directory with the largest mtime.
  575. T}
  576. T{
  577. rand (random)
  578. T}@T{
  579. Calls \f[B]all\f[] and then randomizes.
  580. T}
  581. .TE
  582. .SS Defaults
  583. .PP
  584. .TS
  585. tab(@);
  586. l l.
  587. T{
  588. Category
  589. T}@T{
  590. Policy
  591. T}
  592. _
  593. T{
  594. action
  595. T}@T{
  596. epall
  597. T}
  598. T{
  599. create
  600. T}@T{
  601. epmfs
  602. T}
  603. T{
  604. search
  605. T}@T{
  606. ff
  607. T}
  608. .TE
  609. .SS ioctl
  610. .PP
  611. When \f[C]ioctl\f[] is used with an open file then it will use the file
  612. handle which was created at the original \f[C]open\f[] call.
  613. However, when using \f[C]ioctl\f[] with a directory mergerfs will use
  614. the \f[C]open\f[] policy to find the directory to act on.
  615. .SS unlink
  616. .PP
  617. In FUSE there is an opaque "file handle" which is created by
  618. \f[C]open\f[], \f[C]create\f[], or \f[C]opendir\f[], passed to the
  619. kernel, and then is passed back to the FUSE userland application by the
  620. kernel.
  621. Unfortunately, the FUSE kernel driver does not always send the file
  622. handle when it theoretically could/should.
  623. This complicates certain behaviors / workflows particularly in the high
  624. level API.
  625. As a result mergerfs is currently doing a few hacky things.
  626. .PP
  627. libfuse2 and libfuse3, when using the high level API, will rename names
  628. to \f[C]\&.fuse_hiddenXXXXXX\f[] if the file is open when unlinked or
  629. renamed over.
  630. It does this so the file is still available when a request referencing
  631. the now missing file is made.
  632. This file however keeps a \f[C]rmdir\f[] from succeeding and can be
  633. picked up by software reading directories.
  634. .PP
  635. The change mergerfs has done is that if a file is open when an unlink or
  636. rename happens it will open the file and keep it open till closed by all
  637. those who opened it prior.
  638. When a request comes in referencing that file and it doesn\[aq]t include
  639. a file handle it will instead use the file handle created at
  640. unlink/rename time.
  641. .PP
  642. This won\[aq]t result in technically proper behavior but close enough
  643. for many usecases.
  644. .PP
  645. The plan is to rewrite mergerfs to use the low level API so these
  646. invasive libfuse changes are no longer necessary.
  647. .SS rename & link
  648. .PP
  649. \f[B]NOTE:\f[] If you\[aq]re receiving errors from software when files
  650. are moved / renamed / linked then you should consider changing the
  651. create policy to one which is \f[B]not\f[] path preserving, enabling
  652. \f[C]ignorepponrename\f[], or contacting the author of the offending
  653. software and requesting that \f[C]EXDEV\f[] be properly handled.
  654. .PP
  655. \f[C]rename\f[] and \f[C]link\f[] are tricky functions in a union
  656. filesystem.
  657. \f[C]rename\f[] only works within a single filesystem or device.
  658. If a rename can\[aq]t be done atomically due to the source and
  659. destination paths existing on different mount points it will return
  660. \f[B]\-1\f[] with \f[B]errno = EXDEV\f[] (cross device).
  661. So if a \f[C]rename\f[]\[aq]s source and target are on different drives
  662. within the pool it creates an issue.
  663. .PP
  664. Originally mergerfs would return EXDEV whenever a rename was requested
  665. which was cross directory in any way.
  666. This made the code simple and was technically complient with POSIX
  667. requirements.
  668. However, many applications fail to handle EXDEV at all and treat it as a
  669. normal error or otherwise handle it poorly.
  670. Such apps include: gvfsd\-fuse v1.20.3 and prior, Finder / CIFS/SMB
  671. client in Apple OSX 10.9+, NZBGet, Samba\[aq]s recycling bin feature.
  672. .PP
  673. As a result a compromise was made in order to get most software to work
  674. while still obeying mergerfs\[aq] policies.
  675. Below is the basic logic.
  676. .IP \[bu] 2
  677. If using a \f[B]create\f[] policy which tries to preserve directory
  678. paths (epff,eplfs,eplus,epmfs)
  679. .IP \[bu] 2
  680. Using the \f[B]rename\f[] policy get the list of files to rename
  681. .IP \[bu] 2
  682. For each file attempt rename:
  683. .RS 2
  684. .IP \[bu] 2
  685. If failure with ENOENT run \f[B]create\f[] policy
  686. .IP \[bu] 2
  687. If create policy returns the same drive as currently evaluating then
  688. clone the path
  689. .IP \[bu] 2
  690. Re\-attempt rename
  691. .RE
  692. .IP \[bu] 2
  693. If \f[B]any\f[] of the renames succeed the higher level rename is
  694. considered a success
  695. .IP \[bu] 2
  696. If \f[B]no\f[] renames succeed the first error encountered will be
  697. returned
  698. .IP \[bu] 2
  699. On success:
  700. .RS 2
  701. .IP \[bu] 2
  702. Remove the target from all drives with no source file
  703. .IP \[bu] 2
  704. Remove the source from all drives which failed to rename
  705. .RE
  706. .IP \[bu] 2
  707. If using a \f[B]create\f[] policy which does \f[B]not\f[] try to
  708. preserve directory paths
  709. .IP \[bu] 2
  710. Using the \f[B]rename\f[] policy get the list of files to rename
  711. .IP \[bu] 2
  712. Using the \f[B]getattr\f[] policy get the target path
  713. .IP \[bu] 2
  714. For each file attempt rename:
  715. .RS 2
  716. .IP \[bu] 2
  717. If the source drive != target drive:
  718. .IP \[bu] 2
  719. Clone target path from target drive to source drive
  720. .IP \[bu] 2
  721. Rename
  722. .RE
  723. .IP \[bu] 2
  724. If \f[B]any\f[] of the renames succeed the higher level rename is
  725. considered a success
  726. .IP \[bu] 2
  727. If \f[B]no\f[] renames succeed the first error encountered will be
  728. returned
  729. .IP \[bu] 2
  730. On success:
  731. .RS 2
  732. .IP \[bu] 2
  733. Remove the target from all drives with no source file
  734. .IP \[bu] 2
  735. Remove the source from all drives which failed to rename
  736. .RE
  737. .PP
  738. The the removals are subject to normal entitlement checks.
  739. .PP
  740. The above behavior will help minimize the likelihood of EXDEV being
  741. returned but it will still be possible.
  742. .PP
  743. \f[B]link\f[] uses the same strategy but without the removals.
  744. .SS readdir
  745. .PP
  746. readdir (http://linux.die.net/man/3/readdir) is different from all other
  747. filesystem functions.
  748. While it could have it\[aq]s own set of policies to tweak its behavior
  749. at this time it provides a simple union of files and directories found.
  750. Remember that any action or information queried about these files and
  751. directories come from the respective function.
  752. For instance: an \f[B]ls\f[] is a \f[B]readdir\f[] and for each
  753. file/directory returned \f[B]getattr\f[] is called.
  754. Meaning the policy of \f[B]getattr\f[] is responsible for choosing the
  755. file/directory which is the source of the metadata you see in an
  756. \f[B]ls\f[].
  757. .SS statfs / statvfs
  758. .PP
  759. statvfs (http://linux.die.net/man/2/statvfs) normalizes the source
  760. drives based on the fragment size and sums the number of adjusted blocks
  761. and inodes.
  762. This means you will see the combined space of all sources.
  763. Total, used, and free.
  764. The sources however are dedupped based on the drive so multiple sources
  765. on the same drive will not result in double counting it\[aq]s space.
  766. Filesystems mounted further down the tree of the branch will not be
  767. included when checking the mount\[aq]s stats.
  768. .PP
  769. The options \f[C]statfs\f[] and \f[C]statfs_ignore\f[] can be used to
  770. modify \f[C]statfs\f[] behavior.
  771. .SH BUILDING
  772. .PP
  773. \f[B]NOTE:\f[] Prebuilt packages can be found at:
  774. https://github.com/trapexit/mergerfs/releases
  775. .PP
  776. First get the code from github (https://github.com/trapexit/mergerfs).
  777. .IP
  778. .nf
  779. \f[C]
  780. $\ git\ clone\ https://github.com/trapexit/mergerfs.git
  781. $\ #\ or
  782. $\ wget\ https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs\-<ver>.tar.gz
  783. \f[]
  784. .fi
  785. .SS Debian / Ubuntu
  786. .IP
  787. .nf
  788. \f[C]
  789. $\ cd\ mergerfs
  790. $\ sudo\ tools/install\-build\-pkgs
  791. $\ make\ deb
  792. $\ sudo\ dpkg\ \-i\ ../mergerfs_version_arch.deb
  793. \f[]
  794. .fi
  795. .SS Fedora
  796. .IP
  797. .nf
  798. \f[C]
  799. $\ su\ \-
  800. #\ cd\ mergerfs
  801. #\ tools/install\-build\-pkgs
  802. #\ make\ rpm
  803. #\ rpm\ \-i\ rpmbuild/RPMS/<arch>/mergerfs\-<verion>.<arch>.rpm
  804. \f[]
  805. .fi
  806. .SS Generically
  807. .PP
  808. Have git, g++, make, python, automake, libtool installed.
  809. .IP
  810. .nf
  811. \f[C]
  812. $\ cd\ mergerfs
  813. $\ make
  814. $\ sudo\ make\ install
  815. \f[]
  816. .fi
  817. .SS Build options
  818. .IP
  819. .nf
  820. \f[C]
  821. $\ make\ help
  822. usage:\ make
  823. make\ USE_XATTR=0\ \ \ \ \ \ \-\ build\ program\ without\ xattrs\ functionality
  824. make\ STATIC=1\ \ \ \ \ \ \ \ \ \-\ build\ static\ binary
  825. make\ LTO=1\ \ \ \ \ \ \ \ \ \ \ \ \-\ build\ with\ link\ time\ optimization
  826. \f[]
  827. .fi
  828. .SH RUNTIME CONFIG
  829. .SS .mergerfs pseudo file
  830. .IP
  831. .nf
  832. \f[C]
  833. <mountpoint>/.mergerfs
  834. \f[]
  835. .fi
  836. .PP
  837. There is a pseudo file available at the mount point which allows for the
  838. runtime modification of certain \f[B]mergerfs\f[] options.
  839. The file will not show up in \f[B]readdir\f[] but can be
  840. \f[B]stat\f[]\[aq]ed and manipulated via
  841. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls.
  842. .PP
  843. Any changes made at runtime are \f[B]not\f[] persisted.
  844. If you wish for values to persist they must be included as options
  845. wherever you configure the mounting of mergerfs (/etc/fstab).
  846. .SS Keys
  847. .PP
  848. Use \f[C]xattr\ \-l\ /mountpoint/.mergerfs\f[] to see all supported
  849. keys.
  850. Some are informational and therefore read\-only.
  851. .SS user.mergerfs.branches
  852. .PP
  853. \f[B]NOTE:\f[] formerly \f[C]user.mergerfs.srcmounts\f[] but said key is
  854. still supported.
  855. .PP
  856. Used to query or modify the list of branches.
  857. When modifying there are several shortcuts to easy manipulation of the
  858. list.
  859. .PP
  860. .TS
  861. tab(@);
  862. l l.
  863. T{
  864. Value
  865. T}@T{
  866. Description
  867. T}
  868. _
  869. T{
  870. [list]
  871. T}@T{
  872. set
  873. T}
  874. T{
  875. +<[list]
  876. T}@T{
  877. prepend
  878. T}
  879. T{
  880. +>[list]
  881. T}@T{
  882. append
  883. T}
  884. T{
  885. \-[list]
  886. T}@T{
  887. remove all values provided
  888. T}
  889. T{
  890. \-<
  891. T}@T{
  892. remove first in list
  893. T}
  894. T{
  895. \->
  896. T}@T{
  897. remove last in list
  898. T}
  899. .TE
  900. .PP
  901. \f[C]xattr\ \-w\ user.mergerfs.branches\ +</mnt/drive3\ /mnt/pool/.mergerfs\f[]
  902. .PP
  903. The \f[C]=NC\f[], \f[C]=RO\f[], \f[C]=RW\f[] syntax works just as on the
  904. command line.
  905. .SS minfreespace
  906. .PP
  907. Input: interger with an optional multiplier suffix.
  908. \f[B]K\f[], \f[B]M\f[], or \f[B]G\f[].
  909. .PP
  910. Output: value in bytes
  911. .SS moveonenospc
  912. .PP
  913. Input: \f[B]true\f[] and \f[B]false\f[]
  914. .PP
  915. Ouput: \f[B]true\f[] or \f[B]false\f[]
  916. .SS categories / funcs
  917. .PP
  918. Input: short policy string as described elsewhere in this document
  919. .PP
  920. Output: the policy string except for categories where its funcs have
  921. multiple types.
  922. In that case it will be a comma separated list
  923. .SS Example
  924. .IP
  925. .nf
  926. \f[C]
  927. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-l\ .mergerfs
  928. user.mergerfs.branches:\ /mnt/a:/mnt/b
  929. user.mergerfs.minfreespace:\ 4294967295
  930. user.mergerfs.moveonenospc:\ false
  931. \&...
  932. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  933. ff
  934. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.category.search\ newest\ .mergerfs
  935. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  936. newest
  937. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.branches\ +/mnt/c\ .mergerfs
  938. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.branches\ .mergerfs
  939. /mnt/a:/mnt/b:/mnt/c
  940. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.branches\ =/mnt/c\ .mergerfs
  941. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.branches\ .mergerfs
  942. /mnt/c
  943. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-w\ user.mergerfs.branches\ \[aq]+</mnt/a:/mnt/b\[aq]\ .mergerfs
  944. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.branches\ .mergerfs
  945. /mnt/a:/mnt/b:/mnt/c
  946. \f[]
  947. .fi
  948. .SS file / directory xattrs
  949. .PP
  950. While they won\[aq]t show up when using
  951. listxattr (http://linux.die.net/man/2/listxattr) \f[B]mergerfs\f[]
  952. offers a number of special xattrs to query information about the files
  953. served.
  954. To access the values you will need to issue a
  955. getxattr (http://linux.die.net/man/2/getxattr) for one of the following:
  956. .IP \[bu] 2
  957. \f[B]user.mergerfs.basepath:\f[] the base mount point for the file given
  958. the current getattr policy
  959. .IP \[bu] 2
  960. \f[B]user.mergerfs.relpath:\f[] the relative path of the file from the
  961. perspective of the mount point
  962. .IP \[bu] 2
  963. \f[B]user.mergerfs.fullpath:\f[] the full path of the original file
  964. given the getattr policy
  965. .IP \[bu] 2
  966. \f[B]user.mergerfs.allpaths:\f[] a NUL (\[aq]\[aq]) separated list of
  967. full paths to all files found
  968. .IP
  969. .nf
  970. \f[C]
  971. [trapexit:/mnt/mergerfs]\ $\ ls
  972. A\ B\ C
  973. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.fullpath\ A
  974. /mnt/a/full/path/to/A
  975. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.basepath\ A
  976. /mnt/a
  977. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.relpath\ A
  978. /full/path/to/A
  979. [trapexit:/mnt/mergerfs]\ $\ xattr\ \-p\ user.mergerfs.allpaths\ A\ |\ tr\ \[aq]\\0\[aq]\ \[aq]\\n\[aq]
  980. /mnt/a/full/path/to/A
  981. /mnt/b/full/path/to/A
  982. \f[]
  983. .fi
  984. .SH TOOLING
  985. .IP \[bu] 2
  986. https://github.com/trapexit/mergerfs\-tools
  987. .IP \[bu] 2
  988. mergerfs.ctl: A tool to make it easier to query and configure mergerfs
  989. at runtime
  990. .IP \[bu] 2
  991. mergerfs.fsck: Provides permissions and ownership auditing and the
  992. ability to fix them
  993. .IP \[bu] 2
  994. mergerfs.dedup: Will help identify and optionally remove duplicate files
  995. .IP \[bu] 2
  996. mergerfs.dup: Ensure there are at least N copies of a file across the
  997. pool
  998. .IP \[bu] 2
  999. mergerfs.balance: Rebalance files across drives by moving them from the
  1000. most filled to the least filled
  1001. .IP \[bu] 2
  1002. mergerfs.mktrash: Creates FreeDesktop.org Trash specification compatible
  1003. directories on a mergerfs mount
  1004. .IP \[bu] 2
  1005. https://github.com/trapexit/scorch
  1006. .IP \[bu] 2
  1007. scorch: A tool to help discover silent corruption of files and keep
  1008. track of files
  1009. .IP \[bu] 2
  1010. https://github.com/trapexit/bbf
  1011. .IP \[bu] 2
  1012. bbf (bad block finder): a tool to scan for and \[aq]fix\[aq] hard drive
  1013. bad blocks and find the files using those blocks
  1014. .SH CACHING
  1015. .SS page caching
  1016. .PP
  1017. The kernel performs caching of data pages on all files not opened with
  1018. \f[C]O_DIRECT\f[].
  1019. Due to mergerfs using FUSE and therefore being a userland process the
  1020. kernel can double cache the content being read through mergerfs.
  1021. Once from the underlying filesystem and once for mergerfs.
  1022. Using \f[C]direct_io\f[] and/or \f[C]dropcacheonclose\f[] help minimize
  1023. the double caching.
  1024. \f[C]direct_io\f[] will instruct the kernel to bypass the page cache for
  1025. files opened through mergerfs.
  1026. \f[C]dropcacheonclose\f[] will cause mergerfs to instruct the kernel to
  1027. flush a file\[aq]s page cache for which it had opened when closed.
  1028. If most data is read once its probably best to enable both (read above
  1029. for details and limitations).
  1030. .PP
  1031. If a cache is desired for mergerfs do not enable \f[C]direct_io\f[] and
  1032. instead possibly use \f[C]auto_cache\f[] or \f[C]kernel_cache\f[].
  1033. By default FUSE will invalidate cached pages when a file is opened.
  1034. By using \f[C]auto_cache\f[] it will instead use \f[C]getattr\f[] to
  1035. check if a file has changed when the file is opened and if so will flush
  1036. the cache.
  1037. \f[C]ac_attr_timeout\f[] is the timeout for keeping said cache.
  1038. Alternatively \f[C]kernel_cache\f[] will keep the cache across opens
  1039. unless invalidated through other means.
  1040. You should only uses these if you do not plan to write/modify the same
  1041. files through mergerfs and the underlying filesystem at the same time.
  1042. It could lead to corruption.
  1043. Then again doing so without caching can also cause issues.
  1044. .PP
  1045. It\[aq]s a difficult balance between memory usage, cache bloat &
  1046. duplication, and performance.
  1047. Ideally mergerfs would be able to disable caching for the files it
  1048. reads/writes but allow page caching for itself.
  1049. That would limit the FUSE overhead.
  1050. However, there isn\[aq]t good way to achieve this.
  1051. .SS entry & attribute caching
  1052. .PP
  1053. Given the relatively high cost of FUSE due to the kernel <\-> userspace
  1054. round trips there are kernel side caches for file entries and
  1055. attributes.
  1056. The entry cache limits the \f[C]lookup\f[] calls to mergerfs which ask
  1057. if a file exists.
  1058. The attribute cache limits the need to make \f[C]getattr\f[] calls to
  1059. mergerfs which provide file attributes (mode, size, type, etc.).
  1060. As with the page cache these should not be used if the underlying
  1061. filesystems are being manipulated at the same time as it could lead to
  1062. odd behavior or data corruption.
  1063. The options for setting these are \f[C]cache.entry\f[] and
  1064. \f[C]cache.negative_entry\f[] for the entry cache and
  1065. \f[C]cache.attr\f[] for the attributes cache.
  1066. \f[C]cache.negative_entry\f[] refers to the timeout for negative
  1067. responses to lookups (non\-existant files).
  1068. .SS policy caching
  1069. .PP
  1070. Policies are run every time a function is called.
  1071. These policies can be expensive depending on the setup and usage
  1072. patterns.
  1073. Generally we wouldn\[aq]t want to cache policy results because it may
  1074. result in stale responses if the underlying drives are used directly.
  1075. .PP
  1076. The \f[C]open\f[] policy cache will cache the result of an \f[C]open\f[]
  1077. policy for a particular input for \f[C]cache.open\f[] seconds or until
  1078. the file is unlinked.
  1079. Each file close (release) will randomly chose to clean up the cache of
  1080. expired entries.
  1081. .PP
  1082. This cache is useful in cases like that of \f[B]Transmission\f[] which
  1083. has a "open, read/write, close" pattern (which is much more costly due
  1084. to the FUSE overhead than normal.)
  1085. .SS statfs caching
  1086. .PP
  1087. Of the syscalls used by mergerfs in policies the \f[C]statfs\f[] /
  1088. \f[C]statvfs\f[] call is perhaps the most expensive.
  1089. It\[aq]s used to find out the available space of a drive and whether it
  1090. is mounted read\-only.
  1091. Depending on the setup and usage pattern these queries can be relatively
  1092. costly.
  1093. When \f[C]cache.statfs\f[] is enabled all calls to \f[C]statfs\f[] by a
  1094. policy will be cached for the number of seconds its set to.
  1095. .PP
  1096. Example: If the create policy is \f[C]mfs\f[] and the timeout is 60 then
  1097. for that 60 seconds the same drive will be returned as the target for
  1098. creates because the available space won\[aq]t be updated for that time.
  1099. .SS writeback caching
  1100. .PP
  1101. writeback caching is a technique for improving write speeds by batching
  1102. writes at a faster device and then bulk writing to the slower device.
  1103. With FUSE the kernel will wait for a number of writes to be made and
  1104. then send it to the filesystem as one request.
  1105. mergerfs currently uses a slightly modified and vendored libfuse 2.9.7
  1106. which does not support writeback caching.
  1107. However, a prototype port to libfuse 3.x has been made and the writeback
  1108. cache appears to work as expected (though performance improvements
  1109. greatly depend on the way the client app writes data).
  1110. Once the port is complete and thoroughly tested writeback caching will
  1111. be available.
  1112. .SS tiered caching
  1113. .PP
  1114. Some storage technologies support what some call "tiered" caching.
  1115. The placing of usually smaller, faster storage as a transparent cache to
  1116. larger, slower storage.
  1117. NVMe, SSD, Optane in front of traditional HDDs for instance.
  1118. .PP
  1119. MergerFS does not natively support any sort of tiered caching.
  1120. Most users have no use for such a feature and its inclusion would
  1121. complicate the code.
  1122. However, there are a few situations where a cache drive could help with
  1123. a typical mergerfs setup.
  1124. .IP "1." 3
  1125. Fast network, slow drives, many readers: You\[aq]ve a 10+Gbps network
  1126. with many readers and your regular drives can\[aq]t keep up.
  1127. .IP "2." 3
  1128. Fast network, slow drives, small\[aq]ish bursty writes: You have a
  1129. 10+Gbps network and wish to transfer amounts of data less than your
  1130. cache drive but wish to do so quickly.
  1131. .PP
  1132. With #1 its arguable if you should be using mergerfs at all.
  1133. RAID would probably be the better solution.
  1134. If you\[aq]re going to use mergerfs there are other tactics that may
  1135. help: spreading the data across drives (see the mergerfs.dup tool) and
  1136. setting \f[C]func.open=rand\f[], using \f[C]symlinkify\f[], or using
  1137. dm\-cache or a similar technology to add tiered cache to the underlying
  1138. device.
  1139. .PP
  1140. With #2 one could use dm\-cache as well but there is another solution
  1141. which requires only mergerfs and a cronjob.
  1142. .IP "1." 3
  1143. Create 2 mergerfs pools.
  1144. One which includes just the slow drives and one which has both the fast
  1145. drives (SSD,NVME,etc.) and slow drives.
  1146. .IP "2." 3
  1147. The \[aq]cache\[aq] pool should have the cache drives listed first.
  1148. .IP "3." 3
  1149. The best \f[C]create\f[] policies to use for the \[aq]cache\[aq] pool
  1150. would probably be \f[C]ff\f[], \f[C]epff\f[], \f[C]lfs\f[], or
  1151. \f[C]eplfs\f[].
  1152. The latter two under the assumption that the cache drive(s) are far
  1153. smaller than the backing drives.
  1154. If using path preserving policies remember that you\[aq]ll need to
  1155. manually create the core directories of those paths you wish to be
  1156. cached.
  1157. Be sure the permissions are in sync.
  1158. Use \f[C]mergerfs.fsck\f[] to check / correct them.
  1159. You could also tag the slow drives as \f[C]=NC\f[] though that\[aq]d
  1160. mean if the cache drives fill you\[aq]d get "out of space" errors.
  1161. .IP "4." 3
  1162. Enable \f[C]moveonenospc\f[] and set \f[C]minfreespace\f[]
  1163. appropriately.
  1164. Perhaps setting \f[C]minfreespace\f[] to the size of the largest cache
  1165. drive.
  1166. .IP "5." 3
  1167. Set your programs to use the cache pool.
  1168. .IP "6." 3
  1169. Save one of the below scripts or create you\[aq]re own.
  1170. .IP "7." 3
  1171. Use \f[C]cron\f[] (as root) to schedule the command at whatever
  1172. frequency is appropriate for your workflow.
  1173. .SS time based expiring
  1174. .PP
  1175. Move files from cache to backing pool based only on the last time the
  1176. file was accessed.
  1177. Replace \f[C]\-atime\f[] with \f[C]\-amin\f[] if you want minutes rather
  1178. than days.
  1179. May want to use the \f[C]fadvise\f[] / \f[C]\-\-drop\-cache\f[] version
  1180. of rsync or run rsync with the tool "nocache".
  1181. .IP
  1182. .nf
  1183. \f[C]
  1184. #!/bin/bash
  1185. if\ [\ $#\ !=\ 3\ ];\ then
  1186. \ \ echo\ "usage:\ $0\ <cache\-drive>\ <backing\-pool>\ <days\-old>"
  1187. \ \ exit\ 1
  1188. fi
  1189. CACHE="${1}"
  1190. BACKING="${2}"
  1191. N=${3}
  1192. find\ "${CACHE}"\ \-type\ f\ \-atime\ +${N}\ \-printf\ \[aq]%P\\n\[aq]\ |\ \\
  1193. \ \ rsync\ \-\-files\-from=\-\ \-axqHAXWES\ \-\-preallocate\ \-\-remove\-source\-files\ "${CACHE}/"\ "${BACKING}/"
  1194. \f[]
  1195. .fi
  1196. .SS percentage full expiring
  1197. .PP
  1198. Move the oldest file from the cache to the backing pool.
  1199. Continue till below percentage threshold.
  1200. .IP
  1201. .nf
  1202. \f[C]
  1203. #!/bin/bash
  1204. if\ [\ $#\ !=\ 3\ ];\ then
  1205. \ \ echo\ "usage:\ $0\ <cache\-drive>\ <backing\-pool>\ <percentage>"
  1206. \ \ exit\ 1
  1207. fi
  1208. CACHE="${1}"
  1209. BACKING="${2}"
  1210. PERCENTAGE=${3}
  1211. set\ \-o\ errexit
  1212. while\ [\ $(df\ \-\-output=pcent\ "${CACHE}"\ |\ grep\ \-v\ Use\ |\ cut\ \-d\[aq]%\[aq]\ \-f1)\ \-gt\ ${PERCENTAGE}\ ]
  1213. do
  1214. \ \ \ \ FILE=$(find\ "${CACHE}"\ \-type\ f\ \-printf\ \[aq]%A\@\ %P\\n\[aq]\ |\ \\
  1215. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sort\ |\ \\
  1216. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ head\ \-n\ 1\ |\ \\
  1217. \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ cut\ \-d\[aq]\ \[aq]\ \-f2\-)
  1218. \ \ \ \ test\ \-n\ "${FILE}"
  1219. \ \ \ \ rsync\ \-axqHAXWES\ \-\-preallocate\ \-\-remove\-source\-files\ "${CACHE}/./${FILE}"\ "${BACKING}/"
  1220. done
  1221. \f[]
  1222. .fi
  1223. .SH TIPS / NOTES
  1224. .IP \[bu] 2
  1225. \f[B]use_ino\f[] will only work when used with mergerfs 2.18.0 and
  1226. above.
  1227. .IP \[bu] 2
  1228. Run mergerfs as \f[C]root\f[] (with \f[B]allow_other\f[]) unless
  1229. you\[aq]re merging paths which are owned by the same user otherwise
  1230. strange permission issues may arise.
  1231. .IP \[bu] 2
  1232. https://github.com/trapexit/backup\-and\-recovery\-howtos : A set of
  1233. guides / howtos on creating a data storage system, backing it up,
  1234. maintaining it, and recovering from failure.
  1235. .IP \[bu] 2
  1236. If you don\[aq]t see some directories and files you expect in a merged
  1237. point or policies seem to skip drives be sure the user has permission to
  1238. all the underlying directories.
  1239. Use \f[C]mergerfs.fsck\f[] to audit the drive for out of sync
  1240. permissions.
  1241. .IP \[bu] 2
  1242. Do \f[B]not\f[] use \f[C]direct_io\f[] if you expect applications (such
  1243. as rtorrent) to mmap (http://linux.die.net/man/2/mmap) files.
  1244. It is not currently supported in FUSE w/ \f[C]direct_io\f[] enabled.
  1245. Enabling \f[C]dropcacheonclose\f[] is recommended when
  1246. \f[C]direct_io\f[] is disabled.
  1247. .IP \[bu] 2
  1248. Since POSIX gives you only error or success on calls its difficult to
  1249. determine the proper behavior when applying the behavior to multiple
  1250. targets.
  1251. \f[B]mergerfs\f[] will return an error only if all attempts of an action
  1252. fail.
  1253. Any success will lead to a success returned.
  1254. This means however that some odd situations may arise.
  1255. .IP \[bu] 2
  1256. Kodi (http://kodi.tv), Plex (http://plex.tv),
  1257. Subsonic (http://subsonic.org), etc.
  1258. can use directory mtime (http://linux.die.net/man/2/stat) to more
  1259. efficiently determine whether to scan for new content rather than simply
  1260. performing a full scan.
  1261. If using the default \f[B]getattr\f[] policy of \f[B]ff\f[] its possible
  1262. those programs will miss an update on account of it returning the first
  1263. directory found\[aq]s \f[B]stat\f[] info and its a later directory on
  1264. another mount which had the \f[B]mtime\f[] recently updated.
  1265. To fix this you will want to set \f[B]func.getattr=newest\f[].
  1266. Remember though that this is just \f[B]stat\f[].
  1267. If the file is later \f[B]open\f[]\[aq]ed or \f[B]unlink\f[]\[aq]ed and
  1268. the policy is different for those then a completely different file or
  1269. directory could be acted on.
  1270. .IP \[bu] 2
  1271. Some policies mixed with some functions may result in strange behaviors.
  1272. Not that some of these behaviors and race conditions couldn\[aq]t happen
  1273. outside \f[B]mergerfs\f[] but that they are far more likely to occur on
  1274. account of the attempt to merge together multiple sources of data which
  1275. could be out of sync due to the different policies.
  1276. .IP \[bu] 2
  1277. For consistency its generally best to set \f[B]category\f[] wide
  1278. policies rather than individual \f[B]func\f[]\[aq]s.
  1279. This will help limit the confusion of tools such as
  1280. rsync (http://linux.die.net/man/1/rsync).
  1281. However, the flexibility is there if needed.
  1282. .SH KNOWN ISSUES / BUGS
  1283. .SS directory mtime is not being updated
  1284. .PP
  1285. Remember that the default policy for \f[C]getattr\f[] is \f[C]ff\f[].
  1286. The information for the first directory found will be returned.
  1287. If it wasn\[aq]t the directory which had been updated then it will
  1288. appear outdated.
  1289. .PP
  1290. The reason this is the default is because any other policy would be far
  1291. more expensive and for many applications it is unnecessary.
  1292. To always return the directory with the most recent mtime or a faked
  1293. value based on all found would require a scan of all drives.
  1294. That alone is far more expensive than \f[C]ff\f[] but would also
  1295. possibly spin up sleeping drives.
  1296. .PP
  1297. If you always want the directory information from the one with the most
  1298. recent mtime then use the \f[C]newest\f[] policy for \f[C]getattr\f[].
  1299. .SS \f[C]mv\ /mnt/pool/foo\ /mnt/disk1/foo\f[] removes \f[C]foo\f[]
  1300. .PP
  1301. This is not a bug.
  1302. .PP
  1303. Run in verbose mode to better undertand what\[aq]s happening:
  1304. .IP
  1305. .nf
  1306. \f[C]
  1307. $\ mv\ \-v\ /mnt/pool/foo\ /mnt/disk1/foo
  1308. copied\ \[aq]/mnt/pool/foo\[aq]\ \->\ \[aq]/mnt/disk1/foo\[aq]
  1309. removed\ \[aq]/mnt/pool/foo\[aq]
  1310. $\ ls\ /mnt/pool/foo
  1311. ls:\ cannot\ access\ \[aq]/mnt/pool/foo\[aq]:\ No\ such\ file\ or\ directory
  1312. \f[]
  1313. .fi
  1314. .PP
  1315. \f[C]mv\f[], when working across devices, is copying the source to
  1316. target and then removing the source.
  1317. Since the source \f[B]is\f[] the target in this case, depending on the
  1318. unlink policy, it will remove the just copied file and other files
  1319. across the branches.
  1320. .PP
  1321. If you want to move files to one drive just copy them there and use
  1322. mergerfs.dedup to clean up the old paths or manually remove them from
  1323. the branches directly.
  1324. .SS cached memory appears greater than it should be
  1325. .PP
  1326. Use the \f[C]direct_io\f[] option as described above.
  1327. Due to what mergerfs is doing there ends up being two caches of a file
  1328. under normal usage.
  1329. One from the underlying filesystem and one from mergerfs.
  1330. Enabling \f[C]direct_io\f[] removes the mergerfs cache.
  1331. This saves on memory but means the kernel needs to communicate with
  1332. mergerfs more often and can therefore result in slower speeds.
  1333. .PP
  1334. Since enabling \f[C]direct_io\f[] disables \f[C]mmap\f[] this is not an
  1335. ideal situation however write speeds should be increased.
  1336. .PP
  1337. If \f[C]direct_io\f[] is disabled it is probably a good idea to enable
  1338. \f[C]dropcacheonclose\f[] to minimize double caching.
  1339. .SS NFS clients returning ESTALE / Stale file handle
  1340. .PP
  1341. Be sure to use \f[C]noforget\f[] and \f[C]use_ino\f[] arguments.
  1342. .SS NFS clients don\[aq]t work
  1343. .PP
  1344. Some NFS clients appear to fail when a mergerfs mount is exported.
  1345. Kodi in particular seems to have issues.
  1346. .PP
  1347. Try enabling the \f[C]use_ino\f[] option.
  1348. Some have reported that it fixes the issue.
  1349. .SS rtorrent fails with ENODEV (No such device)
  1350. .PP
  1351. Be sure to turn off \f[C]direct_io\f[].
  1352. rtorrent and some other applications use
  1353. mmap (http://linux.die.net/man/2/mmap) to read and write to files and
  1354. offer no failback to traditional methods.
  1355. FUSE does not currently support mmap while using \f[C]direct_io\f[].
  1356. There may be a performance penalty on writes with \f[C]direct_io\f[] off
  1357. as well as the problem of double caching but it\[aq]s the only way to
  1358. get such applications to work.
  1359. If the performance loss is too high for other apps you can mount
  1360. mergerfs twice.
  1361. Once with \f[C]direct_io\f[] enabled and one without it.
  1362. Be sure to set \f[C]dropcacheonclose=true\f[] if not using
  1363. \f[C]direct_io\f[].
  1364. .SS rtorrent fails with files >= 4GiB
  1365. .PP
  1366. This is a kernel bug with mmap and FUSE on 32bit platforms.
  1367. A fix should become available for all LTS releases.
  1368. .PP
  1369. https://marc.info/?l=linux\-fsdevel&m=155550785230874&w=2
  1370. .SS Plex doesn\[aq]t work with mergerfs
  1371. .PP
  1372. It does.
  1373. If you\[aq]re trying to put Plex\[aq]s config / metadata on mergerfs you
  1374. have to leave \f[C]direct_io\f[] off because Plex is using sqlite which
  1375. apparently needs mmap.
  1376. mmap doesn\[aq]t work with \f[C]direct_io\f[].
  1377. To fix this place the data elsewhere or disable \f[C]direct_io\f[] (with
  1378. \f[C]dropcacheonclose=true\f[]).
  1379. .PP
  1380. If the issue is that scanning doesn\[aq]t seem to pick up media then be
  1381. sure to set \f[C]func.getattr=newest\f[] as mentioned above.
  1382. .SS mmap performance is really bad
  1383. .PP
  1384. There is a bug (https://lkml.org/lkml/2016/3/16/260) in caching which
  1385. affects overall performance of mmap through FUSE in Linux 4.x kernels.
  1386. It is fixed in 4.4.10 and 4.5.4 (https://lkml.org/lkml/2016/5/11/59).
  1387. .SS When a program tries to move or rename a file it fails
  1388. .PP
  1389. Please read the section above regarding rename & link (#rename--link).
  1390. .PP
  1391. The problem is that many applications do not properly handle
  1392. \f[C]EXDEV\f[] errors which \f[C]rename\f[] and \f[C]link\f[] may return
  1393. even though they are perfectly valid situations which do not indicate
  1394. actual drive or OS errors.
  1395. The error will only be returned by mergerfs if using a path preserving
  1396. policy as described in the policy section above.
  1397. If you do not care about path preservation simply change the mergerfs
  1398. policy to the non\-path preserving version.
  1399. For example: \f[C]\-o\ category.create=mfs\f[]
  1400. .PP
  1401. Ideally the offending software would be fixed and it is recommended that
  1402. if you run into this problem you contact the software\[aq]s author and
  1403. request proper handling of \f[C]EXDEV\f[] errors.
  1404. .SS Samba: Moving files / directories fails
  1405. .PP
  1406. Workaround: Copy the file/directory and then remove the original rather
  1407. than move.
  1408. .PP
  1409. This isn\[aq]t an issue with Samba but some SMB clients.
  1410. GVFS\-fuse v1.20.3 and prior (found in Ubuntu 14.04 among others) failed
  1411. to handle certain error codes correctly.
  1412. Particularly \f[B]STATUS_NOT_SAME_DEVICE\f[] which comes from the
  1413. \f[B]EXDEV\f[] which is returned by \f[B]rename\f[] when the call is
  1414. crossing mount points.
  1415. When a program gets an \f[B]EXDEV\f[] it needs to explicitly take an
  1416. alternate action to accomplish it\[aq]s goal.
  1417. In the case of \f[B]mv\f[] or similar it tries \f[B]rename\f[] and on
  1418. \f[B]EXDEV\f[] falls back to a manual copying of data between the two
  1419. locations and unlinking the source.
  1420. In these older versions of GVFS\-fuse if it received \f[B]EXDEV\f[] it
  1421. would translate that into \f[B]EIO\f[].
  1422. This would cause \f[B]mv\f[] or most any application attempting to move
  1423. files around on that SMB share to fail with a IO error.
  1424. .PP
  1425. GVFS\-fuse v1.22.0 (https://bugzilla.gnome.org/show_bug.cgi?id=734568)
  1426. and above fixed this issue but a large number of systems use the older
  1427. release.
  1428. On Ubuntu the version can be checked by issuing
  1429. \f[C]apt\-cache\ showpkg\ gvfs\-fuse\f[].
  1430. Most distros released in 2015 seem to have the updated release and will
  1431. work fine but older systems may not.
  1432. Upgrading gvfs\-fuse or the distro in general will address the problem.
  1433. .PP
  1434. In Apple\[aq]s MacOSX 10.9 they replaced Samba (client and server) with
  1435. their own product.
  1436. It appears their new client does not handle \f[B]EXDEV\f[] either and
  1437. responds similar to older release of gvfs on Linux.
  1438. .SS Trashing files occasionally fails
  1439. .PP
  1440. This is the same issue as with Samba.
  1441. \f[C]rename\f[] returns \f[C]EXDEV\f[] (in our case that will really
  1442. only happen with path preserving policies like \f[C]epmfs\f[]) and the
  1443. software doesn\[aq]t handle the situtation well.
  1444. This is unfortunately a common failure of software which moves files
  1445. around.
  1446. The standard indicates that an implementation \f[C]MAY\f[] choose to
  1447. support non\-user home directory trashing of files (which is a
  1448. \f[C]MUST\f[]).
  1449. The implementation \f[C]MAY\f[] also support "top directory trashes"
  1450. which many probably do.
  1451. .PP
  1452. To create a \f[C]$topdir/.Trash\f[] directory as defined in the standard
  1453. use the mergerfs\-tools (https://github.com/trapexit/mergerfs-tools)
  1454. tool \f[C]mergerfs.mktrash\f[].
  1455. .SS tar: Directory renamed before its status could be extracted
  1456. .PP
  1457. Make sure to use the \f[C]use_ino\f[] option.
  1458. .SS Supplemental user groups
  1459. .PP
  1460. Due to the overhead of
  1461. getgroups/setgroups (http://linux.die.net/man/2/setgroups) mergerfs
  1462. utilizes a cache.
  1463. This cache is opportunistic and per thread.
  1464. Each thread will query the supplemental groups for a user when that
  1465. particular thread needs to change credentials and will keep that data
  1466. for the lifetime of the thread.
  1467. This means that if a user is added to a group it may not be picked up
  1468. without the restart of mergerfs.
  1469. However, since the high level FUSE API\[aq]s (at least the standard
  1470. version) thread pool dynamically grows and shrinks it\[aq]s possible
  1471. that over time a thread will be killed and later a new thread with no
  1472. cache will start and query the new data.
  1473. .PP
  1474. The gid cache uses fixed storage to simplify the design and be
  1475. compatible with older systems which may not have C++11 compilers.
  1476. There is enough storage for 256 users\[aq] supplemental groups.
  1477. Each user is allowed upto 32 supplemental groups.
  1478. Linux >= 2.6.3 allows upto 65535 groups per user but most other *nixs
  1479. allow far less.
  1480. NFS allowing only 16.
  1481. The system does handle overflow gracefully.
  1482. If the user has more than 32 supplemental groups only the first 32 will
  1483. be used.
  1484. If more than 256 users are using the system when an uncached user is
  1485. found it will evict an existing user\[aq]s cache at random.
  1486. So long as there aren\[aq]t more than 256 active users this should be
  1487. fine.
  1488. If either value is too low for your needs you will have to modify
  1489. \f[C]gidcache.hpp\f[] to increase the values.
  1490. Note that doing so will increase the memory needed by each thread.
  1491. .SS mergerfs or libfuse crashing
  1492. .PP
  1493. \f[B]NOTE:\f[] as of mergerfs 2.22.0 it includes the most recent version
  1494. of libfuse (or requires libfuse\-2.9.7) so any crash should be reported.
  1495. For older releases continue reading...
  1496. .PP
  1497. If suddenly the mergerfs mount point disappears and
  1498. \f[C]Transport\ endpoint\ is\ not\ connected\f[] is returned when
  1499. attempting to perform actions within the mount directory \f[B]and\f[]
  1500. the version of libfuse (use \f[C]mergerfs\ \-v\f[] to find the version)
  1501. is older than \f[C]2.9.4\f[] its likely due to a bug in libfuse.
  1502. Affected versions of libfuse can be found in Debian Wheezy, Ubuntu
  1503. Precise and others.
  1504. .PP
  1505. In order to fix this please install newer versions of libfuse.
  1506. If using a Debian based distro (Debian,Ubuntu,Mint) you can likely just
  1507. install newer versions of
  1508. libfuse (https://packages.debian.org/unstable/libfuse2) and
  1509. fuse (https://packages.debian.org/unstable/fuse) from the repo of a
  1510. newer release.
  1511. .SS mergerfs appears to be crashing or exiting
  1512. .PP
  1513. There seems to be an issue with Linux version \f[C]4.9.0\f[] and above
  1514. in which an invalid message appears to be transmitted to libfuse (used
  1515. by mergerfs) causing it to exit.
  1516. No messages will be printed in any logs as its not a proper crash.
  1517. Debugging of the issue is still ongoing and can be followed via the
  1518. fuse\-devel
  1519. thread (https://sourceforge.net/p/fuse/mailman/message/35662577).
  1520. .SS mergerfs under heavy load and memory preasure leads to kernel panic
  1521. .PP
  1522. https://lkml.org/lkml/2016/9/14/527
  1523. .IP
  1524. .nf
  1525. \f[C]
  1526. [25192.515454]\ kernel\ BUG\ at\ /build/linux\-a2WvEb/linux\-4.4.0/mm/workingset.c:346!
  1527. [25192.517521]\ invalid\ opcode:\ 0000\ [#1]\ SMP
  1528. [25192.519602]\ Modules\ linked\ in:\ netconsole\ ip6t_REJECT\ nf_reject_ipv6\ ipt_REJECT\ nf_reject_ipv4\ configfs\ binfmt_misc\ veth\ bridge\ stp\ llc\ nf_conntrack_ipv6\ nf_defrag_ipv6\ xt_conntrack\ ip6table_filter\ ip6_tables\ xt_multiport\ iptable_filter\ ipt_MASQUERADE\ nf_nat_masquerade_ipv4\ xt_comment\ xt_nat\ iptable_nat\ nf_conntrack_ipv4\ nf_defrag_ipv4\ nf_nat_ipv4\ nf_nat\ nf_conntrack\ xt_CHECKSUM\ xt_tcpudp\ iptable_mangle\ ip_tables\ x_tables\ intel_rapl\ x86_pkg_temp_thermal\ intel_powerclamp\ eeepc_wmi\ asus_wmi\ coretemp\ sparse_keymap\ kvm_intel\ ppdev\ kvm\ irqbypass\ mei_me\ 8250_fintek\ input_leds\ serio_raw\ parport_pc\ tpm_infineon\ mei\ shpchp\ mac_hid\ parport\ lpc_ich\ autofs4\ drbg\ ansi_cprng\ dm_crypt\ algif_skcipher\ af_alg\ btrfs\ raid456\ async_raid6_recov\ async_memcpy\ async_pq\ async_xor\ async_tx\ xor\ raid6_pq\ libcrc32c\ raid0\ multipath\ linear\ raid10\ raid1\ i915\ crct10dif_pclmul\ crc32_pclmul\ aesni_intel\ i2c_algo_bit\ aes_x86_64\ drm_kms_helper\ lrw\ gf128mul\ glue_helper\ ablk_helper\ syscopyarea\ cryptd\ sysfillrect\ sysimgblt\ fb_sys_fops\ drm\ ahci\ r8169\ libahci\ mii\ wmi\ fjes\ video\ [last\ unloaded:\ netconsole]
  1529. [25192.540910]\ CPU:\ 2\ PID:\ 63\ Comm:\ kswapd0\ Not\ tainted\ 4.4.0\-36\-generic\ #55\-Ubuntu
  1530. [25192.543411]\ Hardware\ name:\ System\ manufacturer\ System\ Product\ Name/P8H67\-M\ PRO,\ BIOS\ 3904\ 04/27/2013
  1531. [25192.545840]\ task:\ ffff88040cae6040\ ti:\ ffff880407488000\ task.ti:\ ffff880407488000
  1532. [25192.548277]\ RIP:\ 0010:[<ffffffff811ba501>]\ \ [<ffffffff811ba501>]\ shadow_lru_isolate+0x181/0x190
  1533. [25192.550706]\ RSP:\ 0018:ffff88040748bbe0\ \ EFLAGS:\ 00010002
  1534. [25192.553127]\ RAX:\ 0000000000001c81\ RBX:\ ffff8802f91ee928\ RCX:\ ffff8802f91eeb38
  1535. [25192.555544]\ RDX:\ ffff8802f91ee938\ RSI:\ ffff8802f91ee928\ RDI:\ ffff8804099ba2c0
  1536. [25192.557914]\ RBP:\ ffff88040748bc08\ R08:\ 000000000001a7b6\ R09:\ 000000000000003f
  1537. [25192.560237]\ R10:\ 000000000001a750\ R11:\ 0000000000000000\ R12:\ ffff8804099ba2c0
  1538. [25192.562512]\ R13:\ ffff8803157e9680\ R14:\ ffff8803157e9668\ R15:\ ffff8804099ba2c8
  1539. [25192.564724]\ FS:\ \ 0000000000000000(0000)\ GS:ffff88041f280000(0000)\ knlGS:0000000000000000
  1540. [25192.566990]\ CS:\ \ 0010\ DS:\ 0000\ ES:\ 0000\ CR0:\ 0000000080050033
  1541. [25192.569201]\ CR2:\ 00007ffabb690000\ CR3:\ 0000000001e0a000\ CR4:\ 00000000000406e0
  1542. [25192.571419]\ Stack:
  1543. [25192.573550]\ \ ffff8804099ba2c0\ ffff88039e4f86f0\ ffff8802f91ee928\ ffff8804099ba2c8
  1544. [25192.575695]\ \ ffff88040748bd08\ ffff88040748bc58\ ffffffff811b99bf\ 0000000000000052
  1545. [25192.577814]\ \ 0000000000000000\ ffffffff811ba380\ 000000000000008a\ 0000000000000080
  1546. [25192.579947]\ Call\ Trace:
  1547. [25192.582022]\ \ [<ffffffff811b99bf>]\ __list_lru_walk_one.isra.3+0x8f/0x130
  1548. [25192.584137]\ \ [<ffffffff811ba380>]\ ?\ memcg_drain_all_list_lrus+0x190/0x190
  1549. [25192.586165]\ \ [<ffffffff811b9a83>]\ list_lru_walk_one+0x23/0x30
  1550. [25192.588145]\ \ [<ffffffff811ba544>]\ scan_shadow_nodes+0x34/0x50
  1551. [25192.590074]\ \ [<ffffffff811a0e9d>]\ shrink_slab.part.40+0x1ed/0x3d0
  1552. [25192.591985]\ \ [<ffffffff811a53da>]\ shrink_zone+0x2ca/0x2e0
  1553. [25192.593863]\ \ [<ffffffff811a64ce>]\ kswapd+0x51e/0x990
  1554. [25192.595737]\ \ [<ffffffff811a5fb0>]\ ?\ mem_cgroup_shrink_node_zone+0x1c0/0x1c0
  1555. [25192.597613]\ \ [<ffffffff810a0808>]\ kthread+0xd8/0xf0
  1556. [25192.599495]\ \ [<ffffffff810a0730>]\ ?\ kthread_create_on_node+0x1e0/0x1e0
  1557. [25192.601335]\ \ [<ffffffff8182e34f>]\ ret_from_fork+0x3f/0x70
  1558. [25192.603193]\ \ [<ffffffff810a0730>]\ ?\ kthread_create_on_node+0x1e0/0x1e0
  1559. \f[]
  1560. .fi
  1561. .PP
  1562. There is a bug in the kernel.
  1563. A work around appears to be turning off \f[C]splice\f[].
  1564. Don\[aq]t add the \f[C]splice_*\f[] arguments or add
  1565. \f[C]no_splice_write,no_splice_move,no_splice_read\f[].
  1566. This, however, is not guaranteed to work.
  1567. .SS rm: fts_read failed: No such file or directory
  1568. .PP
  1569. NOTE: This is only relevant to mergerfs versions at or below v2.25.x and
  1570. should not occur in more recent versions.
  1571. See the notes on \f[C]unlink\f[].
  1572. .PP
  1573. Not \f[I]really\f[] a bug.
  1574. The FUSE library will move files when asked to delete them as a way to
  1575. deal with certain edge cases and then later delete that file when its
  1576. clear the file is no longer needed.
  1577. This however can lead to two issues.
  1578. One is that these hidden files are noticed by \f[C]rm\ \-rf\f[] or
  1579. \f[C]find\f[] when scanning directories and they may try to remove them
  1580. and they might have disappeared already.
  1581. There is nothing \f[I]wrong\f[] about this happening but it can be
  1582. annoying.
  1583. The second issue is that a directory might not be able to removed on
  1584. account of the hidden file being still there.
  1585. .PP
  1586. Using the \f[B]hard_remove\f[] option will make it so these temporary
  1587. files are not used and files are deleted immedately.
  1588. That has a side effect however.
  1589. Files which are unlinked and then they are still used (in certain forms)
  1590. will result in an error (ENOENT).
  1591. .SH FAQ
  1592. .SS How well does mergerfs scale? Is it "production ready?"
  1593. .PP
  1594. Users have reported running mergerfs on everything from a Raspberry Pi
  1595. to dual socket Xeon systems with >20 cores.
  1596. I\[aq]m aware of at least a few companies which use mergerfs in
  1597. production.
  1598. Open Media Vault (https://www.openmediavault.org) includes mergerfs is
  1599. it\[aq]s sole solution for pooling drives.
  1600. .SS Can mergerfs be used with drives which already have data / are in
  1601. use?
  1602. .PP
  1603. Yes.
  1604. MergerFS is a proxy and does \f[B]NOT\f[] interfere with the normal form
  1605. or function of the drives / mounts / paths it manages.
  1606. .PP
  1607. MergerFS is \f[B]not\f[] a traditional filesystem.
  1608. MergerFS is \f[B]not\f[] RAID.
  1609. It does \f[B]not\f[] manipulate the data that passes through it.
  1610. It does \f[B]not\f[] shard data across drives.
  1611. It merely shards some \f[B]behavior\f[] and aggregates others.
  1612. .SS Can mergerfs be removed without affecting the data?
  1613. .PP
  1614. See the previous question\[aq]s answer.
  1615. .SS Do hard links work?
  1616. .PP
  1617. Yes.
  1618. You need to use \f[C]use_ino\f[] to support proper reporting of inodes.
  1619. .PP
  1620. What mergerfs does not do is fake hard links across branches.
  1621. Read the section "rename & link" for how it.
  1622. .SS Does mergerfs support CoW / copy\-on\-write?
  1623. .PP
  1624. Not in the sense of a filesystem like BTRFS or ZFS nor in the overlayfs
  1625. or aufs sense.
  1626. It does offer a
  1627. cow\-shell (http://manpages.ubuntu.com/manpages/bionic/man1/cow-shell.1.html)
  1628. like hard link breaking (copy to temp file then rename over original)
  1629. which can be useful when wanting to save space by hardlinking duplicate
  1630. files but wish to treat each name as if it were a unique and separate
  1631. file.
  1632. .SS Why can\[aq]t I see my files / directories?
  1633. .PP
  1634. It\[aq]s almost always a permissions issue.
  1635. Unlike mhddfs, which runs as root and attempts to access content as
  1636. such, mergerfs always changes it\[aq]s credentials to that of the
  1637. caller.
  1638. This means that if the user does not have access to a file or directory
  1639. than neither will mergerfs.
  1640. However, because mergerfs is creating a union of paths it may be able to
  1641. read some files and directories on one drive but not another resulting
  1642. in an incomplete set.
  1643. .PP
  1644. Whenever you run into a split permission issue (seeing some but not all
  1645. files) try using
  1646. mergerfs.fsck (https://github.com/trapexit/mergerfs-tools) tool to check
  1647. for and fix the mismatch.
  1648. If you aren\[aq]t seeing anything at all be sure that the basic
  1649. permissions are correct.
  1650. The user and group values are correct and that directories have their
  1651. executable bit set.
  1652. A common mistake by users new to Linux is to \f[C]chmod\ \-R\ 644\f[]
  1653. when they should have \f[C]chmod\ \-R\ u=rwX,go=rX\f[].
  1654. .PP
  1655. If using a network filesystem such as NFS, SMB, CIFS (Samba) be sure to
  1656. pay close attention to anything regarding permissioning and users.
  1657. Root squashing and user translation for instance has bitten a few
  1658. mergerfs users.
  1659. Some of these also affect the use of mergerfs from container platforms
  1660. such as Docker.
  1661. .SS Why is only one drive being used?
  1662. .PP
  1663. Are you using a path preserving policy?
  1664. The default policy for file creation is \f[C]epmfs\f[].
  1665. That means only the drives with the path preexisting will be considered
  1666. when creating a file.
  1667. If you don\[aq]t care about where files and directories are created you
  1668. likely shouldn\[aq]t be using a path preserving policy and instead
  1669. something like \f[C]mfs\f[].
  1670. .PP
  1671. This can be especially apparent when filling an empty pool from an
  1672. external source.
  1673. If you do want path preservation you\[aq]ll need to perform the manual
  1674. act of creating paths on the drives you want the data to land on before
  1675. transfering your data.
  1676. Setting \f[C]func.mkdir=epall\f[] can simplify managing path
  1677. perservation for \f[C]create\f[].
  1678. .SS Why was libfuse embedded into mergerfs?
  1679. .IP "1." 3
  1680. A significant number of users use mergerfs on distros with old versions
  1681. of libfuse which have serious bugs.
  1682. Requiring updated versions of libfuse on those distros isn\[aq]t
  1683. pratical (no package offered, user inexperience, etc.).
  1684. The only practical way to provide a stable runtime on those systems was
  1685. to "vendor" / embed the library into the project.
  1686. .IP "2." 3
  1687. mergerfs was written to use the high level API.
  1688. There are a number of limitations in the HLAPI that make certain
  1689. features difficult or impossible to implement.
  1690. While some of these features could be patched into newer versions of
  1691. libfuse without breaking the public API some of them would require hacky
  1692. code to provide backwards compatibility.
  1693. While it may still be worth working with upstream to address these
  1694. issues in future versions, since the library needs to be vendored for
  1695. stability and compatibility reasons it is preferable / easier to modify
  1696. the API.
  1697. Longer term the plan is to rewrite mergerfs to use the low level API.
  1698. .SS Why did support for system libfuse get removed?
  1699. .PP
  1700. See above first.
  1701. .PP
  1702. If/when mergerfs is rewritten to use the low\-level API then it\[aq]ll
  1703. be plausible to support system libfuse but till then its simply too much
  1704. work to manage the differences across the versions.
  1705. .SS Why use mergerfs over mhddfs?
  1706. .PP
  1707. mhddfs is no longer maintained and has some known stability and security
  1708. issues (see below).
  1709. MergerFS provides a superset of mhddfs\[aq] features and should offer
  1710. the same or maybe better performance.
  1711. .PP
  1712. Below is an example of mhddfs and mergerfs setup to work similarly.
  1713. .PP
  1714. \f[C]mhddfs\ \-o\ mlimit=4G,allow_other\ /mnt/drive1,/mnt/drive2\ /mnt/pool\f[]
  1715. .PP
  1716. \f[C]mergerfs\ \-o\ minfreespace=4G,allow_other,category.create=ff\ /mnt/drive1:/mnt/drive2\ /mnt/pool\f[]
  1717. .SS Why use mergerfs over aufs?
  1718. .PP
  1719. aufs is mostly abandoned and no longer available in many distros.
  1720. .PP
  1721. While aufs can offer better peak performance mergerfs provides more
  1722. configurability and is generally easier to use.
  1723. mergerfs however does not offer the overlay / copy\-on\-write (CoW)
  1724. features which aufs and overlayfs have.
  1725. .SS Why use mergerfs over unionfs?
  1726. .PP
  1727. UnionFS is more like aufs then mergerfs in that it offers overlay / CoW
  1728. features.
  1729. If you\[aq]re just looking to create a union of drives and want
  1730. flexibility in file/directory placement then mergerfs offers that
  1731. whereas unionfs is more for overlaying RW filesystems over RO ones.
  1732. .SS Why use mergerfs over LVM/ZFS/BTRFS/RAID0 drive concatenation /
  1733. striping?
  1734. .PP
  1735. With simple JBOD / drive concatenation / stripping / RAID0 a single
  1736. drive failure will result in full pool failure.
  1737. mergerfs performs a similar behavior without the possibility of
  1738. catastrophic failure and the difficulties in recovery.
  1739. Drives may fail however all other data will continue to be accessable.
  1740. .PP
  1741. When combined with something like SnapRaid (http://www.snapraid.it)
  1742. and/or an offsite backup solution you can have the flexibilty of JBOD
  1743. without the single point of failure.
  1744. .SS Why use mergerfs over ZFS?
  1745. .PP
  1746. MergerFS is not intended to be a replacement for ZFS.
  1747. MergerFS is intended to provide flexible pooling of arbitrary drives
  1748. (local or remote), of arbitrary sizes, and arbitrary filesystems.
  1749. For \f[C]write\ once,\ read\ many\f[] usecases such as bulk media
  1750. storage.
  1751. Where data integrity and backup is managed in other ways.
  1752. In that situation ZFS can introduce major maintance and cost burdens as
  1753. described
  1754. here (http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html).
  1755. .SS Can drives be written to directly? Outside of mergerfs while pooled?
  1756. .PP
  1757. Yes, however its not recommended to use the same file from within the
  1758. pool and from without at the same time.
  1759. Especially if using caching of any kind (cache.entry, cache.attr,
  1760. ac_attr_timeout, cache.negative_entry, auto_cache, kernel_cache).
  1761. .SS Why do I get an "out of space" / "no space left on device" / ENOSPC
  1762. error even though there appears to be lots of space available?
  1763. .PP
  1764. First make sure you\[aq]ve read the sections above about policies, path
  1765. preservation, branch filtering, and the options \f[B]minfreespace\f[],
  1766. \f[B]moveonenospc\f[], \f[B]statfs\f[], and \f[B]statfs_ignore\f[].
  1767. .PP
  1768. mergerfs is simply presenting a union of the content within multiple
  1769. branches.
  1770. The reported free space is an aggregate of space available within the
  1771. pool (behavior modified by \f[B]statfs\f[] and \f[B]statfs_ignore\f[]).
  1772. It does not represent a contiguous space.
  1773. In the same way that read\-only filesystems, those with quotas, or
  1774. reserved space report the full theoretical space available.
  1775. .PP
  1776. Due to path preservation, branch tagging, read\-only status, and
  1777. \f[B]minfreespace\f[] settings it is perfectly valid that
  1778. \f[C]ENOSPC\f[] / "out of space" / "no space left on device" be
  1779. returned.
  1780. It is doing what was asked of it: filtering possible branches due to
  1781. those settings.
  1782. Only one error can be returned and if one of the reasons for filtering a
  1783. branch was \f[B]minfreespace\f[] then it will be returned as such.
  1784. \f[B]moveonenospc\f[] is only relevant to writing a file which is too
  1785. large for the drive its currently on.
  1786. .PP
  1787. It is also possible that the filesystem selected has run out of inodes.
  1788. Use \f[C]df\ \-i\f[] to list the total and available inodes per
  1789. filesystem.
  1790. .PP
  1791. If you don\[aq]t care about path preservation then simply change the
  1792. \f[C]create\f[] policy to one which isn\[aq]t.
  1793. \f[C]mfs\f[] is probably what most are looking for.
  1794. The reason its not default is because it was originally set to
  1795. \f[C]epmfs\f[] and changing it now would change people\[aq]s setup.
  1796. Such a setting change will likely occur in mergerfs 3.
  1797. .SS Can mergerfs mounts be exported over NFS?
  1798. .PP
  1799. Yes.
  1800. Due to current usage of libfuse by mergerfs and how NFS interacts with
  1801. it it is necessary to add \f[C]noforget\f[] to mergerfs options to keep
  1802. from getting "stale file handle" errors.
  1803. .PP
  1804. Some clients (Kodi) have issues in which the contents of the NFS mount
  1805. will not be presented but users have found that enabling the
  1806. \f[C]use_ino\f[] option often fixes that problem.
  1807. .SS Can mergerfs mounts be exported over Samba / SMB?
  1808. .PP
  1809. Yes.
  1810. While some users have reported problems it appears to always be related
  1811. to how Samba is setup in relation to permissions.
  1812. .SS How are inodes calculated?
  1813. .PP
  1814. mergerfs\-inode = (original\-inode | (device\-id << 32))
  1815. .PP
  1816. While \f[C]ino_t\f[] is 64 bits only a few filesystems use more than 32.
  1817. Similarly, while \f[C]dev_t\f[] is also 64 bits it was traditionally 16
  1818. bits.
  1819. Bitwise or\[aq]ing them together should work most of the time.
  1820. While totally unique inodes are preferred the overhead which would be
  1821. needed does not seem to outweighted by the benefits.
  1822. .PP
  1823. While atypical, yes, inodes can be reused and not refer to the same
  1824. file.
  1825. The internal id used to reference a file in FUSE is different from the
  1826. inode value presented.
  1827. The former is the \f[C]nodeid\f[] and is actually a tuple of
  1828. (nodeid,generation).
  1829. That tuple is not user facing.
  1830. The inode is merely metadata passed through the kernel and found using
  1831. the \f[C]stat\f[] family of calls or \f[C]readdir\f[].
  1832. .PP
  1833. From FUSE docs regarding \f[C]use_ino\f[]:
  1834. .IP
  1835. .nf
  1836. \f[C]
  1837. Honor\ the\ st_ino\ field\ in\ the\ functions\ getattr()\ and
  1838. fill_dir().\ This\ value\ is\ used\ to\ fill\ in\ the\ st_ino\ field
  1839. in\ the\ stat(2),\ lstat(2),\ fstat(2)\ functions\ and\ the\ d_ino
  1840. field\ in\ the\ readdir(2)\ function.\ The\ filesystem\ does\ not
  1841. have\ to\ guarantee\ uniqueness,\ however\ some\ applications
  1842. rely\ on\ this\ value\ being\ unique\ for\ the\ whole\ filesystem.
  1843. Note\ that\ this\ does\ *not*\ affect\ the\ inode\ that\ libfuse
  1844. and\ the\ kernel\ use\ internally\ (also\ called\ the\ "nodeid").
  1845. \f[]
  1846. .fi
  1847. .SS I notice massive slowdowns of writes over NFS
  1848. .PP
  1849. Due to how NFS works and interacts with FUSE when not using
  1850. \f[C]direct_io\f[] its possible that a getxattr for
  1851. \f[C]security.capability\f[] will be issued prior to any write.
  1852. This will usually result in a massive slowdown for writes.
  1853. Using \f[C]direct_io\f[] will keep this from happening (and generally
  1854. good to enable unless you need the features it disables) but the
  1855. \f[C]security_capability\f[] option can also help by short circuiting
  1856. the call and returning \f[C]ENOATTR\f[].
  1857. .PP
  1858. You could also set \f[C]xattr\f[] to \f[C]noattr\f[] or \f[C]nosys\f[]
  1859. to short circuit or stop all xattr requests.
  1860. .SS What are these .fuse_hidden files?
  1861. .PP
  1862. NOTE: mergerfs >= 2.26.0 will not have these temporary files.
  1863. See the notes on \f[C]unlink\f[].
  1864. .PP
  1865. When not using \f[B]hard_remove\f[] libfuse will create
  1866. \&.fuse_hiddenXXXXXXXX files when an opened file is unlinked.
  1867. This is to simplify "use after unlink" usecases.
  1868. There is a possibility these files end up being picked up by software
  1869. scanning directories and not ignoring hidden files.
  1870. This is rarely a problem but a solution is in the works.
  1871. .PP
  1872. The files are cleaned up once the file is finally closed.
  1873. Only if mergerfs crashes or is killed would they be left around.
  1874. They are safe to remove as they are already unlinked files.
  1875. .SS It\[aq]s mentioned that there are some security issues with mhddfs.
  1876. What are they? How does mergerfs address them?
  1877. .PP
  1878. mhddfs (https://github.com/trapexit/mhddfs) manages running as
  1879. \f[B]root\f[] by calling
  1880. getuid() (https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
  1881. and if it returns \f[B]0\f[] then it will
  1882. chown (http://linux.die.net/man/1/chown) the file.
  1883. Not only is that a race condition but it doesn\[aq]t handle other
  1884. situations.
  1885. Rather than attempting to simulate POSIX ACL behavior the proper way to
  1886. manage this is to use seteuid (http://linux.die.net/man/2/seteuid) and
  1887. setegid (http://linux.die.net/man/2/setegid), in effect becoming the
  1888. user making the original call, and perform the action as them.
  1889. This is what mergerfs does and why mergerfs should always run as root.
  1890. .PP
  1891. In Linux setreuid syscalls apply only to the thread.
  1892. GLIBC hides this away by using realtime signals to inform all threads to
  1893. change credentials.
  1894. Taking after \f[B]Samba\f[], mergerfs uses
  1895. \f[B]syscall(SYS_setreuid,...)\f[] to set the callers credentials for
  1896. that thread only.
  1897. Jumping back to \f[B]root\f[] as necessary should escalated privileges
  1898. be needed (for instance: to clone paths between drives).
  1899. .PP
  1900. For non\-Linux systems mergerfs uses a read\-write lock and changes
  1901. credentials only when necessary.
  1902. If multiple threads are to be user X then only the first one will need
  1903. to change the processes credentials.
  1904. So long as the other threads need to be user X they will take a readlock
  1905. allowing multiple threads to share the credentials.
  1906. Once a request comes in to run as user Y that thread will attempt a
  1907. write lock and change to Y\[aq]s credentials when it can.
  1908. If the ability to give writers priority is supported then that flag will
  1909. be used so threads trying to change credentials don\[aq]t starve.
  1910. This isn\[aq]t the best solution but should work reasonably well
  1911. assuming there are few users.
  1912. .SH PERFORMANCE TWEAKING
  1913. .IP \[bu] 2
  1914. try adding (or removing) \f[C]direct_io\f[]
  1915. .IP \[bu] 2
  1916. try adding (or removing) \f[C]auto_cache\f[]
  1917. .IP \[bu] 2
  1918. try adding (or removing) \f[C]kernel_cache\f[]
  1919. .IP \[bu] 2
  1920. try adding (or removing) \f[C]splice_move\f[], \f[C]splice_read\f[], and
  1921. \f[C]splice_write\f[]
  1922. .IP \[bu] 2
  1923. try increasing cache timeouts \f[C]cache.attr\f[], \f[C]cache.entry\f[],
  1924. \f[C]cache.negative_entry\f[]
  1925. .IP \[bu] 2
  1926. try changing the number of worker threads
  1927. .IP \[bu] 2
  1928. try disabling \f[C]security_capability\f[] or \f[C]xattr\f[]
  1929. .IP \[bu] 2
  1930. test theoretical performance using \f[C]nullrw\f[] or mounting a ram
  1931. disk
  1932. .IP \[bu] 2
  1933. use \f[C]symlinkify\f[] if your data is largely static and you need
  1934. native speed reads
  1935. .IP \[bu] 2
  1936. use lvm and lvm cache to place a SSD in front of your HDDs (howto
  1937. coming)
  1938. .SH SUPPORT
  1939. .PP
  1940. Filesystems are very complex and difficult to debug.
  1941. mergerfs, while being just a proxy of sorts, is also very difficult to
  1942. debug given the large number of possible settings it can have itself and
  1943. the massive number of environments it can run in.
  1944. When reporting on a suspected issue \f[B]please, please\f[] include as
  1945. much of the below information as possible otherwise it will be difficult
  1946. or impossible to diagnose.
  1947. Also please make sure to read all of the above documentation as it
  1948. includes nearly every known system or user issue previously encountered.
  1949. .SS Information to include in bug reports
  1950. .IP \[bu] 2
  1951. Version of mergerfs: \f[C]mergerfs\ \-V\f[]
  1952. .IP \[bu] 2
  1953. mergerfs settings: from \f[C]/etc/fstab\f[] or command line execution
  1954. .IP \[bu] 2
  1955. Version of Linux: \f[C]uname\ \-a\f[]
  1956. .IP \[bu] 2
  1957. Versions of any additional software being used
  1958. .IP \[bu] 2
  1959. List of drives, their filesystems, and sizes (before and after issue):
  1960. \f[C]df\ \-h\f[]
  1961. .IP \[bu] 2
  1962. A \f[C]strace\f[] of the app having problems:
  1963. .IP \[bu] 2
  1964. \f[C]strace\ \-f\ \-o\ /tmp/app.strace.txt\ <cmd>\f[]
  1965. .IP \[bu] 2
  1966. A \f[C]strace\f[] of mergerfs while the program is trying to do whatever
  1967. it\[aq]s failing to do:
  1968. .IP \[bu] 2
  1969. \f[C]strace\ \-f\ \-p\ <mergerfsPID>\ \-o\ /tmp/mergerfs.strace.txt\f[]
  1970. .IP \[bu] 2
  1971. \f[B]Precise\f[] directions on replicating the issue.
  1972. Do not leave \f[B]anything\f[] out.
  1973. .IP \[bu] 2
  1974. Try to recreate the problem in the simplist way using standard programs.
  1975. .SS Contact / Issue submission
  1976. .IP \[bu] 2
  1977. github.com: https://github.com/trapexit/mergerfs/issues
  1978. .IP \[bu] 2
  1979. email: trapexit\@spawn.link
  1980. .IP \[bu] 2
  1981. twitter: https://twitter.com/_trapexit
  1982. .IP \[bu] 2
  1983. reddit: https://www.reddit.com/user/trapexit
  1984. .IP \[bu] 2
  1985. discord: https://discord.gg/MpAr69V
  1986. .SS Support development
  1987. .PP
  1988. This software is free to use and released under a very liberal license.
  1989. That said if you like this software and would like to support its
  1990. development donations are welcome.
  1991. .IP \[bu] 2
  1992. PayPal: trapexit\@spawn.link
  1993. .IP \[bu] 2
  1994. Patreon: https://www.patreon.com/trapexit
  1995. .IP \[bu] 2
  1996. SubscribeStar: https://www.subscribestar.com/trapexit
  1997. .IP \[bu] 2
  1998. Bitcoin (BTC): 12CdMhEPQVmjz3SSynkAEuD5q9JmhTDCZA
  1999. .IP \[bu] 2
  2000. Bitcoin Cash (BCH): 1AjPqZZhu7GVEs6JFPjHmtsvmDL4euzMzp
  2001. .IP \[bu] 2
  2002. Ethereum (ETH): 0x09A166B11fCC127324C7fc5f1B572255b3046E94
  2003. .IP \[bu] 2
  2004. Litecoin (LTC): LXAsq6yc6zYU3EbcqyWtHBrH1Ypx4GjUjm
  2005. .IP \[bu] 2
  2006. Ripple (XRP): rNACR2hqGjpbHuCKwmJ4pDpd2zRfuRATcE
  2007. .SH LINKS
  2008. .IP \[bu] 2
  2009. https://spawn.link
  2010. .IP \[bu] 2
  2011. https://github.com/trapexit/mergerfs
  2012. .IP \[bu] 2
  2013. https://github.com/trapexit/mergerfs\-tools
  2014. .IP \[bu] 2
  2015. https://github.com/trapexit/scorch
  2016. .IP \[bu] 2
  2017. https://github.com/trapexit/bbf
  2018. .IP \[bu] 2
  2019. https://github.com/trapexit/backup\-and\-recovery\-howtos
  2020. .IP \[bu] 2
  2021. https://discord.gg/MpAr69V
  2022. .SH AUTHORS
  2023. Antonio SJ Musumeci <trapexit@spawn.link>.