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.

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