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.

2080 lines
79 KiB

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