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.

2792 lines
103 KiB

8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
5 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
6 years ago
6 years ago
6 years ago
6 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
8 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
8 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
9 years ago
9 years ago
6 years ago
9 years ago
9 years ago
9 years ago
9 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
9 years ago
5 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
  1. .\"t
  2. .\" Automatically generated by Pandoc 2.5
  3. .\"
  4. .TH "mergerfs" "1" "2020\-08\-30" "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[R] 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[R], \f[B]unionfs\f[R], and
  18. \f[B]aufs\f[R].
  19. .SH FEATURES
  20. .IP \[bu] 2
  21. Runs in userspace (FUSE)
  22. .IP \[bu] 2
  23. Configurable behaviors / file placement
  24. .IP \[bu] 2
  25. Support for extended attributes (xattrs)
  26. .IP \[bu] 2
  27. Support for file attributes (chattr)
  28. .IP \[bu] 2
  29. Runtime configurable (via xattrs)
  30. .IP \[bu] 2
  31. Safe to run as root
  32. .IP \[bu] 2
  33. Opportunistic credential caching
  34. .IP \[bu] 2
  35. Works with heterogeneous filesystem types
  36. .IP \[bu] 2
  37. Handling of writes to full drives (transparently move file to drive with
  38. capacity)
  39. .IP \[bu] 2
  40. Handles pool of read\-only and read/write drives
  41. .IP \[bu] 2
  42. Can turn read\-only files into symlinks to underlying file
  43. .IP \[bu] 2
  44. Hard link copy\-on\-write / CoW
  45. .IP \[bu] 2
  46. Support for POSIX ACLs
  47. .SH HOW IT WORKS
  48. .PP
  49. mergerfs logically merges multiple paths together.
  50. Think a union of sets.
  51. The file/s or directory/s acted on or presented through mergerfs are
  52. based on the policy chosen for that particular action.
  53. Read more about policies below.
  54. .IP
  55. .nf
  56. \f[C]
  57. A + B = C
  58. /disk1 /disk2 /merged
  59. | | |
  60. +\-\- /dir1 +\-\- /dir1 +\-\- /dir1
  61. | | | | | |
  62. | +\-\- file1 | +\-\- file2 | +\-\- file1
  63. | | +\-\- file3 | +\-\- file2
  64. +\-\- /dir2 | | +\-\- file3
  65. | | +\-\- /dir3 |
  66. | +\-\- file4 | +\-\- /dir2
  67. | +\-\- file5 | |
  68. +\-\- file6 | +\-\- file4
  69. |
  70. +\-\- /dir3
  71. | |
  72. | +\-\- file5
  73. |
  74. +\-\- file6
  75. \f[R]
  76. .fi
  77. .PP
  78. mergerfs does \f[B]NOT\f[R] support the copy\-on\-write (CoW) or
  79. whiteout behaviors found in \f[B]aufs\f[R] and \f[B]overlayfs\f[R].
  80. You can \f[B]not\f[R] mount a read\-only filesystem and write to it.
  81. However, mergerfs will ignore read\-only drives when creating new files
  82. so you can mix read\-write and read\-only drives.
  83. It also does \f[B]NOT\f[R] split data across drives.
  84. It is not RAID0 / striping.
  85. It is simply a union of other filesystems.
  86. .SH TERMINOLOGY
  87. .IP \[bu] 2
  88. branch: A base path used in the pool.
  89. .IP \[bu] 2
  90. pool: The mergerfs mount.
  91. The union of the branches.
  92. .IP \[bu] 2
  93. relative path: The path in the pool relative to the branch and mount.
  94. .IP \[bu] 2
  95. function: A filesystem call (open, unlink, create, getattr, rmdir, etc.)
  96. .IP \[bu] 2
  97. category: A collection of functions based on basic behavior (action,
  98. create, search).
  99. .IP \[bu] 2
  100. policy: The algorithm used to select a file when performing a function.
  101. .IP \[bu] 2
  102. path preservation: Aspect of some policies which includes checking the
  103. path for which a file would be created.
  104. .SH BASIC SETUP
  105. .PP
  106. If you don\[cq]t already know that you have a special use case then just
  107. start with one of the following option sets.
  108. .SS You need \f[C]mmap\f[R] (used by rtorrent and many sqlite3 base software)
  109. .PP
  110. \f[C]allow_other,use_ino,cache.files=partial,dropcacheonclose=true,category.create=mfs\f[R]
  111. .SS You don\[cq]t need \f[C]mmap\f[R]
  112. .PP
  113. \f[C]allow_other,use_ino,cache.files=off,dropcacheonclose=true,category.create=mfs\f[R]
  114. .PP
  115. See the mergerfs wiki for real world
  116. deployments (https://github.com/trapexit/mergerfs/wiki/Real-World-Deployments)
  117. for comparisons / ideas.
  118. .SH OPTIONS
  119. .PP
  120. These options are the same regardless you use them with the
  121. \f[C]mergerfs\f[R] commandline program, used in fstab, or in a config
  122. file.
  123. .SS mount options
  124. .IP \[bu] 2
  125. \f[B]config\f[R]: Path to a config file.
  126. Same arguments as below in key=val / ini style format.
  127. .IP \[bu] 2
  128. \f[B]branches\f[R]: Colon delimited list of branches.
  129. .IP \[bu] 2
  130. \f[B]allow_other\f[R]: A libfuse option which allows users besides the
  131. one which ran mergerfs to see the filesystem.
  132. This is required for most use\-cases.
  133. .IP \[bu] 2
  134. \f[B]minfreespace=SIZE\f[R]: The minimum space value used for creation
  135. policies.
  136. Can be overridden by branch specific option.
  137. Understands `K', `M', and `G' to represent kilobyte, megabyte, and
  138. gigabyte respectively.
  139. (default: 4G)
  140. .IP \[bu] 2
  141. \f[B]moveonenospc=BOOL|POLICY\f[R]: When enabled if a \f[B]write\f[R]
  142. fails with \f[B]ENOSPC\f[R] (no space left on device) or
  143. \f[B]EDQUOT\f[R] (disk quota exceeded) the policy selected will run to
  144. find a new location for the file.
  145. An attempt to move the file to that branch will occur (keeping all
  146. metadata possible) and if successful the original is unlinked and the
  147. write retried.
  148. (default: false, true = mfs)
  149. .IP \[bu] 2
  150. \f[B]use_ino\f[R]: Causes mergerfs to supply file/directory inodes
  151. rather than libfuse.
  152. While not a default it is recommended it be enabled so that linked files
  153. share the same inode value.
  154. .IP \[bu] 2
  155. \f[B]inodecalc=passthrough|path\-hash|devino\-hash|hybrid\-hash\f[R]:
  156. Selects the inode calculation algorithm.
  157. (default: hybrid\-hash)
  158. .IP \[bu] 2
  159. \f[B]dropcacheonclose=BOOL\f[R]: When a file is requested to be closed
  160. call \f[C]posix_fadvise\f[R] on it first to instruct the kernel that we
  161. no longer need the data and it can drop its cache.
  162. Recommended when \f[B]cache.files=partial|full|auto\-full\f[R] to limit
  163. double caching.
  164. (default: false)
  165. .IP \[bu] 2
  166. \f[B]symlinkify=BOOL\f[R]: When enabled and a file is not writable and
  167. its mtime or ctime is older than \f[B]symlinkify_timeout\f[R] files will
  168. be reported as symlinks to the original files.
  169. Please read more below before using.
  170. (default: false)
  171. .IP \[bu] 2
  172. \f[B]symlinkify_timeout=UINT\f[R]: Time to wait, in seconds, to activate
  173. the \f[B]symlinkify\f[R] behavior.
  174. (default: 3600)
  175. .IP \[bu] 2
  176. \f[B]nullrw=BOOL\f[R]: Turns reads and writes into no\-ops.
  177. The request will succeed but do nothing.
  178. Useful for benchmarking mergerfs.
  179. (default: false)
  180. .IP \[bu] 2
  181. \f[B]ignorepponrename=BOOL\f[R]: Ignore path preserving on rename.
  182. Typically rename and link act differently depending on the policy of
  183. \f[C]create\f[R] (read below).
  184. Enabling this will cause rename and link to always use the non\-path
  185. preserving behavior.
  186. This means files, when renamed or linked, will stay on the same drive.
  187. (default: false)
  188. .IP \[bu] 2
  189. \f[B]security_capability=BOOL\f[R]: If false return ENOATTR when xattr
  190. security.capability is queried.
  191. (default: true)
  192. .IP \[bu] 2
  193. \f[B]xattr=passthrough|noattr|nosys\f[R]: Runtime control of xattrs.
  194. Default is to passthrough xattr requests.
  195. `noattr' will short circuit as if nothing exists.
  196. `nosys' will respond with ENOSYS as if xattrs are not supported or
  197. disabled.
  198. (default: passthrough)
  199. .IP \[bu] 2
  200. \f[B]link_cow=BOOL\f[R]: When enabled if a regular file is opened which
  201. has a link count > 1 it will copy the file to a temporary file and
  202. rename over the original.
  203. Breaking the link and providing a basic copy\-on\-write function similar
  204. to cow\-shell.
  205. (default: false)
  206. .IP \[bu] 2
  207. \f[B]statfs=base|full\f[R]: Controls how statfs works.
  208. `base' means it will always use all branches in statfs calculations.
  209. `full' is in effect path preserving and only includes drives where the
  210. path exists.
  211. (default: base)
  212. .IP \[bu] 2
  213. \f[B]statfs_ignore=none|ro|nc\f[R]: `ro' will cause statfs calculations
  214. to ignore available space for branches mounted or tagged as `read\-only'
  215. or `no create'.
  216. `nc' will ignore available space for branches tagged as `no create'.
  217. (default: none)
  218. .IP \[bu] 2
  219. \f[B]nfsopenhack=off|git|all\f[R]: A workaround for exporting mergerfs
  220. over NFS where there are issues with creating files for write while
  221. setting the mode to read\-only.
  222. (default: off)
  223. .IP \[bu] 2
  224. \f[B]posix_acl=BOOL\f[R]: Enable POSIX ACL support (if supported by
  225. kernel and underlying filesystem).
  226. (default: false)
  227. .IP \[bu] 2
  228. \f[B]async_read=BOOL\f[R]: Perform reads asynchronously.
  229. If disabled or unavailable the kernel will ensure there is at most one
  230. pending read request per file handle and will attempt to order requests
  231. by offset.
  232. (default: true)
  233. .IP \[bu] 2
  234. \f[B]fuse_msg_size=UINT\f[R]: Set the max number of pages per FUSE
  235. message.
  236. Only available on Linux >= 4.20 and ignored otherwise.
  237. (min: 1; max: 256; default: 256)
  238. .IP \[bu] 2
  239. \f[B]threads=INT\f[R]: Number of threads to use in multithreaded mode.
  240. When set to zero it will attempt to discover and use the number of
  241. logical cores.
  242. If the lookup fails it will fall back to using 4.
  243. If the thread count is set negative it will look up the number of cores
  244. then divide by the absolute value.
  245. ie.
  246. threads=\-2 on an 8 core machine will result in 8 / 2 = 4 threads.
  247. There will always be at least 1 thread.
  248. NOTE: higher number of threads increases parallelism but usually
  249. decreases throughput.
  250. (default: 0)
  251. .IP \[bu] 2
  252. \f[B]fsname=STR\f[R]: Sets the name of the filesystem as seen in
  253. \f[B]mount\f[R], \f[B]df\f[R], etc.
  254. Defaults to a list of the source paths concatenated together with the
  255. longest common prefix removed.
  256. .IP \[bu] 2
  257. \f[B]func.FUNC=POLICY\f[R]: Sets the specific FUSE function\[cq]s
  258. policy.
  259. See below for the list of value types.
  260. Example: \f[B]func.getattr=newest\f[R]
  261. .IP \[bu] 2
  262. \f[B]category.action=POLICY\f[R]: Sets policy of all FUSE functions in
  263. the action category.
  264. (default: epall)
  265. .IP \[bu] 2
  266. \f[B]category.create=POLICY\f[R]: Sets policy of all FUSE functions in
  267. the create category.
  268. (default: epmfs)
  269. .IP \[bu] 2
  270. \f[B]category.search=POLICY\f[R]: Sets policy of all FUSE functions in
  271. the search category.
  272. (default: ff)
  273. .IP \[bu] 2
  274. \f[B]cache.open=UINT\f[R]: `open' policy cache timeout in seconds.
  275. (default: 0)
  276. .IP \[bu] 2
  277. \f[B]cache.statfs=UINT\f[R]: `statfs' cache timeout in seconds.
  278. (default: 0)
  279. .IP \[bu] 2
  280. \f[B]cache.attr=UINT\f[R]: File attribute cache timeout in seconds.
  281. (default: 1)
  282. .IP \[bu] 2
  283. \f[B]cache.entry=UINT\f[R]: File name lookup cache timeout in seconds.
  284. (default: 1)
  285. .IP \[bu] 2
  286. \f[B]cache.negative_entry=UINT\f[R]: Negative file name lookup cache
  287. timeout in seconds.
  288. (default: 0)
  289. .IP \[bu] 2
  290. \f[B]cache.files=libfuse|off|partial|full|auto\-full\f[R]: File page
  291. caching mode (default: libfuse)
  292. .IP \[bu] 2
  293. \f[B]cache.writeback=BOOL\f[R]: Enable kernel writeback caching
  294. (default: false)
  295. .IP \[bu] 2
  296. \f[B]cache.symlinks=BOOL\f[R]: Cache symlinks (if supported by kernel)
  297. (default: false)
  298. .IP \[bu] 2
  299. \f[B]cache.readdir=BOOL\f[R]: Cache readdir (if supported by kernel)
  300. (default: false)
  301. .IP \[bu] 2
  302. \f[B]direct_io\f[R]: deprecated \- Bypass page cache.
  303. Use \f[C]cache.files=off\f[R] instead.
  304. (default: false)
  305. .IP \[bu] 2
  306. \f[B]kernel_cache\f[R]: deprecated \- Do not invalidate data cache on
  307. file open.
  308. Use \f[C]cache.files=full\f[R] instead.
  309. (default: false)
  310. .IP \[bu] 2
  311. \f[B]auto_cache\f[R]: deprecated \- Invalidate data cache if file mtime
  312. or size change.
  313. Use \f[C]cache.files=auto\-full\f[R] instead.
  314. (default: false)
  315. .IP \[bu] 2
  316. \f[B]async_read\f[R]: deprecated \- Perform reads asynchronously.
  317. Use \f[C]async_read=true\f[R] instead.
  318. .IP \[bu] 2
  319. \f[B]sync_read\f[R]: deprecated \- Perform reads synchronously.
  320. Use \f[C]async_read=false\f[R] instead.
  321. .PP
  322. \f[B]NOTE:\f[R] Options are evaluated in the order listed so if the
  323. options are \f[B]func.rmdir=rand,category.action=ff\f[R] the
  324. \f[B]action\f[R] category setting will override the \f[B]rmdir\f[R]
  325. setting.
  326. .SS Value Types
  327. .IP \[bu] 2
  328. BOOL = `true' | `false'
  329. .IP \[bu] 2
  330. INT = [MIN_INT,MAX_INT]
  331. .IP \[bu] 2
  332. UINT = [0,MAX_INT]
  333. .IP \[bu] 2
  334. SIZE = `NNM'; NN = INT, M = `K' | `M' | `G' | `T'
  335. .IP \[bu] 2
  336. STR = string
  337. .IP \[bu] 2
  338. FUNC = filesystem function
  339. .IP \[bu] 2
  340. CATEGORY = function category
  341. .IP \[bu] 2
  342. POLICY = mergerfs function policy
  343. .SS branches
  344. .PP
  345. The `branches' argument is a colon (`:') delimited list of paths to be
  346. pooled together.
  347. It does not matter if the paths are on the same or different drives nor
  348. does it matter the filesystem (within reason).
  349. Used and available space will not be duplicated for paths on the same
  350. device and any features which aren\[cq]t supported by the underlying
  351. filesystem (such as file attributes or extended attributes) will return
  352. the appropriate errors.
  353. .PP
  354. Branches currently have two options which can be set.
  355. A type which impacts whether or not the branch is included in a policy
  356. calculation and a individual minfreespace value.
  357. The values are set by prepending an \f[C]=\f[R] at the end of a branch
  358. designation and using commas as delimiters.
  359. Example: /mnt/drive=RW,1234
  360. .SS branch type
  361. .IP \[bu] 2
  362. RW: (read/write) \- Default behavior.
  363. Will be eligible in all policy categories.
  364. .IP \[bu] 2
  365. RO: (read\-only) \- Will be excluded from \f[C]create\f[R] and
  366. \f[C]action\f[R] policies.
  367. Same as a read\-only mounted filesystem would be (though faster to
  368. process).
  369. .IP \[bu] 2
  370. NC: (no\-create) \- Will be excluded from \f[C]create\f[R] policies.
  371. You can\[cq]t create on that branch but you can change or delete.
  372. .SS minfreespace
  373. .PP
  374. Same purpose as the global option but specific to the branch.
  375. If not set the global value is used.
  376. .SS globbing
  377. .PP
  378. To make it easier to include multiple branches mergerfs supports
  379. globbing (http://linux.die.net/man/7/glob).
  380. \f[B]The globbing tokens MUST be escaped when using via the shell else
  381. the shell itself will apply the glob itself.\f[R]
  382. .IP
  383. .nf
  384. \f[C]
  385. # mergerfs \-o allow_other,use_ino /mnt/disk\[rs]*:/mnt/cdrom /media/drives
  386. \f[R]
  387. .fi
  388. .PP
  389. The above line will use all mount points in /mnt prefixed with
  390. \f[B]disk\f[R] and the \f[B]cdrom\f[R].
  391. .PP
  392. To have the pool mounted at boot or otherwise accessible from related
  393. tools use \f[B]/etc/fstab\f[R].
  394. .IP
  395. .nf
  396. \f[C]
  397. # <file system> <mount point> <type> <options> <dump> <pass>
  398. /mnt/disk*:/mnt/cdrom /mnt/pool fuse.mergerfs allow_other,use_ino 0 0
  399. \f[R]
  400. .fi
  401. .PP
  402. \f[B]NOTE:\f[R] the globbing is done at mount or when updated using the
  403. runtime API.
  404. If a new directory is added matching the glob after the fact it will not
  405. be automatically included.
  406. .PP
  407. \f[B]NOTE:\f[R] for mounting via \f[B]fstab\f[R] to work you must have
  408. \f[B]mount.fuse\f[R] installed.
  409. For Ubuntu/Debian it is included in the \f[B]fuse\f[R] package.
  410. .SS inodecalc
  411. .PP
  412. Inodes (st_ino) are unique identifiers within a filesystem.
  413. Each mounted filesystem has device ID (st_dev) as well and together they
  414. can uniquely identify a file on the whole of the system.
  415. Entries on the same device with the same inode are in fact references to
  416. the same underlying file.
  417. It is a many to one relationship between names and an inode.
  418. Directories, however, do not have multiple links on most systems due to
  419. the complexity they add.
  420. .PP
  421. FUSE allows the server (mergerfs) to set inode values but not device
  422. IDs.
  423. Creating an inode value is somewhat complex in mergerfs\[cq] case as
  424. files aren\[cq]t really in its control.
  425. If a policy changes what directory or file is to be selected or
  426. something changes out of band it becomes unclear what value should be
  427. used.
  428. Most software does not to care what the values are but those that do
  429. often break if a value changes unexpectedly.
  430. The tool \f[C]find\f[R] will abort a directory walk if it sees a
  431. directory inode change.
  432. NFS will return stale handle errors if the inode changes out of band.
  433. File dedup tools will usually leverage device ids and inodes as a
  434. shortcut in searching for duplicate files and would resort to full file
  435. comparisons should it find different inode values.
  436. .PP
  437. mergerfs offers multiple ways to calculate the inode in hopes of
  438. covering different usecases.
  439. .IP \[bu] 2
  440. passthrough: Passes through the underlying inode value.
  441. Mostly intended for testing as using this does not address any of the
  442. problems mentioned above and could confuse file deduplication software
  443. as inodes from different filesystems can be the same.
  444. .IP \[bu] 2
  445. path\-hash: Hashes the relative path of the entry in question.
  446. The underlying file\[cq]s values are completely ignored.
  447. This means the inode value will always be the same for that file path.
  448. This is useful when using NFS and you make changes out of band such as
  449. copy data between branches.
  450. This also means that entries that do point to the same file will not be
  451. recognizable via inodes.
  452. That \f[B]does not\f[R] mean hard links don\[cq]t work.
  453. They will.
  454. .IP \[bu] 2
  455. path\-hash32: 32bit version of path\-hash.
  456. .IP \[bu] 2
  457. devino\-hash: Hashes the device id and inode of the underlying entry.
  458. This won\[cq]t prevent issues with NFS should the policy pick a
  459. different file or files move out of band but will present the same inode
  460. for underlying files that do too.
  461. .IP \[bu] 2
  462. devino\-hash32: 32bit version of devino\-hash.
  463. .IP \[bu] 2
  464. hybrid\-hash: Performs \f[C]path\-hash\f[R] on directories and
  465. \f[C]devino\-hash\f[R] on other file types.
  466. Since directories can\[cq]t have hard links the static value won\[cq]t
  467. make a difference and the files will get values useful for finding
  468. duplicates.
  469. Probably the best to use if not using NFS.
  470. As such it is the default.
  471. .IP \[bu] 2
  472. hybrid\-hash32: 32bit version of hybrid\-hash.
  473. .PP
  474. 32bit versions are provided as there is some software which does not
  475. handle 64bit inodes well.
  476. .PP
  477. While there is a risk of hash collision in tests of a couple million
  478. entries there were zero collisions.
  479. Unlike a typical filesystem FUSE filesystems can reuse inodes and not
  480. refer to the same entry.
  481. The internal identifier used to reference a file in FUSE is different
  482. from the inode value presented.
  483. The former is the \f[C]nodeid\f[R] and is actually a tuple of 2 64bit
  484. values: \f[C]nodeid\f[R] and \f[C]generation\f[R].
  485. This tuple is not client facing.
  486. The inode that is presented to the client is passed through the kernel
  487. uninterpreted.
  488. .PP
  489. From FUSE docs regarding \f[C]use_ino\f[R]:
  490. .IP
  491. .nf
  492. \f[C]
  493. Honor the st_ino field in the functions getattr() and
  494. fill_dir(). This value is used to fill in the st_ino field
  495. in the stat(2), lstat(2), fstat(2) functions and the d_ino
  496. field in the readdir(2) function. The filesystem does not
  497. have to guarantee uniqueness, however some applications
  498. rely on this value being unique for the whole filesystem.
  499. Note that this does *not* affect the inode that libfuse
  500. and the kernel use internally (also called the \[dq]nodeid\[dq]).
  501. \f[R]
  502. .fi
  503. .PP
  504. In the future the \f[C]use_ino\f[R] option will probably be removed as
  505. this feature should replace the original libfuse inode calculation
  506. strategy.
  507. Currently you still need to use \f[C]use_ino\f[R] in order to enable
  508. \f[C]inodecalc\f[R].
  509. .SS fuse_msg_size
  510. .PP
  511. FUSE applications communicate with the kernel over a special character
  512. device: \f[C]/dev/fuse\f[R].
  513. A large portion of the overhead associated with FUSE is the cost of
  514. going back and forth from user space and kernel space over that device.
  515. Generally speaking the fewer trips needed the better the performance
  516. will be.
  517. Reducing the number of trips can be done a number of ways.
  518. Kernel level caching and increasing message sizes being two significant
  519. ones.
  520. When it comes to reads and writes if the message size is doubled the
  521. number of trips are approximately halved.
  522. .PP
  523. In Linux 4.20 a new feature was added allowing the negotiation of the
  524. max message size.
  525. Since the size is in multiples of
  526. pages (https://en.wikipedia.org/wiki/Page_(computer_memory)) the feature
  527. is called \f[C]max_pages\f[R].
  528. There is a maximum \f[C]max_pages\f[R] value of 256 (1MiB) and minimum
  529. of 1 (4KiB).
  530. The default used by Linux >=4.20, and hardcoded value used before 4.20,
  531. is 32 (128KiB).
  532. In mergerfs its referred to as \f[C]fuse_msg_size\f[R] to make it clear
  533. what it impacts and provide some abstraction.
  534. .PP
  535. Since there should be no downsides to increasing \f[C]fuse_msg_size\f[R]
  536. / \f[C]max_pages\f[R], outside a minor bump in RAM usage due to larger
  537. message buffers, mergerfs defaults the value to 256.
  538. On kernels before 4.20 the value has no effect.
  539. The reason the value is configurable is to enable experimentation and
  540. benchmarking.
  541. See the BENCHMARKING section for examples.
  542. .SS symlinkify
  543. .PP
  544. Due to the levels of indirection introduced by mergerfs and the
  545. underlying technology FUSE there can be varying levels of performance
  546. degradation.
  547. This feature will turn non\-directories which are not writable into
  548. symlinks to the original file found by the \f[C]readlink\f[R] policy
  549. after the mtime and ctime are older than the timeout.
  550. .PP
  551. \f[B]WARNING:\f[R] The current implementation has a known issue in which
  552. if the file is open and being used when the file is converted to a
  553. symlink then the application which has that file open will receive an
  554. error when using it.
  555. This is unlikely to occur in practice but is something to keep in mind.
  556. .PP
  557. \f[B]WARNING:\f[R] Some backup solutions, such as CrashPlan, do not
  558. backup the target of a symlink.
  559. If using this feature it will be necessary to point any backup software
  560. to the original drives or configure the software to follow symlinks if
  561. such an option is available.
  562. Alternatively create two mounts.
  563. One for backup and one for general consumption.
  564. .SS nullrw
  565. .PP
  566. Due to how FUSE works there is an overhead to all requests made to a
  567. FUSE filesystem that wouldn\[cq]t exist for an in kernel one.
  568. Meaning that even a simple passthrough will have some slowdown.
  569. However, generally the overhead is minimal in comparison to the cost of
  570. the underlying I/O.
  571. By disabling the underlying I/O we can test the theoretical performance
  572. boundaries.
  573. .PP
  574. By enabling \f[C]nullrw\f[R] mergerfs will work as it always does
  575. \f[B]except\f[R] that all reads and writes will be no\-ops.
  576. A write will succeed (the size of the write will be returned as if it
  577. were successful) but mergerfs does nothing with the data it was given.
  578. Similarly a read will return the size requested but won\[cq]t touch the
  579. buffer.
  580. .PP
  581. See the BENCHMARKING section for suggestions on how to test.
  582. .SS xattr
  583. .PP
  584. Runtime extended attribute support can be managed via the
  585. \f[C]xattr\f[R] option.
  586. By default it will passthrough any xattr calls.
  587. Given xattr support is rarely used and can have significant performance
  588. implications mergerfs allows it to be disabled at runtime.
  589. The performance problems mostly comes when file caching is enabled.
  590. The kernel will send a \f[C]getxattr\f[R] for
  591. \f[C]security.capability\f[R] \f[I]before every single write\f[R].
  592. It doesn\[cq]t cache the responses to any \f[C]getxattr\f[R].
  593. This might be addressed in the future but for now mergerfs can really
  594. only offer the following workarounds.
  595. .PP
  596. \f[C]noattr\f[R] will cause mergerfs to short circuit all xattr calls
  597. and return ENOATTR where appropriate.
  598. mergerfs still gets all the requests but they will not be forwarded on
  599. to the underlying filesystems.
  600. The runtime control will still function in this mode.
  601. .PP
  602. \f[C]nosys\f[R] will cause mergerfs to return ENOSYS for any xattr call.
  603. The difference with \f[C]noattr\f[R] is that the kernel will cache this
  604. fact and itself short circuit future calls.
  605. This is more efficient than \f[C]noattr\f[R] but will cause
  606. mergerfs\[cq] runtime control via the hidden file to stop working.
  607. .SS nfsopenhack
  608. .PP
  609. NFS is not fully POSIX compliant and historically certain behaviors,
  610. such as opening files with O_EXCL, are not or not well supported.
  611. When mergerfs (or any FUSE filesystem) is exported over NFS some of
  612. these issues come up due to how NFS and FUSE interact.
  613. .PP
  614. This hack addresses the issue where the creation of a file with a
  615. read\-only mode but with a read/write or write only flag.
  616. Normally this is perfectly valid but NFS chops the one open call into
  617. multiple calls.
  618. Exactly how it is translated depends on the configuration and versions
  619. of the NFS server and clients but it results in a permission error
  620. because a normal user is not allowed to open a read\-only file as
  621. writable.
  622. .PP
  623. Even though it\[cq]s a more niche situation this hack breaks normal
  624. security and behavior and as such is \f[C]off\f[R] by default.
  625. If set to \f[C]git\f[R] it will only perform the hack when the path in
  626. question includes \f[C]/.git/\f[R].
  627. \f[C]all\f[R] will result it it applying anytime a readonly file which
  628. is empty is opened for writing.
  629. .SH FUNCTIONS, CATEGORIES and POLICIES
  630. .PP
  631. The POSIX filesystem API is made up of a number of functions.
  632. \f[B]creat\f[R], \f[B]stat\f[R], \f[B]chown\f[R], etc.
  633. For ease of configuration in mergerfs most of the core functions are
  634. grouped into 3 categories: \f[B]action\f[R], \f[B]create\f[R], and
  635. \f[B]search\f[R].
  636. These functions and categories can be assigned a policy which dictates
  637. which branch is chosen when performing that function.
  638. .PP
  639. Some functions, listed in the category \f[C]N/A\f[R] below, can not be
  640. assigned the normal policies.
  641. These functions work with file handles, rather than file paths, which
  642. were created by \f[C]open\f[R] or \f[C]create\f[R].
  643. That said many times the current FUSE kernel driver will not always
  644. provide the file handle when a client calls \f[C]fgetattr\f[R],
  645. \f[C]fchown\f[R], \f[C]fchmod\f[R], \f[C]futimens\f[R],
  646. \f[C]ftruncate\f[R], etc.
  647. This means it will call the regular, path based, versions.
  648. \f[C]readdir\f[R] has no real need for a policy given the purpose is
  649. merely to return a list of entries in a directory.
  650. \f[C]statfs\f[R]\[cq]s behavior can be modified via other options.
  651. .PP
  652. When using policies which are based on a branch\[cq]s available space
  653. the base path provided is used.
  654. Not the full path to the file in question.
  655. Meaning that mounts in the branch won\[cq]t be considered in the space
  656. calculations.
  657. The reason is that it doesn\[cq]t really work for non\-path preserving
  658. policies and can lead to non\-obvious behaviors.
  659. .PP
  660. NOTE: While any policy can be assigned to a function or category though
  661. some may not be very useful in practice.
  662. For instance: \f[B]rand\f[R] (random) may be useful for file creation
  663. (create) but could lead to very odd behavior if used for \f[C]chmod\f[R]
  664. if there were more than one copy of the file.
  665. .SS Functions and their Category classifications
  666. .PP
  667. .TS
  668. tab(@);
  669. lw(7.4n) lw(62.6n).
  670. T{
  671. Category
  672. T}@T{
  673. FUSE Functions
  674. T}
  675. _
  676. T{
  677. action
  678. T}@T{
  679. chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate,
  680. unlink, utimens
  681. T}
  682. T{
  683. create
  684. T}@T{
  685. create, mkdir, mknod, symlink
  686. T}
  687. T{
  688. search
  689. T}@T{
  690. access, getattr, getxattr, ioctl (directories), listxattr, open,
  691. readlink
  692. T}
  693. T{
  694. N/A
  695. T}@T{
  696. fchmod, fchown, futimens, ftruncate, fallocate, fgetattr, fsync, ioctl
  697. (files), read, readdir, release, statfs, write, copy_file_range
  698. T}
  699. .TE
  700. .PP
  701. In cases where something may be searched for (such as a path to clone)
  702. \f[B]getattr\f[R] will usually be used.
  703. .SS Policies
  704. .PP
  705. A policy is the algorithm used to choose a branch or branches for a
  706. function to work on.
  707. Think of them as ways to filter and sort branches.
  708. .PP
  709. Any function in the \f[C]create\f[R] category will clone the relative
  710. path if needed.
  711. Some other functions (\f[C]rename\f[R],\f[C]link\f[R],\f[C]ioctl\f[R])
  712. have special requirements or behaviors which you can read more about
  713. below.
  714. .SS Filtering
  715. .PP
  716. Policies basically search branches and create a list of files / paths
  717. for functions to work on.
  718. The policy is responsible for filtering and sorting the branches.
  719. Filters include \f[B]minfreespace\f[R], whether or not a branch is
  720. mounted read\-only, and the branch tagging (RO,NC,RW).
  721. These filters are applied across all policies unless otherwise noted.
  722. .IP \[bu] 2
  723. No \f[B]search\f[R] function policies filter.
  724. .IP \[bu] 2
  725. All \f[B]action\f[R] function policies filter out branches which are
  726. mounted \f[B]read\-only\f[R] or tagged as \f[B]RO (read\-only)\f[R].
  727. .IP \[bu] 2
  728. All \f[B]create\f[R] function policies filter out branches which are
  729. mounted \f[B]read\-only\f[R], tagged \f[B]RO (read\-only)\f[R] or
  730. \f[B]NC (no create)\f[R], or has available space less than
  731. \f[C]minfreespace\f[R].
  732. .PP
  733. Policies may have their own additional filtering such as those that
  734. require existing paths to be present.
  735. .PP
  736. If all branches are filtered an error will be returned.
  737. Typically \f[B]EROFS\f[R] (read\-only filesystem) or \f[B]ENOSPC\f[R]
  738. (no space left on device) depending on the most recent reason for
  739. filtering a branch.
  740. \f[B]ENOENT\f[R] will be returned if no elegible branch is found.
  741. .SS Path Preservation
  742. .PP
  743. Policies, as described below, are of two basic types.
  744. \f[C]path preserving\f[R] and \f[C]non\-path preserving\f[R].
  745. .PP
  746. All policies which start with \f[C]ep\f[R] (\f[B]epff\f[R],
  747. \f[B]eplfs\f[R], \f[B]eplus\f[R], \f[B]epmfs\f[R], \f[B]eprand\f[R]) are
  748. \f[C]path preserving\f[R].
  749. \f[C]ep\f[R] stands for \f[C]existing path\f[R].
  750. .PP
  751. A path preserving policy will only consider drives where the relative
  752. path being accessed already exists.
  753. .PP
  754. When using non\-path preserving policies paths will be cloned to target
  755. drives as necessary.
  756. .PP
  757. With the \f[C]msp\f[R] or \f[C]most shared path\f[R] policies they are
  758. defined as \f[C]path preserving\f[R] for the purpose of controlling
  759. \f[C]link\f[R] and \f[C]rename\f[R]\[cq]s behaviors since
  760. \f[C]ignorepponrename\f[R] is available to disable that behavior.
  761. In mergerfs v3.0 the path preserving behavior of rename and link will
  762. likely be separated from the policy all together.
  763. .SS Policy descriptions
  764. .PP
  765. A policy\[cq]s behavior differs, as mentioned above, based on the
  766. function it is used with.
  767. Sometimes it really might not make sense to even offer certain policies
  768. because they are literally the same as others but it makes things a bit
  769. more uniform.
  770. In mergerfs 3.0 this might change.
  771. .PP
  772. .TS
  773. tab(@);
  774. lw(16.2n) lw(53.8n).
  775. T{
  776. Policy
  777. T}@T{
  778. Description
  779. T}
  780. _
  781. T{
  782. all
  783. T}@T{
  784. Search: Same as \f[B]epall\f[R].
  785. Action: Same as \f[B]epall\f[R].
  786. Create: for \f[B]mkdir\f[R], \f[B]mknod\f[R], and \f[B]symlink\f[R] it
  787. will apply to all branches.
  788. \f[B]create\f[R] works like \f[B]ff\f[R].
  789. T}
  790. T{
  791. epall (existing path, all)
  792. T}@T{
  793. Search: Same as \f[B]epff\f[R] (but more expensive because it
  794. doesn\[cq]t stop after finding a valid branch).
  795. Action: apply to all found.
  796. Create: for \f[B]mkdir\f[R], \f[B]mknod\f[R], and \f[B]symlink\f[R] it
  797. will apply to all found.
  798. \f[B]create\f[R] works like \f[B]epff\f[R] (but more expensive because
  799. it doesn\[cq]t stop after finding a valid branch).
  800. T}
  801. T{
  802. epff (existing path, first found)
  803. T}@T{
  804. Given the order of the branches, as defined at mount time or configured
  805. at runtime, act on the first one found where the relative path exists.
  806. T}
  807. T{
  808. eplfs (existing path, least free space)
  809. T}@T{
  810. Of all the branches on which the relative path exists choose the drive
  811. with the least free space.
  812. T}
  813. T{
  814. eplus (existing path, least used space)
  815. T}@T{
  816. Of all the branches on which the relative path exists choose the drive
  817. with the least used space.
  818. T}
  819. T{
  820. epmfs (existing path, most free space)
  821. T}@T{
  822. Of all the branches on which the relative path exists choose the drive
  823. with the most free space.
  824. T}
  825. T{
  826. eppfrd (existing path, percentage free random distribution)
  827. T}@T{
  828. Like \f[B]pfrd\f[R] but limited to existing paths.
  829. T}
  830. T{
  831. eprand (existing path, random)
  832. T}@T{
  833. Calls \f[B]epall\f[R] and then randomizes.
  834. Returns 1.
  835. T}
  836. T{
  837. erofs
  838. T}@T{
  839. Exclusively return \f[B]\-1\f[R] with \f[B]errno\f[R] set to
  840. \f[B]EROFS\f[R] (read\-only filesystem).
  841. T}
  842. T{
  843. ff (first found)
  844. T}@T{
  845. Search: Same as \f[B]epff\f[R].
  846. Action: Same as \f[B]epff\f[R].
  847. Create: Given the order of the drives, as defined at mount time or
  848. configured at runtime, act on the first one found.
  849. T}
  850. T{
  851. lfs (least free space)
  852. T}@T{
  853. Search: Same as \f[B]eplfs\f[R].
  854. Action: Same as \f[B]eplfs\f[R].
  855. Create: Pick the drive with the least available free space.
  856. T}
  857. T{
  858. lus (least used space)
  859. T}@T{
  860. Search: Same as \f[B]eplus\f[R].
  861. Action: Same as \f[B]eplus\f[R].
  862. Create: Pick the drive with the least used space.
  863. T}
  864. T{
  865. mfs (most free space)
  866. T}@T{
  867. Search: Same as \f[B]epmfs\f[R].
  868. Action: Same as \f[B]epmfs\f[R].
  869. Create: Pick the drive with the most available free space.
  870. T}
  871. T{
  872. msplfs (most shared path, least free space)
  873. T}@T{
  874. Search: Same as \f[B]eplfs\f[R].
  875. Action: Same as \f[B]eplfs\f[R].
  876. Create: like \f[B]eplfs\f[R] but walk back the path if it fails to find
  877. a branch at that level.
  878. T}
  879. T{
  880. msplus (most shared path, least used space)
  881. T}@T{
  882. Search: Same as \f[B]eplus\f[R].
  883. Action: Same as \f[B]eplus\f[R].
  884. Create: like \f[B]eplus\f[R] but walk back the path if it fails to find
  885. a branch at that level.
  886. T}
  887. T{
  888. mspmfs (most shared path, most free space)
  889. T}@T{
  890. Search: Same as \f[B]epmfs\f[R].
  891. Action: Same as \f[B]epmfs\f[R].
  892. Create: like \f[B]epmfs\f[R] but walk back the path if it fails to find
  893. a branch at that level.
  894. T}
  895. T{
  896. msppfrd (most shared path, percentage free random distribution)
  897. T}@T{
  898. Search: Same as \f[B]eppfrd\f[R].
  899. Action: Same as \f[B]eppfrd\f[R].
  900. Create: Like \f[B]eppfrd\f[R] but will walk back the path if it fails to
  901. find a branch at that level.
  902. T}
  903. T{
  904. newest
  905. T}@T{
  906. Pick the file / directory with the largest mtime.
  907. T}
  908. T{
  909. pfrd (percentage free random distribution)
  910. T}@T{
  911. Search: Same as \f[B]eppfrd\f[R].
  912. Action: Same as \f[B]eppfrd\f[R].
  913. Create: Chooses a branch at random with the likelihood of selection
  914. based on a branch\[cq]s available space relative to the total.
  915. T}
  916. T{
  917. rand (random)
  918. T}@T{
  919. Calls \f[B]all\f[R] and then randomizes.
  920. Returns 1.
  921. T}
  922. .TE
  923. .PP
  924. \f[B]NOTE:\f[R] If you are using an underlying filesystem that reserves
  925. blocks such as ext2, ext3, or ext4 be aware that mergerfs respects the
  926. reservation by using \f[C]f_bavail\f[R] (number of free blocks for
  927. unprivileged users) rather than \f[C]f_bfree\f[R] (number of free
  928. blocks) in policy calculations.
  929. \f[B]df\f[R] does NOT use \f[C]f_bavail\f[R], it uses \f[C]f_bfree\f[R],
  930. so direct comparisons between \f[B]df\f[R] output and mergerfs\[cq]
  931. policies is not appropriate.
  932. .SS Defaults
  933. .PP
  934. .TS
  935. tab(@);
  936. l l.
  937. T{
  938. Category
  939. T}@T{
  940. Policy
  941. T}
  942. _
  943. T{
  944. action
  945. T}@T{
  946. epall
  947. T}
  948. T{
  949. create
  950. T}@T{
  951. epmfs
  952. T}
  953. T{
  954. search
  955. T}@T{
  956. ff
  957. T}
  958. .TE
  959. .SS ioctl
  960. .PP
  961. When \f[C]ioctl\f[R] is used with an open file then it will use the file
  962. handle which was created at the original \f[C]open\f[R] call.
  963. However, when using \f[C]ioctl\f[R] with a directory mergerfs will use
  964. the \f[C]open\f[R] policy to find the directory to act on.
  965. .SS rename & link
  966. .PP
  967. \f[B]NOTE:\f[R] If you\[cq]re receiving errors from software when files
  968. are moved / renamed / linked then you should consider changing the
  969. create policy to one which is \f[B]not\f[R] path preserving, enabling
  970. \f[C]ignorepponrename\f[R], or contacting the author of the offending
  971. software and requesting that \f[C]EXDEV\f[R] (cross device / improper
  972. link) be properly handled.
  973. .PP
  974. \f[C]rename\f[R] and \f[C]link\f[R] are tricky functions in a union
  975. filesystem.
  976. \f[C]rename\f[R] only works within a single filesystem or device.
  977. If a rename can\[cq]t be done atomically due to the source and
  978. destination paths existing on different mount points it will return
  979. \f[B]\-1\f[R] with \f[B]errno = EXDEV\f[R] (cross device / improper
  980. link).
  981. So if a \f[C]rename\f[R]\[cq]s source and target are on different drives
  982. within the pool it creates an issue.
  983. .PP
  984. Originally mergerfs would return EXDEV whenever a rename was requested
  985. which was cross directory in any way.
  986. This made the code simple and was technically compliant with POSIX
  987. requirements.
  988. However, many applications fail to handle EXDEV at all and treat it as a
  989. normal error or otherwise handle it poorly.
  990. Such apps include: gvfsd\-fuse v1.20.3 and prior, Finder / CIFS/SMB
  991. client in Apple OSX 10.9+, NZBGet, Samba\[cq]s recycling bin feature.
  992. .PP
  993. As a result a compromise was made in order to get most software to work
  994. while still obeying mergerfs\[cq] policies.
  995. Below is the basic logic.
  996. .IP \[bu] 2
  997. If using a \f[B]create\f[R] policy which tries to preserve directory
  998. paths (epff,eplfs,eplus,epmfs)
  999. .RS 2
  1000. .IP \[bu] 2
  1001. Using the \f[B]rename\f[R] policy get the list of files to rename
  1002. .IP \[bu] 2
  1003. For each file attempt rename:
  1004. .RS 2
  1005. .IP \[bu] 2
  1006. If failure with ENOENT (no such file or directory) run \f[B]create\f[R]
  1007. policy
  1008. .IP \[bu] 2
  1009. If create policy returns the same drive as currently evaluating then
  1010. clone the path
  1011. .IP \[bu] 2
  1012. Re\-attempt rename
  1013. .RE
  1014. .IP \[bu] 2
  1015. If \f[B]any\f[R] of the renames succeed the higher level rename is
  1016. considered a success
  1017. .IP \[bu] 2
  1018. If \f[B]no\f[R] renames succeed the first error encountered will be
  1019. returned
  1020. .IP \[bu] 2
  1021. On success:
  1022. .RS 2
  1023. .IP \[bu] 2
  1024. Remove the target from all drives with no source file
  1025. .IP \[bu] 2
  1026. Remove the source from all drives which failed to rename
  1027. .RE
  1028. .RE
  1029. .IP \[bu] 2
  1030. If using a \f[B]create\f[R] policy which does \f[B]not\f[R] try to
  1031. preserve directory paths
  1032. .RS 2
  1033. .IP \[bu] 2
  1034. Using the \f[B]rename\f[R] policy get the list of files to rename
  1035. .IP \[bu] 2
  1036. Using the \f[B]getattr\f[R] policy get the target path
  1037. .IP \[bu] 2
  1038. For each file attempt rename:
  1039. .RS 2
  1040. .IP \[bu] 2
  1041. If the source drive != target drive:
  1042. .RS 2
  1043. .IP \[bu] 2
  1044. Clone target path from target drive to source drive
  1045. .RE
  1046. .IP \[bu] 2
  1047. Rename
  1048. .RE
  1049. .IP \[bu] 2
  1050. If \f[B]any\f[R] of the renames succeed the higher level rename is
  1051. considered a success
  1052. .IP \[bu] 2
  1053. If \f[B]no\f[R] renames succeed the first error encountered will be
  1054. returned
  1055. .IP \[bu] 2
  1056. On success:
  1057. .RS 2
  1058. .IP \[bu] 2
  1059. Remove the target from all drives with no source file
  1060. .IP \[bu] 2
  1061. Remove the source from all drives which failed to rename
  1062. .RE
  1063. .RE
  1064. .PP
  1065. The the removals are subject to normal entitlement checks.
  1066. .PP
  1067. The above behavior will help minimize the likelihood of EXDEV being
  1068. returned but it will still be possible.
  1069. .PP
  1070. \f[B]link\f[R] uses the same strategy but without the removals.
  1071. .SS readdir
  1072. .PP
  1073. readdir (http://linux.die.net/man/3/readdir) is different from all other
  1074. filesystem functions.
  1075. While it could have its own set of policies to tweak its behavior at
  1076. this time it provides a simple union of files and directories found.
  1077. Remember that any action or information queried about these files and
  1078. directories come from the respective function.
  1079. For instance: an \f[B]ls\f[R] is a \f[B]readdir\f[R] and for each
  1080. file/directory returned \f[B]getattr\f[R] is called.
  1081. Meaning the policy of \f[B]getattr\f[R] is responsible for choosing the
  1082. file/directory which is the source of the metadata you see in an
  1083. \f[B]ls\f[R].
  1084. .SS statfs / statvfs
  1085. .PP
  1086. statvfs (http://linux.die.net/man/2/statvfs) normalizes the source
  1087. drives based on the fragment size and sums the number of adjusted blocks
  1088. and inodes.
  1089. This means you will see the combined space of all sources.
  1090. Total, used, and free.
  1091. The sources however are dedupped based on the drive so multiple sources
  1092. on the same drive will not result in double counting its space.
  1093. Filesystems mounted further down the tree of the branch will not be
  1094. included when checking the mount\[cq]s stats.
  1095. .PP
  1096. The options \f[C]statfs\f[R] and \f[C]statfs_ignore\f[R] can be used to
  1097. modify \f[C]statfs\f[R] behavior.
  1098. .SH ERROR HANDLING
  1099. .PP
  1100. POSIX filesystem functions offer a single return code meaning that there
  1101. is some complication regarding the handling of multiple branches as
  1102. mergerfs does.
  1103. It tries to handle errors in a way that would generally return
  1104. meaningful values for that particular function.
  1105. .SS chmod, chown, removexattr, setxattr, truncate, utimens
  1106. .IP "1)" 3
  1107. if no error: return 0 (success)
  1108. .IP "2)" 3
  1109. if no successes: return first error
  1110. .IP "3)" 3
  1111. if one of the files acted on was the same as the related search
  1112. function: return its value
  1113. .IP "4)" 3
  1114. return 0 (success)
  1115. .PP
  1116. While doing this increases the complexity and cost of error handling,
  1117. particularly step 3, this provides probably the most reasonable return
  1118. value.
  1119. .SS unlink, rmdir
  1120. .IP "1)" 3
  1121. if no errors: return 0 (success)
  1122. .IP "2)" 3
  1123. return first error
  1124. .PP
  1125. Older version of mergerfs would return success if any success occurred
  1126. but for unlink and rmdir there are downstream assumptions that, while
  1127. not impossible to occur, can confuse some software.
  1128. .SS others
  1129. .PP
  1130. For search functions there is always a single thing acted on and as such
  1131. whatever return value that comes from the single function call is
  1132. returned.
  1133. .PP
  1134. For create functions \f[C]mkdir\f[R], \f[C]mknod\f[R], and
  1135. \f[C]symlink\f[R] which don\[cq]t return a file descriptor and therefore
  1136. can have \f[C]all\f[R] or \f[C]epall\f[R] policies it will return
  1137. success if any of the calls succeed and an error otherwise.
  1138. .SH BUILD / UPDATE
  1139. .PP
  1140. \f[B]NOTE:\f[R] Prebuilt packages can be found at and recommended for
  1141. most users: https://github.com/trapexit/mergerfs/releases
  1142. \f[B]NOTE:\f[R] Only tagged releases are supported.
  1143. \f[C]master\f[R] and other branches should be considered works in
  1144. progress.
  1145. .PP
  1146. First get the code from github (https://github.com/trapexit/mergerfs).
  1147. .IP
  1148. .nf
  1149. \f[C]
  1150. $ git clone https://github.com/trapexit/mergerfs.git
  1151. $ # or
  1152. $ wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs\-<ver>.tar.gz
  1153. \f[R]
  1154. .fi
  1155. .SS Debian / Ubuntu
  1156. .IP
  1157. .nf
  1158. \f[C]
  1159. $ cd mergerfs
  1160. $ sudo tools/install\-build\-pkgs
  1161. $ make deb
  1162. $ sudo dpkg \-i ../mergerfs_<version>_<arch>.deb
  1163. \f[R]
  1164. .fi
  1165. .SS RHEL / CentOS /Fedora
  1166. .IP
  1167. .nf
  1168. \f[C]
  1169. $ su \-
  1170. # cd mergerfs
  1171. # tools/install\-build\-pkgs
  1172. # make rpm
  1173. # rpm \-i rpmbuild/RPMS/<arch>/mergerfs\-<version>.<arch>.rpm
  1174. \f[R]
  1175. .fi
  1176. .SS Generically
  1177. .PP
  1178. Have git, g++, make, python installed.
  1179. .IP
  1180. .nf
  1181. \f[C]
  1182. $ cd mergerfs
  1183. $ make
  1184. $ sudo make install
  1185. \f[R]
  1186. .fi
  1187. .SS Build options
  1188. .IP
  1189. .nf
  1190. \f[C]
  1191. $ make help
  1192. usage: make
  1193. make USE_XATTR=0 \- build program without xattrs functionality
  1194. make STATIC=1 \- build static binary
  1195. make LTO=1 \- build with link time optimization
  1196. \f[R]
  1197. .fi
  1198. .SH UPGRADE
  1199. .PP
  1200. mergerfs can be upgraded live by mounting on top of the previous
  1201. instance.
  1202. Simply install the new version of mergerfs and follow the instructions
  1203. below.
  1204. .PP
  1205. Add \f[C]nonempty\f[R] to your mergerfs option list and call mergerfs
  1206. again or if using \f[C]/etc/fstab\f[R] call for it to mount again.
  1207. Existing open files and such will continue to work fine though they
  1208. won\[cq]t see runtime changes since any such change would be the new
  1209. mount.
  1210. If you plan on changing settings with the new mount you should / could
  1211. apply those before mounting the new version.
  1212. .IP
  1213. .nf
  1214. \f[C]
  1215. $ sudo mount /mnt/mergerfs
  1216. $ mount | grep mergerfs
  1217. media on /mnt/mergerfs type fuse.mergerfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
  1218. media on /mnt/mergerfs type fuse.mergerfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
  1219. \f[R]
  1220. .fi
  1221. .PP
  1222. A problem with this approach is that the underlying instance will
  1223. continue to run even if the software using it stop or are restarted.
  1224. To work around this you can use a \[lq]lazy umount\[rq].
  1225. Before mounting over top the mount point with the new instance of
  1226. mergerfs issue: \f[C]umount \-l <mergerfs_mountpoint>\f[R].
  1227. .SH RUNTIME CONFIG
  1228. .SS ioctl
  1229. .PP
  1230. The original runtime config API was via xattr calls.
  1231. This however became an issue when needing to disable xattr.
  1232. While slightly less convenient ioctl does not have the same problems and
  1233. will be the main API going forward.
  1234. .PP
  1235. The keys are the same as the command line option arguments as well as
  1236. the config file.
  1237. .SS requests / commands
  1238. .PP
  1239. All commands take a 4096 byte char buffer.
  1240. .IP \[bu] 2
  1241. read keys: get a nul `\[rs]0' delimited list of option keys
  1242. .RS 2
  1243. .IP \[bu] 2
  1244. _IOWR(0xDF,0,char[4096]) = 0xD000DF00
  1245. .IP \[bu] 2
  1246. on success ioctl return value is the total length
  1247. .RE
  1248. .IP \[bu] 2
  1249. read value: get an option value
  1250. .RS 2
  1251. .IP \[bu] 2
  1252. _IOWR(0xDF,1,char[4096]) = 0xD000DF01
  1253. .IP \[bu] 2
  1254. the key is passed in via the char buffer as a nul `\[rs]0' terminated
  1255. string
  1256. .IP \[bu] 2
  1257. on success ioctl return value is the total length
  1258. .RE
  1259. .IP \[bu] 2
  1260. write value: set an option value
  1261. .RS 2
  1262. .IP \[bu] 2
  1263. _IOW(0xDF,2,char[4096]) = 0x5000DF02
  1264. .IP \[bu] 2
  1265. the key and value is passed in via the char buffer as a nul `\[rs]0'
  1266. terminated string in the format of \f[C]key=value\f[R]
  1267. .IP \[bu] 2
  1268. on success ioctl return value is 0
  1269. .RE
  1270. .IP \[bu] 2
  1271. file info: get mergerfs metadata info for a file
  1272. .RS 2
  1273. .IP \[bu] 2
  1274. _IOWR(0xDF,3,char[4096]) = 0xD000DF03
  1275. .IP \[bu] 2
  1276. the key is passed in via the char buffer as a nul `\[rs]0' terminated
  1277. string
  1278. .IP \[bu] 2
  1279. on success the ioctl return value is the total length
  1280. .IP \[bu] 2
  1281. keys:
  1282. .RS 2
  1283. .IP \[bu] 2
  1284. basepath: the base mount point for the file according to the getattr
  1285. policy
  1286. .IP \[bu] 2
  1287. relpath: the relative path of the file from the mount point
  1288. .IP \[bu] 2
  1289. fullpath: the full path of the underlying file according to the getattr
  1290. policy
  1291. .IP \[bu] 2
  1292. allpaths: a NUL `\[rs]0' delimited list of full paths to all files found
  1293. .RE
  1294. .RE
  1295. .SS .mergerfs pseudo file (deprecated)
  1296. .PP
  1297. NOTE: this interface will be removed in mergerfs 3.0
  1298. .IP
  1299. .nf
  1300. \f[C]
  1301. <mountpoint>/.mergerfs
  1302. \f[R]
  1303. .fi
  1304. .PP
  1305. There is a pseudo file available at the mount point which allows for the
  1306. runtime modification of certain \f[B]mergerfs\f[R] options.
  1307. The file will not show up in \f[B]readdir\f[R] but can be
  1308. \f[B]stat\f[R]\[cq]ed and manipulated via
  1309. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls.
  1310. .PP
  1311. Any changes made at runtime are \f[B]not\f[R] persisted.
  1312. If you wish for values to persist they must be included as options
  1313. wherever you configure the mounting of mergerfs (/etc/fstab).
  1314. .SS Keys
  1315. .PP
  1316. Use \f[C]xattr \-l /mountpoint/.mergerfs\f[R] to see all supported keys.
  1317. Some are informational and therefore read\-only.
  1318. \f[C]setxattr\f[R] will return EINVAL (invalid argument) on read\-only
  1319. keys.
  1320. .SS Values
  1321. .PP
  1322. Same as the command line.
  1323. .SS user.mergerfs.branches
  1324. .PP
  1325. \f[B]NOTE:\f[R] formerly \f[C]user.mergerfs.srcmounts\f[R] but said key
  1326. is still supported.
  1327. .PP
  1328. Used to query or modify the list of branches.
  1329. When modifying there are several shortcuts to easy manipulation of the
  1330. list.
  1331. .PP
  1332. .TS
  1333. tab(@);
  1334. l l.
  1335. T{
  1336. Value
  1337. T}@T{
  1338. Description
  1339. T}
  1340. _
  1341. T{
  1342. [list]
  1343. T}@T{
  1344. set
  1345. T}
  1346. T{
  1347. +<[list]
  1348. T}@T{
  1349. prepend
  1350. T}
  1351. T{
  1352. +>[list]
  1353. T}@T{
  1354. append
  1355. T}
  1356. T{
  1357. \-[list]
  1358. T}@T{
  1359. remove all values provided
  1360. T}
  1361. T{
  1362. \-<
  1363. T}@T{
  1364. remove first in list
  1365. T}
  1366. T{
  1367. \->
  1368. T}@T{
  1369. remove last in list
  1370. T}
  1371. .TE
  1372. .PP
  1373. \f[C]xattr \-w user.mergerfs.branches +</mnt/drive3 /mnt/pool/.mergerfs\f[R]
  1374. .PP
  1375. The \f[C]=NC\f[R], \f[C]=RO\f[R], \f[C]=RW\f[R] syntax works just as on
  1376. the command line.
  1377. .SS Example
  1378. .IP
  1379. .nf
  1380. \f[C]
  1381. [trapexit:/mnt/mergerfs] $ xattr \-l .mergerfs
  1382. user.mergerfs.branches: /mnt/a=RW:/mnt/b=RW
  1383. user.mergerfs.minfreespace: 4294967295
  1384. user.mergerfs.moveonenospc: false
  1385. \&...
  1386. [trapexit:/mnt/mergerfs] $ xattr \-p user.mergerfs.category.search .mergerfs
  1387. ff
  1388. [trapexit:/mnt/mergerfs] $ xattr \-w user.mergerfs.category.search newest .mergerfs
  1389. [trapexit:/mnt/mergerfs] $ xattr \-p user.mergerfs.category.search .mergerfs
  1390. newest
  1391. [trapexit:/mnt/mergerfs] $ xattr \-w user.mergerfs.branches +/mnt/c .mergerfs
  1392. [trapexit:/mnt/mergerfs] $ xattr \-p user.mergerfs.branches .mergerfs
  1393. /mnt/a:/mnt/b:/mnt/c
  1394. [trapexit:/mnt/mergerfs] $ xattr \-w user.mergerfs.branches =/mnt/c .mergerfs
  1395. [trapexit:/mnt/mergerfs] $ xattr \-p user.mergerfs.branches .mergerfs
  1396. /mnt/c
  1397. [trapexit:/mnt/mergerfs] $ xattr \-w user.mergerfs.branches \[aq]+</mnt/a:/mnt/b\[aq] .mergerfs
  1398. [trapexit:/mnt/mergerfs] $ xattr \-p user.mergerfs.branches .mergerfs
  1399. /mnt/a:/mnt/b:/mnt/c
  1400. \f[R]
  1401. .fi
  1402. .SS file / directory xattrs
  1403. .PP
  1404. While they won\[cq]t show up when using
  1405. listxattr (http://linux.die.net/man/2/listxattr) \f[B]mergerfs\f[R]
  1406. offers a number of special xattrs to query information about the files
  1407. served.
  1408. To access the values you will need to issue a
  1409. getxattr (http://linux.die.net/man/2/getxattr) for one of the following:
  1410. .IP \[bu] 2
  1411. \f[B]user.mergerfs.basepath\f[R]: the base mount point for the file
  1412. given the current getattr policy
  1413. .IP \[bu] 2
  1414. \f[B]user.mergerfs.relpath\f[R]: the relative path of the file from the
  1415. perspective of the mount point
  1416. .IP \[bu] 2
  1417. \f[B]user.mergerfs.fullpath\f[R]: the full path of the original file
  1418. given the getattr policy
  1419. .IP \[bu] 2
  1420. \f[B]user.mergerfs.allpaths\f[R]: a NUL (`\[rs]0') separated list of
  1421. full paths to all files found
  1422. .IP
  1423. .nf
  1424. \f[C]
  1425. [trapexit:/mnt/mergerfs] $ ls
  1426. A B C
  1427. [trapexit:/mnt/mergerfs] $ xattr \-p user.mergerfs.fullpath A
  1428. /mnt/a/full/path/to/A
  1429. [trapexit:/mnt/mergerfs] $ xattr \-p user.mergerfs.basepath A
  1430. /mnt/a
  1431. [trapexit:/mnt/mergerfs] $ xattr \-p user.mergerfs.relpath A
  1432. /full/path/to/A
  1433. [trapexit:/mnt/mergerfs] $ xattr \-p user.mergerfs.allpaths A | tr \[aq]\[rs]0\[aq] \[aq]\[rs]n\[aq]
  1434. /mnt/a/full/path/to/A
  1435. /mnt/b/full/path/to/A
  1436. \f[R]
  1437. .fi
  1438. .SH TOOLING
  1439. .IP \[bu] 2
  1440. https://github.com/trapexit/mergerfs\-tools
  1441. .RS 2
  1442. .IP \[bu] 2
  1443. mergerfs.ctl: A tool to make it easier to query and configure mergerfs
  1444. at runtime
  1445. .IP \[bu] 2
  1446. mergerfs.fsck: Provides permissions and ownership auditing and the
  1447. ability to fix them
  1448. .IP \[bu] 2
  1449. mergerfs.dedup: Will help identify and optionally remove duplicate files
  1450. .IP \[bu] 2
  1451. mergerfs.dup: Ensure there are at least N copies of a file across the
  1452. pool
  1453. .IP \[bu] 2
  1454. mergerfs.balance: Rebalance files across drives by moving them from the
  1455. most filled to the least filled
  1456. .IP \[bu] 2
  1457. mergerfs.consolidate: move files within a single mergerfs directory to
  1458. the drive with most free space
  1459. .RE
  1460. .IP \[bu] 2
  1461. https://github.com/trapexit/scorch
  1462. .RS 2
  1463. .IP \[bu] 2
  1464. scorch: A tool to help discover silent corruption of files and keep
  1465. track of files
  1466. .RE
  1467. .IP \[bu] 2
  1468. https://github.com/trapexit/bbf
  1469. .RS 2
  1470. .IP \[bu] 2
  1471. bbf (bad block finder): a tool to scan for and `fix' hard drive bad
  1472. blocks and find the files using those blocks
  1473. .RE
  1474. .SH CACHING
  1475. .SS page caching
  1476. .PP
  1477. https://en.wikipedia.org/wiki/Page_cache
  1478. .PP
  1479. tl;dr: * cache.files=off: Disables page caching.
  1480. Underlying files cached, mergerfs files are not.
  1481. * cache.files=partial: Enables page caching.
  1482. Underlying files cached, mergerfs files cached while open.
  1483. * cache.files=full: Enables page caching.
  1484. Underlying files cached, mergerfs files cached across opens.
  1485. * cache.files=auto\-full: Enables page caching.
  1486. Underlying files cached, mergerfs files cached across opens if mtime and
  1487. size are unchanged since previous open.
  1488. * cache.files=libfuse: follow traditional libfuse \f[C]direct_io\f[R],
  1489. \f[C]kernel_cache\f[R], and \f[C]auto_cache\f[R] arguments.
  1490. .PP
  1491. FUSE, which mergerfs uses, offers a number of page caching modes.
  1492. mergerfs tries to simplify their use via the \f[C]cache.files\f[R]
  1493. option.
  1494. It can and should replace usage of \f[C]direct_io\f[R],
  1495. \f[C]kernel_cache\f[R], and \f[C]auto_cache\f[R].
  1496. .PP
  1497. Due to mergerfs using FUSE and therefore being a userland process
  1498. proxying existing filesystems the kernel will double cache the content
  1499. being read and written through mergerfs.
  1500. Once from the underlying filesystem and once from mergerfs (it sees them
  1501. as two separate entities).
  1502. Using \f[C]cache.files=off\f[R] will keep the double caching from
  1503. happening by disabling caching of mergerfs but this has the side effect
  1504. that \f[I]all\f[R] read and write calls will be passed to mergerfs which
  1505. may be slower than enabling caching, you lose shared \f[C]mmap\f[R]
  1506. support which can affect apps such as rtorrent, and no read\-ahead will
  1507. take place.
  1508. The kernel will still cache the underlying filesystem data but that only
  1509. helps so much given mergerfs will still process all requests.
  1510. .PP
  1511. If you do enable file page caching,
  1512. \f[C]cache.files=partial|full|auto\-full\f[R], you should also enable
  1513. \f[C]dropcacheonclose\f[R] which will cause mergerfs to instruct the
  1514. kernel to flush the underlying file\[cq]s page cache when the file is
  1515. closed.
  1516. This behavior is the same as the rsync fadvise / drop cache patch and
  1517. Feh\[cq]s nocache project.
  1518. .PP
  1519. If most files are read once through and closed (like media) it is best
  1520. to enable \f[C]dropcacheonclose\f[R] regardless of caching mode in order
  1521. to minimize buffer bloat.
  1522. .PP
  1523. It is difficult to balance memory usage, cache bloat & duplication, and
  1524. performance.
  1525. Ideally mergerfs would be able to disable caching for the files it
  1526. reads/writes but allow page caching for itself.
  1527. That would limit the FUSE overhead.
  1528. However, there isn\[cq]t a good way to achieve this.
  1529. It would need to open all files with O_DIRECT which places limitations
  1530. on the what underlying filesystems would be supported and complicates
  1531. the code.
  1532. .PP
  1533. kernel documentation:
  1534. https://www.kernel.org/doc/Documentation/filesystems/fuse\-io.txt
  1535. .SS entry & attribute caching
  1536. .PP
  1537. Given the relatively high cost of FUSE due to the kernel <\-> userspace
  1538. round trips there are kernel side caches for file entries and
  1539. attributes.
  1540. The entry cache limits the \f[C]lookup\f[R] calls to mergerfs which ask
  1541. if a file exists.
  1542. The attribute cache limits the need to make \f[C]getattr\f[R] calls to
  1543. mergerfs which provide file attributes (mode, size, type, etc.).
  1544. As with the page cache these should not be used if the underlying
  1545. filesystems are being manipulated at the same time as it could lead to
  1546. odd behavior or data corruption.
  1547. The options for setting these are \f[C]cache.entry\f[R] and
  1548. \f[C]cache.negative_entry\f[R] for the entry cache and
  1549. \f[C]cache.attr\f[R] for the attributes cache.
  1550. \f[C]cache.negative_entry\f[R] refers to the timeout for negative
  1551. responses to lookups (non\-existent files).
  1552. .SS writeback caching
  1553. .PP
  1554. When \f[C]cache.files\f[R] is enabled the default is for it to perform
  1555. writethrough caching.
  1556. This behavior won\[cq]t help improve performance as each write still
  1557. goes one for one through the filesystem.
  1558. By enabling the FUSE writeback cache small writes may be aggregated by
  1559. the kernel and then sent to mergerfs as one larger request.
  1560. This can greatly improve the throughput for apps which write to files
  1561. inefficiently.
  1562. The amount the kernel can aggregate is limited by the size of a FUSE
  1563. message.
  1564. Read the \f[C]fuse_msg_size\f[R] section for more details.
  1565. .PP
  1566. There is a small side effect as a result of enabling writeback caching.
  1567. Underlying files won\[cq]t ever be opened with O_APPEND or O_WRONLY.
  1568. The former because the kernel then manages append mode and the latter
  1569. because the kernel may request file data from mergerfs to populate the
  1570. write cache.
  1571. The O_APPEND change means that if a file is changed outside of mergerfs
  1572. it could lead to corruption as the kernel won\[cq]t know the end of the
  1573. file has changed.
  1574. That said any time you use caching you should keep from using the same
  1575. file outside of mergerfs at the same time.
  1576. .PP
  1577. Note that if an application is properly sizing writes then writeback
  1578. caching will have little or no effect.
  1579. It will only help with writes of sizes below the FUSE message size (128K
  1580. on older kernels, 1M on newer).
  1581. .SS policy caching
  1582. .PP
  1583. Policies are run every time a function (with a policy as mentioned
  1584. above) is called.
  1585. These policies can be expensive depending on mergerfs\[cq] setup and
  1586. client usage patterns.
  1587. Generally we wouldn\[cq]t want to cache policy results because it may
  1588. result in stale responses if the underlying drives are used directly.
  1589. .PP
  1590. The \f[C]open\f[R] policy cache will cache the result of an
  1591. \f[C]open\f[R] policy for a particular input for \f[C]cache.open\f[R]
  1592. seconds or until the file is unlinked.
  1593. Each file close (release) will randomly chose to clean up the cache of
  1594. expired entries.
  1595. .PP
  1596. This cache is really only useful in cases where you have a large number
  1597. of branches and \f[C]open\f[R] is called on the same files repeatedly
  1598. (like \f[B]Transmission\f[R] which opens and closes a file on every
  1599. read/write presumably to keep file handle usage low).
  1600. .SS statfs caching
  1601. .PP
  1602. Of the syscalls used by mergerfs in policies the \f[C]statfs\f[R] /
  1603. \f[C]statvfs\f[R] call is perhaps the most expensive.
  1604. It\[cq]s used to find out the available space of a drive and whether it
  1605. is mounted read\-only.
  1606. Depending on the setup and usage pattern these queries can be relatively
  1607. costly.
  1608. When \f[C]cache.statfs\f[R] is enabled all calls to \f[C]statfs\f[R] by
  1609. a policy will be cached for the number of seconds its set to.
  1610. .PP
  1611. Example: If the create policy is \f[C]mfs\f[R] and the timeout is 60
  1612. then for that 60 seconds the same drive will be returned as the target
  1613. for creates because the available space won\[cq]t be updated for that
  1614. time.
  1615. .SS symlink caching
  1616. .PP
  1617. As of version 4.20 Linux supports symlink caching.
  1618. Significant performance increases can be had in workloads which use a
  1619. lot of symlinks.
  1620. Setting \f[C]cache.symlinks=true\f[R] will result in requesting symlink
  1621. caching from the kernel only if supported.
  1622. As a result its safe to enable it on systems prior to 4.20.
  1623. That said it is disabled by default for now.
  1624. You can see if caching is enabled by querying the xattr
  1625. \f[C]user.mergerfs.cache.symlinks\f[R] but given it must be requested at
  1626. startup you can not change it at runtime.
  1627. .SS readdir caching
  1628. .PP
  1629. As of version 4.20 Linux supports readdir caching.
  1630. This can have a significant impact on directory traversal.
  1631. Especially when combined with entry (\f[C]cache.entry\f[R]) and
  1632. attribute (\f[C]cache.attr\f[R]) caching.
  1633. Setting \f[C]cache.readdir=true\f[R] will result in requesting readdir
  1634. caching from the kernel on each \f[C]opendir\f[R].
  1635. If the kernel doesn\[cq]t support readdir caching setting the option to
  1636. \f[C]true\f[R] has no effect.
  1637. This option is configurable at runtime via xattr
  1638. \f[C]user.mergerfs.cache.readdir\f[R].
  1639. .SS tiered caching
  1640. .PP
  1641. Some storage technologies support what some call \[lq]tiered\[rq]
  1642. caching.
  1643. The placing of usually smaller, faster storage as a transparent cache to
  1644. larger, slower storage.
  1645. NVMe, SSD, Optane in front of traditional HDDs for instance.
  1646. .PP
  1647. MergerFS does not natively support any sort of tiered caching.
  1648. Most users have no use for such a feature and its inclusion would
  1649. complicate the code.
  1650. However, there are a few situations where a cache drive could help with
  1651. a typical mergerfs setup.
  1652. .IP "1." 3
  1653. Fast network, slow drives, many readers: You\[cq]ve a 10+Gbps network
  1654. with many readers and your regular drives can\[cq]t keep up.
  1655. .IP "2." 3
  1656. Fast network, slow drives, small\[cq]ish bursty writes: You have a
  1657. 10+Gbps network and wish to transfer amounts of data less than your
  1658. cache drive but wish to do so quickly.
  1659. .PP
  1660. With #1 its arguable if you should be using mergerfs at all.
  1661. RAID would probably be the better solution.
  1662. If you\[cq]re going to use mergerfs there are other tactics that may
  1663. help: spreading the data across drives (see the mergerfs.dup tool) and
  1664. setting \f[C]func.open=rand\f[R], using \f[C]symlinkify\f[R], or using
  1665. dm\-cache or a similar technology to add tiered cache to the underlying
  1666. device.
  1667. .PP
  1668. With #2 one could use dm\-cache as well but there is another solution
  1669. which requires only mergerfs and a cronjob.
  1670. .IP "1." 3
  1671. Create 2 mergerfs pools.
  1672. One which includes just the slow drives and one which has both the fast
  1673. drives (SSD,NVME,etc.) and slow drives.
  1674. .IP "2." 3
  1675. The `cache' pool should have the cache drives listed first.
  1676. .IP "3." 3
  1677. The best \f[C]create\f[R] policies to use for the `cache' pool would
  1678. probably be \f[C]ff\f[R], \f[C]epff\f[R], \f[C]lfs\f[R], or
  1679. \f[C]eplfs\f[R].
  1680. The latter two under the assumption that the cache drive(s) are far
  1681. smaller than the backing drives.
  1682. If using path preserving policies remember that you\[cq]ll need to
  1683. manually create the core directories of those paths you wish to be
  1684. cached.
  1685. Be sure the permissions are in sync.
  1686. Use \f[C]mergerfs.fsck\f[R] to check / correct them.
  1687. You could also tag the slow drives as \f[C]=NC\f[R] though that\[cq]d
  1688. mean if the cache drives fill you\[cq]d get \[lq]out of space\[rq]
  1689. errors.
  1690. .IP "4." 3
  1691. Enable \f[C]moveonenospc\f[R] and set \f[C]minfreespace\f[R]
  1692. appropriately.
  1693. To make sure there is enough room on the \[lq]slow\[rq] pool you might
  1694. want to set \f[C]minfreespace\f[R] to at least as large as the size of
  1695. the largest cache drive if not larger.
  1696. This way in the worst case the whole of the cache drive(s) can be moved
  1697. to the other drives.
  1698. .IP "5." 3
  1699. Set your programs to use the cache pool.
  1700. .IP "6." 3
  1701. Save one of the below scripts or create you\[cq]re own.
  1702. .IP "7." 3
  1703. Use \f[C]cron\f[R] (as root) to schedule the command at whatever
  1704. frequency is appropriate for your workflow.
  1705. .SS time based expiring
  1706. .PP
  1707. Move files from cache to backing pool based only on the last time the
  1708. file was accessed.
  1709. Replace \f[C]\-atime\f[R] with \f[C]\-amin\f[R] if you want minutes
  1710. rather than days.
  1711. May want to use the \f[C]fadvise\f[R] / \f[C]\-\-drop\-cache\f[R]
  1712. version of rsync or run rsync with the tool \[lq]nocache\[rq].
  1713. .PP
  1714. \f[I]NOTE:\f[R] The arguments to these scripts include the cache
  1715. \f[B]drive\f[R].
  1716. Not the pool with the cache drive.
  1717. You could have data loss if the source is the cache pool.
  1718. .IP
  1719. .nf
  1720. \f[C]
  1721. #!/bin/bash
  1722. if [ $# != 3 ]; then
  1723. echo \[dq]usage: $0 <cache\-drive> <backing\-pool> <days\-old>\[dq]
  1724. exit 1
  1725. fi
  1726. CACHE=\[dq]${1}\[dq]
  1727. BACKING=\[dq]${2}\[dq]
  1728. N=${3}
  1729. find \[dq]${CACHE}\[dq] \-type f \-atime +${N} \-printf \[aq]%P\[rs]n\[aq] | \[rs]
  1730. rsync \-\-files\-from=\- \-axqHAXWES \-\-preallocate \-\-remove\-source\-files \[dq]${CACHE}/\[dq] \[dq]${BACKING}/\[dq]
  1731. \f[R]
  1732. .fi
  1733. .SS percentage full expiring
  1734. .PP
  1735. Move the oldest file from the cache to the backing pool.
  1736. Continue till below percentage threshold.
  1737. .PP
  1738. \f[I]NOTE:\f[R] The arguments to these scripts include the cache
  1739. \f[B]drive\f[R].
  1740. Not the pool with the cache drive.
  1741. You could have data loss if the source is the cache pool.
  1742. .IP
  1743. .nf
  1744. \f[C]
  1745. #!/bin/bash
  1746. if [ $# != 3 ]; then
  1747. echo \[dq]usage: $0 <cache\-drive> <backing\-pool> <percentage>\[dq]
  1748. exit 1
  1749. fi
  1750. CACHE=\[dq]${1}\[dq]
  1751. BACKING=\[dq]${2}\[dq]
  1752. PERCENTAGE=${3}
  1753. set \-o errexit
  1754. while [ $(df \-\-output=pcent \[dq]${CACHE}\[dq] | grep \-v Use | cut \-d\[aq]%\[aq] \-f1) \-gt ${PERCENTAGE} ]
  1755. do
  1756. FILE=$(find \[dq]${CACHE}\[dq] \-type f \-printf \[aq]%A\[at] %P\[rs]n\[aq] | \[rs]
  1757. sort | \[rs]
  1758. head \-n 1 | \[rs]
  1759. cut \-d\[aq] \[aq] \-f2\-)
  1760. test \-n \[dq]${FILE}\[dq]
  1761. rsync \-axqHAXWESR \-\-preallocate \-\-remove\-source\-files \[dq]${CACHE}/./${FILE}\[dq] \[dq]${BACKING}/\[dq]
  1762. done
  1763. \f[R]
  1764. .fi
  1765. .SH PERFORMANCE
  1766. .PP
  1767. mergerfs is at its core just a proxy and therefore its theoretical max
  1768. performance is that of the underlying devices.
  1769. However, given it is a FUSE filesystem working from userspace there is
  1770. an increase in overhead relative to kernel based solutions.
  1771. That said the performance can match the theoretical max but it depends
  1772. greatly on the system\[cq]s configuration.
  1773. Especially when adding network filesystems into the mix there are many
  1774. variables which can impact performance.
  1775. Drive speeds and latency, network speeds and latency, general
  1776. concurrency, read/write sizes, etc.
  1777. Unfortunately, given the number of variables it has been difficult to
  1778. find a single set of settings which provide optimal performance.
  1779. If you\[cq]re having performance issues please look over the suggestions
  1780. below (including the benchmarking section.)
  1781. .PP
  1782. NOTE: be sure to read about these features before changing them to
  1783. understand what behaviors it may impact
  1784. .IP \[bu] 2
  1785. enable (or disable) \f[C]splice_move\f[R], \f[C]splice_read\f[R], and
  1786. \f[C]splice_write\f[R]
  1787. .IP \[bu] 2
  1788. disable \f[C]security_capability\f[R] and/or \f[C]xattr\f[R]
  1789. .IP \[bu] 2
  1790. increase cache timeouts \f[C]cache.attr\f[R], \f[C]cache.entry\f[R],
  1791. \f[C]cache.negative_entry\f[R]
  1792. .IP \[bu] 2
  1793. enable (or disable) page caching (\f[C]cache.files\f[R])
  1794. .IP \[bu] 2
  1795. enable \f[C]cache.writeback\f[R]
  1796. .IP \[bu] 2
  1797. enable \f[C]cache.open\f[R]
  1798. .IP \[bu] 2
  1799. enable \f[C]cache.statfs\f[R]
  1800. .IP \[bu] 2
  1801. enable \f[C]cache.symlinks\f[R]
  1802. .IP \[bu] 2
  1803. enable \f[C]cache.readdir\f[R]
  1804. .IP \[bu] 2
  1805. change the number of worker threads
  1806. .IP \[bu] 2
  1807. disable \f[C]posix_acl\f[R]
  1808. .IP \[bu] 2
  1809. disable \f[C]async_read\f[R]
  1810. .IP \[bu] 2
  1811. test theoretical performance using \f[C]nullrw\f[R] or mounting a ram
  1812. disk
  1813. .IP \[bu] 2
  1814. use \f[C]symlinkify\f[R] if your data is largely static and read\-only
  1815. .IP \[bu] 2
  1816. use tiered cache drives
  1817. .IP \[bu] 2
  1818. use LVM and LVM cache to place a SSD in front of your HDDs
  1819. .PP
  1820. If you come across a setting that significantly impacts performance
  1821. please contact trapexit so he may investigate further.
  1822. .SH BENCHMARKING
  1823. .PP
  1824. Filesystems are complicated.
  1825. They do many things and many of those are interconnected.
  1826. Additionally, the OS, drivers, hardware, etc.
  1827. all can impact performance.
  1828. Therefore, when benchmarking, it is \f[B]necessary\f[R] that the test
  1829. focus as narrowly as possible.
  1830. .PP
  1831. For most throughput is the key benchmark.
  1832. To test throughput \f[C]dd\f[R] is useful but \f[B]must\f[R] be used
  1833. with the correct settings in order to ensure the filesystem or device is
  1834. actually being tested.
  1835. The OS can and will cache data.
  1836. Without forcing synchronous reads and writes and/or disabling caching
  1837. the values returned will not be representative of the device\[cq]s true
  1838. performance.
  1839. .PP
  1840. When benchmarking through mergerfs ensure you only use 1 branch to
  1841. remove any possibility of the policies complicating the situation.
  1842. Benchmark the underlying filesystem first and then mount mergerfs over
  1843. it and test again.
  1844. If you\[cq]re experience speeds below your expectation you will need to
  1845. narrow down precisely which component is leading to the slowdown.
  1846. Preferably test the following in the order listed (but not combined).
  1847. .IP "1." 3
  1848. Enable \f[C]nullrw\f[R] mode with \f[C]nullrw=true\f[R].
  1849. This will effectively make reads and writes no\-ops.
  1850. Removing the underlying device / filesystem from the equation.
  1851. This will give us the top theoretical speeds.
  1852. .IP "2." 3
  1853. Mount mergerfs over \f[C]tmpfs\f[R].
  1854. \f[C]tmpfs\f[R] is a RAM disk.
  1855. Extremely high speed and very low latency.
  1856. This is a more realistic best case scenario.
  1857. Example: \f[C]mount \-t tmpfs \-o size=2G tmpfs /tmp/tmpfs\f[R]
  1858. .IP "3." 3
  1859. Mount mergerfs over a local drive.
  1860. NVMe, SSD, HDD, etc.
  1861. If you have more than one I\[cq]d suggest testing each of them as drives
  1862. and/or controllers (their drivers) could impact performance.
  1863. .IP "4." 3
  1864. Finally, if you intend to use mergerfs with a network filesystem, either
  1865. as the source of data or to combine with another through mergerfs, test
  1866. each of those alone as above.
  1867. .PP
  1868. Once you find the component which has the performance issue you can do
  1869. further testing with different options to see if they impact
  1870. performance.
  1871. For reads and writes the most relevant would be: \f[C]cache.files\f[R],
  1872. \f[C]async_read\f[R], \f[C]splice_move\f[R], \f[C]splice_read\f[R],
  1873. \f[C]splice_write\f[R].
  1874. Less likely but relevant when using NFS or with certain filesystems
  1875. would be \f[C]security_capability\f[R], \f[C]xattr\f[R], and
  1876. \f[C]posix_acl\f[R].
  1877. If you find a specific system, drive, filesystem, controller, etc.
  1878. that performs poorly contact trapexit so he may investigate further.
  1879. .PP
  1880. Sometimes the problem is really the application accessing or writing
  1881. data through mergerfs.
  1882. Some software use small buffer sizes which can lead to more requests and
  1883. therefore greater overhead.
  1884. You can test this out yourself by replace \f[C]bs=1M\f[R] in the
  1885. examples below with \f[C]ibs\f[R] or \f[C]obs\f[R] and using a size of
  1886. \f[C]512\f[R] instead of \f[C]1M\f[R].
  1887. In one example test using \f[C]nullrw\f[R] the write speed dropped from
  1888. 4.9GB/s to 69.7MB/s when moving from \f[C]1M\f[R] to \f[C]512\f[R].
  1889. Similar results were had when testing reads.
  1890. Small writes overhead may be improved by leveraging a write cache but in
  1891. casual tests little gain was found.
  1892. More tests will need to be done before this feature would become
  1893. available.
  1894. If you have an app that appears slow with mergerfs it could be due to
  1895. this.
  1896. Contact trapexit so he may investigate further.
  1897. .SS write benchmark
  1898. .IP
  1899. .nf
  1900. \f[C]
  1901. $ dd if=/dev/zero of=/mnt/mergerfs/1GB.file bs=1M count=1024 oflag=nocache conv=fdatasync status=progress
  1902. \f[R]
  1903. .fi
  1904. .SS read benchmark
  1905. .IP
  1906. .nf
  1907. \f[C]
  1908. $ dd if=/mnt/mergerfs/1GB.file of=/dev/null bs=1M count=1024 iflag=nocache conv=fdatasync status=progress
  1909. \f[R]
  1910. .fi
  1911. .SH TIPS / NOTES
  1912. .IP \[bu] 2
  1913. This document is very literal and thorough.
  1914. Unless there is a bug things work as described.
  1915. If a suspected feature isn\[cq]t mentioned it doesn\[cq]t exist.
  1916. .IP \[bu] 2
  1917. Ensure you\[cq]re using the latest version.
  1918. Few distros have the latest version.
  1919. .IP \[bu] 2
  1920. \f[B]use_ino\f[R] will only work when used with mergerfs 2.18.0 and
  1921. above.
  1922. .IP \[bu] 2
  1923. Run mergerfs as \f[C]root\f[R] (with \f[B]allow_other\f[R]) unless
  1924. you\[cq]re merging paths which are owned by the same user otherwise
  1925. strange permission issues may arise.
  1926. .IP \[bu] 2
  1927. https://github.com/trapexit/backup\-and\-recovery\-howtos : A set of
  1928. guides / howtos on creating a data storage system, backing it up,
  1929. maintaining it, and recovering from failure.
  1930. .IP \[bu] 2
  1931. If you don\[cq]t see some directories and files you expect in a merged
  1932. point or policies seem to skip drives be sure the user has permission to
  1933. all the underlying directories.
  1934. Use \f[C]mergerfs.fsck\f[R] to audit the drive for out of sync
  1935. permissions.
  1936. .IP \[bu] 2
  1937. Do \f[B]not\f[R] use \f[C]cache.files=off\f[R] if you expect
  1938. applications (such as rtorrent) to use
  1939. mmap (http://linux.die.net/man/2/mmap) files.
  1940. Shared mmap is not currently supported in FUSE w/ page caching disabled.
  1941. Enabling \f[C]dropcacheonclose\f[R] is recommended when
  1942. \f[C]cache.files=partial|full|auto\-full\f[R].
  1943. .IP \[bu] 2
  1944. Kodi (http://kodi.tv), Plex (http://plex.tv),
  1945. Subsonic (http://subsonic.org), etc.
  1946. can use directory mtime (http://linux.die.net/man/2/stat) to more
  1947. efficiently determine whether to scan for new content rather than simply
  1948. performing a full scan.
  1949. If using the default \f[B]getattr\f[R] policy of \f[B]ff\f[R] it\[cq]s
  1950. possible those programs will miss an update on account of it returning
  1951. the first directory found\[cq]s \f[B]stat\f[R] info and its a later
  1952. directory on another mount which had the \f[B]mtime\f[R] recently
  1953. updated.
  1954. To fix this you will want to set \f[B]func.getattr=newest\f[R].
  1955. Remember though that this is just \f[B]stat\f[R].
  1956. If the file is later \f[B]open\f[R]\[cq]ed or \f[B]unlink\f[R]\[cq]ed
  1957. and the policy is different for those then a completely different file
  1958. or directory could be acted on.
  1959. .IP \[bu] 2
  1960. Some policies mixed with some functions may result in strange behaviors.
  1961. Not that some of these behaviors and race conditions couldn\[cq]t happen
  1962. outside \f[B]mergerfs\f[R] but that they are far more likely to occur on
  1963. account of the attempt to merge together multiple sources of data which
  1964. could be out of sync due to the different policies.
  1965. .IP \[bu] 2
  1966. For consistency its generally best to set \f[B]category\f[R] wide
  1967. policies rather than individual \f[B]func\f[R]\[cq]s.
  1968. This will help limit the confusion of tools such as
  1969. rsync (http://linux.die.net/man/1/rsync).
  1970. However, the flexibility is there if needed.
  1971. .SH KNOWN ISSUES / BUGS
  1972. .SS kernel issues & bugs
  1973. .PP
  1974. <https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs>
  1975. .SS directory mtime is not being updated
  1976. .PP
  1977. Remember that the default policy for \f[C]getattr\f[R] is \f[C]ff\f[R].
  1978. The information for the first directory found will be returned.
  1979. If it wasn\[cq]t the directory which had been updated then it will
  1980. appear outdated.
  1981. .PP
  1982. The reason this is the default is because any other policy would be more
  1983. expensive and for many applications it is unnecessary.
  1984. To always return the directory with the most recent mtime or a faked
  1985. value based on all found would require a scan of all drives.
  1986. .PP
  1987. If you always want the directory information from the one with the most
  1988. recent mtime then use the \f[C]newest\f[R] policy for \f[C]getattr\f[R].
  1989. .SS `mv /mnt/pool/foo /mnt/disk1/foo' removes `foo'
  1990. .PP
  1991. This is not a bug.
  1992. .PP
  1993. Run in verbose mode to better understand what\[cq]s happening:
  1994. .IP
  1995. .nf
  1996. \f[C]
  1997. $ mv \-v /mnt/pool/foo /mnt/disk1/foo
  1998. copied \[aq]/mnt/pool/foo\[aq] \-> \[aq]/mnt/disk1/foo\[aq]
  1999. removed \[aq]/mnt/pool/foo\[aq]
  2000. $ ls /mnt/pool/foo
  2001. ls: cannot access \[aq]/mnt/pool/foo\[aq]: No such file or directory
  2002. \f[R]
  2003. .fi
  2004. .PP
  2005. \f[C]mv\f[R], when working across devices, is copying the source to
  2006. target and then removing the source.
  2007. Since the source \f[B]is\f[R] the target in this case, depending on the
  2008. unlink policy, it will remove the just copied file and other files
  2009. across the branches.
  2010. .PP
  2011. If you want to move files to one drive just copy them there and use
  2012. mergerfs.dedup to clean up the old paths or manually remove them from
  2013. the branches directly.
  2014. .SS cached memory appears greater than it should be
  2015. .PP
  2016. Use \f[C]cache.files=off\f[R] and/or \f[C]dropcacheonclose=true\f[R].
  2017. See the section on page caching.
  2018. .SS NFS clients returning ESTALE / Stale file handle
  2019. .PP
  2020. NFS does not like out of band changes.
  2021. That is especially true of inode values.
  2022. .PP
  2023. Be sure to use the following options:
  2024. .IP \[bu] 2
  2025. noforget
  2026. .IP \[bu] 2
  2027. use_ino
  2028. .IP \[bu] 2
  2029. inodecalc=path\-hash
  2030. .SS rtorrent fails with ENODEV (No such device)
  2031. .PP
  2032. Be sure to set \f[C]cache.files=partial|full|auto\-full\f[R] or turn off
  2033. \f[C]direct_io\f[R].
  2034. rtorrent and some other applications use
  2035. mmap (http://linux.die.net/man/2/mmap) to read and write to files and
  2036. offer no fallback to traditional methods.
  2037. FUSE does not currently support mmap while using \f[C]direct_io\f[R].
  2038. There may be a performance penalty on writes with \f[C]direct_io\f[R]
  2039. off as well as the problem of double caching but it\[cq]s the only way
  2040. to get such applications to work.
  2041. If the performance loss is too high for other apps you can mount
  2042. mergerfs twice.
  2043. Once with \f[C]direct_io\f[R] enabled and one without it.
  2044. Be sure to set \f[C]dropcacheonclose=true\f[R] if not using
  2045. \f[C]direct_io\f[R].
  2046. .SS Plex doesn\[cq]t work with mergerfs
  2047. .PP
  2048. It does.
  2049. If you\[cq]re trying to put Plex\[cq]s config / metadata / database on
  2050. mergerfs you can\[cq]t set \f[C]cache.files=off\f[R] because Plex is
  2051. using sqlite3 with mmap enabled.
  2052. Shared mmap is not supported by Linux\[cq]s FUSE implementation when
  2053. page caching is disabled.
  2054. To fix this place the data elsewhere (preferable) or enable
  2055. \f[C]cache.files\f[R] (with \f[C]dropcacheonclose=true\f[R]).
  2056. Sqlite3 does not need mmap but the developer needs to fall back to
  2057. standard IO if mmap fails.
  2058. .PP
  2059. If the issue is that scanning doesn\[cq]t seem to pick up media then be
  2060. sure to set \f[C]func.getattr=newest\f[R] though generally a full scan
  2061. will pick up all media anyway.
  2062. .SS When a program tries to move or rename a file it fails
  2063. .PP
  2064. Please read the section above regarding rename & link.
  2065. .PP
  2066. The problem is that many applications do not properly handle
  2067. \f[C]EXDEV\f[R] errors which \f[C]rename\f[R] and \f[C]link\f[R] may
  2068. return even though they are perfectly valid situations which do not
  2069. indicate actual drive or OS errors.
  2070. The error will only be returned by mergerfs if using a path preserving
  2071. policy as described in the policy section above.
  2072. If you do not care about path preservation simply change the mergerfs
  2073. policy to the non\-path preserving version.
  2074. For example: \f[C]\-o category.create=mfs\f[R]
  2075. .PP
  2076. Ideally the offending software would be fixed and it is recommended that
  2077. if you run into this problem you contact the software\[cq]s author and
  2078. request proper handling of \f[C]EXDEV\f[R] errors.
  2079. .SS my 32bit software has problems
  2080. .PP
  2081. Some software have problems with 64bit inode values.
  2082. The symptoms can include EOVERFLOW errors when trying to list files.
  2083. You can address this by setting \f[C]inodecalc\f[R] to one of the 32bit
  2084. based algos as described in the relevant section.
  2085. .SS Samba: Moving files / directories fails
  2086. .PP
  2087. Workaround: Copy the file/directory and then remove the original rather
  2088. than move.
  2089. .PP
  2090. This isn\[cq]t an issue with Samba but some SMB clients.
  2091. GVFS\-fuse v1.20.3 and prior (found in Ubuntu 14.04 among others) failed
  2092. to handle certain error codes correctly.
  2093. Particularly \f[B]STATUS_NOT_SAME_DEVICE\f[R] which comes from the
  2094. \f[B]EXDEV\f[R] which is returned by \f[B]rename\f[R] when the call is
  2095. crossing mount points.
  2096. When a program gets an \f[B]EXDEV\f[R] it needs to explicitly take an
  2097. alternate action to accomplish its goal.
  2098. In the case of \f[B]mv\f[R] or similar it tries \f[B]rename\f[R] and on
  2099. \f[B]EXDEV\f[R] falls back to a manual copying of data between the two
  2100. locations and unlinking the source.
  2101. In these older versions of GVFS\-fuse if it received \f[B]EXDEV\f[R] it
  2102. would translate that into \f[B]EIO\f[R].
  2103. This would cause \f[B]mv\f[R] or most any application attempting to move
  2104. files around on that SMB share to fail with a IO error.
  2105. .PP
  2106. GVFS\-fuse v1.22.0 (https://bugzilla.gnome.org/show_bug.cgi?id=734568)
  2107. and above fixed this issue but a large number of systems use the older
  2108. release.
  2109. On Ubuntu the version can be checked by issuing
  2110. \f[C]apt\-cache showpkg gvfs\-fuse\f[R].
  2111. Most distros released in 2015 seem to have the updated release and will
  2112. work fine but older systems may not.
  2113. Upgrading gvfs\-fuse or the distro in general will address the problem.
  2114. .PP
  2115. In Apple\[cq]s MacOSX 10.9 they replaced Samba (client and server) with
  2116. their own product.
  2117. It appears their new client does not handle \f[B]EXDEV\f[R] either and
  2118. responds similar to older release of gvfs on Linux.
  2119. .SS Trashing files occasionally fails
  2120. .PP
  2121. This is the same issue as with Samba.
  2122. \f[C]rename\f[R] returns \f[C]EXDEV\f[R] (in our case that will really
  2123. only happen with path preserving policies like \f[C]epmfs\f[R]) and the
  2124. software doesn\[cq]t handle the situation well.
  2125. This is unfortunately a common failure of software which moves files
  2126. around.
  2127. The standard indicates that an implementation \f[C]MAY\f[R] choose to
  2128. support non\-user home directory trashing of files (which is a
  2129. \f[C]MUST\f[R]).
  2130. The implementation \f[C]MAY\f[R] also support \[lq]top directory
  2131. trashes\[rq] which many probably do.
  2132. .PP
  2133. To create a \f[C]$topdir/.Trash\f[R] directory as defined in the
  2134. standard use the
  2135. mergerfs\-tools (https://github.com/trapexit/mergerfs-tools) tool
  2136. \f[C]mergerfs.mktrash\f[R].
  2137. .SS tar: Directory renamed before its status could be extracted
  2138. .PP
  2139. Make sure to use the \f[C]use_ino\f[R] option.
  2140. .SS Supplemental user groups
  2141. .PP
  2142. Due to the overhead of
  2143. getgroups/setgroups (http://linux.die.net/man/2/setgroups) mergerfs
  2144. utilizes a cache.
  2145. This cache is opportunistic and per thread.
  2146. Each thread will query the supplemental groups for a user when that
  2147. particular thread needs to change credentials and will keep that data
  2148. for the lifetime of the thread.
  2149. This means that if a user is added to a group it may not be picked up
  2150. without the restart of mergerfs.
  2151. However, since the high level FUSE API\[cq]s (at least the standard
  2152. version) thread pool dynamically grows and shrinks it\[cq]s possible
  2153. that over time a thread will be killed and later a new thread with no
  2154. cache will start and query the new data.
  2155. .PP
  2156. The gid cache uses fixed storage to simplify the design and be
  2157. compatible with older systems which may not have C++11 compilers.
  2158. There is enough storage for 256 users\[cq] supplemental groups.
  2159. Each user is allowed up to 32 supplemental groups.
  2160. Linux >= 2.6.3 allows up to 65535 groups per user but most other *nixs
  2161. allow far less.
  2162. NFS allowing only 16.
  2163. The system does handle overflow gracefully.
  2164. If the user has more than 32 supplemental groups only the first 32 will
  2165. be used.
  2166. If more than 256 users are using the system when an uncached user is
  2167. found it will evict an existing user\[cq]s cache at random.
  2168. So long as there aren\[cq]t more than 256 active users this should be
  2169. fine.
  2170. If either value is too low for your needs you will have to modify
  2171. \f[C]gidcache.hpp\f[R] to increase the values.
  2172. Note that doing so will increase the memory needed by each thread.
  2173. .PP
  2174. While not a bug some users have found when using containers that
  2175. supplemental groups defined inside the container don\[cq]t work properly
  2176. with regard to permissions.
  2177. This is expected as mergerfs lives outside the container and therefore
  2178. is querying the host\[cq]s group database.
  2179. There might be a hack to work around this (make mergerfs read the
  2180. /etc/group file in the container) but it is not yet implemented and
  2181. would be limited to Linux and the /etc/group DB.
  2182. Preferably users would mount in the host group file into the containers
  2183. or use a standard shared user & groups technology like NIS or LDAP.
  2184. .SS mergerfs or libfuse crashing
  2185. .PP
  2186. First\&... always upgrade to the latest version unless told otherwise.
  2187. .PP
  2188. If using mergerfs below 2.22.0:
  2189. .PP
  2190. If suddenly the mergerfs mount point disappears and
  2191. \f[C]Transport endpoint is not connected\f[R] is returned when
  2192. attempting to perform actions within the mount directory \f[B]and\f[R]
  2193. the version of libfuse (use \f[C]mergerfs \-v\f[R] to find the version)
  2194. is older than \f[C]2.9.4\f[R] its likely due to a bug in libfuse.
  2195. Affected versions of libfuse can be found in Debian Wheezy, Ubuntu
  2196. Precise and others.
  2197. .PP
  2198. In order to fix this please install newer versions of libfuse.
  2199. If using a Debian based distro (Debian,Ubuntu,Mint) you can likely just
  2200. install newer versions of
  2201. libfuse (https://packages.debian.org/unstable/libfuse2) and
  2202. fuse (https://packages.debian.org/unstable/fuse) from the repo of a
  2203. newer release.
  2204. .PP
  2205. If using mergerfs at or above 2.22.0:
  2206. .PP
  2207. First upgrade if possible, check the known bugs section, and contact
  2208. trapexit.
  2209. .SS mergerfs appears to be crashing or exiting
  2210. .PP
  2211. There seems to be an issue with Linux version \f[C]4.9.0\f[R] and above
  2212. in which an invalid message appears to be transmitted to libfuse (used
  2213. by mergerfs) causing it to exit.
  2214. No messages will be printed in any logs as it\[cq]s not a proper crash.
  2215. Debugging of the issue is still ongoing and can be followed via the
  2216. fuse\-devel
  2217. thread (https://sourceforge.net/p/fuse/mailman/message/35662577).
  2218. .SS rm: fts_read failed: No such file or directory
  2219. .PP
  2220. Please update.
  2221. This is only happened to mergerfs versions at or below v2.25.x and will
  2222. not occur in more recent versions.
  2223. .SH FAQ
  2224. .SS How well does mergerfs scale? Is it \[lq]production ready?\[rq]
  2225. .PP
  2226. Users have reported running mergerfs on everything from a Raspberry Pi
  2227. to dual socket Xeon systems with >20 cores.
  2228. I\[cq]m aware of at least a few companies which use mergerfs in
  2229. production.
  2230. Open Media Vault (https://www.openmediavault.org) includes mergerfs as
  2231. its sole solution for pooling drives.
  2232. The author of mergerfs had it running for over 300 days managing 16+
  2233. drives with reasonably heavy 24/7 read and write usage.
  2234. Stopping only after the machine\[cq]s power supply died.
  2235. .PP
  2236. Most serious issues (crashes or data corruption) have been due to kernel
  2237. bugs (https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs).
  2238. All of which are fixed in stable releases.
  2239. .SS Can mergerfs be used with drives which already have data / are in use?
  2240. .PP
  2241. Yes.
  2242. MergerFS is a proxy and does \f[B]NOT\f[R] interfere with the normal
  2243. form or function of the drives / mounts / paths it manages.
  2244. .PP
  2245. MergerFS is \f[B]not\f[R] a traditional filesystem.
  2246. MergerFS is \f[B]not\f[R] RAID.
  2247. It does \f[B]not\f[R] manipulate the data that passes through it.
  2248. It does \f[B]not\f[R] shard data across drives.
  2249. It merely shards some \f[B]behavior\f[R] and aggregates others.
  2250. .SS Can mergerfs be removed without affecting the data?
  2251. .PP
  2252. See the previous question\[cq]s answer.
  2253. .SS What policies should I use?
  2254. .PP
  2255. Unless you\[cq]re doing something more niche the average user is
  2256. probably best off using \f[C]mfs\f[R] for \f[C]category.create\f[R].
  2257. It will spread files out across your branches based on available space.
  2258. Use \f[C]mspmfs\f[R] if you want to try to colocate the data a bit more.
  2259. You may want to use \f[C]lus\f[R] if you prefer a slightly different
  2260. distribution of data if you have a mix of smaller and larger drives.
  2261. Generally though \f[C]mfs\f[R], \f[C]lus\f[R], or even \f[C]rand\f[R]
  2262. are good for the general use case.
  2263. If you are starting with an imbalanced pool you can use the tool
  2264. \f[B]mergerfs.balance\f[R] to redistribute files across the pool.
  2265. .PP
  2266. If you really wish to try to colocate files based on directory you can
  2267. set \f[C]func.create\f[R] to \f[C]epmfs\f[R] or similar and
  2268. \f[C]func.mkdir\f[R] to \f[C]rand\f[R] or \f[C]eprand\f[R] depending on
  2269. if you just want to colocate generally or on specific branches.
  2270. Either way the \f[I]need\f[R] to colocate is rare.
  2271. For instance: if you wish to remove the drive regularly and want the
  2272. data to predictably be on that drive or if you don\[cq]t use backup at
  2273. all and don\[cq]t wish to replace that data piecemeal.
  2274. In which case using path preservation can help but will require some
  2275. manual attention.
  2276. Colocating after the fact can be accomplished using the
  2277. \f[B]mergerfs.consolidate\f[R] tool.
  2278. If you don\[cq]t need strict colocation which the \f[C]ep\f[R] policies
  2279. provide then you can use the \f[C]msp\f[R] based policies which will
  2280. walk back the path till finding a branch that works.
  2281. .PP
  2282. Ultimately there is no correct answer.
  2283. It is a preference or based on some particular need.
  2284. mergerfs is very easy to test and experiment with.
  2285. I suggest creating a test setup and experimenting to get a sense of what
  2286. you want.
  2287. .PP
  2288. The reason \f[C]mfs\f[R] is not the default \f[C]category.create\f[R]
  2289. policy is historical.
  2290. When/if a 3.X gets released it will be changed to minimize confusion
  2291. people often have with path preserving policies.
  2292. .SS What settings should I use?
  2293. .PP
  2294. Depends on what features you want.
  2295. Generally speaking there are no \[lq]wrong\[rq] settings.
  2296. All settings are performance or feature related.
  2297. The best bet is to read over the available options and choose what fits
  2298. your situation.
  2299. If something isn\[cq]t clear from the documentation please reach out and
  2300. the documentation will be improved.
  2301. .PP
  2302. That said, for the average person, the following should be fine:
  2303. .PP
  2304. \f[C]\-o use_ino,cache.files=off,dropcacheonclose=true,allow_other,category.create=mfs\f[R]
  2305. .SS Why are all my files ending up on 1 drive?!
  2306. .PP
  2307. Did you start with empty drives?
  2308. Did you explicitly configure a \f[C]category.create\f[R] policy?
  2309. Are you using an \f[C]existing path\f[R] / \f[C]path preserving\f[R]
  2310. policy?
  2311. .PP
  2312. The default create policy is \f[C]epmfs\f[R].
  2313. That is a path preserving algorithm.
  2314. With such a policy for \f[C]mkdir\f[R] and \f[C]create\f[R] with a set
  2315. of empty drives it will select only 1 drive when the first directory is
  2316. created.
  2317. Anything, files or directories, created in that first directory will be
  2318. placed on the same branch because it is preserving paths.
  2319. .PP
  2320. This catches a lot of new users off guard but changing the default would
  2321. break the setup for many existing users.
  2322. If you do not care about path preservation and wish your files to be
  2323. spread across all your drives change to \f[C]mfs\f[R] or similar policy
  2324. as described above.
  2325. If you do want path preservation you\[cq]ll need to perform the manual
  2326. act of creating paths on the drives you want the data to land on before
  2327. transferring your data.
  2328. Setting \f[C]func.mkdir=epall\f[R] can simplify managing path
  2329. preservation for \f[C]create\f[R].
  2330. Or use \f[C]func.mkdir=rand\f[R] if you\[cq]re interested in just
  2331. grouping together directory content by drive.
  2332. .SS Do hardlinks work?
  2333. .PP
  2334. Yes.
  2335. You need to use \f[C]use_ino\f[R] to support proper reporting of inodes
  2336. but they work regardless.
  2337. See also the option \f[C]inodecalc\f[R].
  2338. .PP
  2339. What mergerfs does not do is fake hard links across branches.
  2340. Read the section \[lq]rename & link\[rq] for how it works.
  2341. .PP
  2342. Remember that hardlinks will NOT work across devices.
  2343. That includes between the original filesystem and a mergerfs pool,
  2344. between two separate pools of the same underlying filesystems, or bind
  2345. mounts of paths within the mergerfs pool.
  2346. The latter is common when using Docker or Podman.
  2347. Multiple volumes (bind mounts) to the same underlying filesystem are
  2348. considered different devices.
  2349. There is no way to link between them.
  2350. You should mount in the highest directory in the mergerfs pool that
  2351. includes all the paths you need if you want links to work.
  2352. .SS Does mergerfs support CoW / copy\-on\-write / writes to read\-only filesystems?
  2353. .PP
  2354. Not in the sense of a filesystem like BTRFS or ZFS nor in the overlayfs
  2355. or aufs sense.
  2356. It does offer a
  2357. cow\-shell (http://manpages.ubuntu.com/manpages/bionic/man1/cow-shell.1.html)
  2358. like hard link breaking (copy to temp file then rename over original)
  2359. which can be useful when wanting to save space by hardlinking duplicate
  2360. files but wish to treat each name as if it were a unique and separate
  2361. file.
  2362. .PP
  2363. If you want to write to a read\-only filesystem you should look at
  2364. overlayfs.
  2365. You can always include the overlayfs mount into a mergerfs pool.
  2366. .SS Why can\[cq]t I see my files / directories?
  2367. .PP
  2368. It\[cq]s almost always a permissions issue.
  2369. Unlike mhddfs and unionfs\-fuse, which runs as root and attempts to
  2370. access content as such, mergerfs always changes its credentials to that
  2371. of the caller.
  2372. This means that if the user does not have access to a file or directory
  2373. than neither will mergerfs.
  2374. However, because mergerfs is creating a union of paths it may be able to
  2375. read some files and directories on one drive but not another resulting
  2376. in an incomplete set.
  2377. .PP
  2378. Whenever you run into a split permission issue (seeing some but not all
  2379. files) try using
  2380. mergerfs.fsck (https://github.com/trapexit/mergerfs-tools) tool to check
  2381. for and fix the mismatch.
  2382. If you aren\[cq]t seeing anything at all be sure that the basic
  2383. permissions are correct.
  2384. The user and group values are correct and that directories have their
  2385. executable bit set.
  2386. A common mistake by users new to Linux is to \f[C]chmod \-R 644\f[R]
  2387. when they should have \f[C]chmod \-R u=rwX,go=rX\f[R].
  2388. .PP
  2389. If using a network filesystem such as NFS, SMB, CIFS (Samba) be sure to
  2390. pay close attention to anything regarding permissioning and users.
  2391. Root squashing and user translation for instance has bitten a few
  2392. mergerfs users.
  2393. Some of these also affect the use of mergerfs from container platforms
  2394. such as Docker.
  2395. .SS Is my OS\[cq]s libfuse needed for mergerfs to work?
  2396. .PP
  2397. No.\ Normally \f[C]mount.fuse\f[R] is needed to get mergerfs (or any
  2398. FUSE filesystem to mount using the \f[C]mount\f[R] command but in
  2399. vendoring the libfuse library the \f[C]mount.fuse\f[R] app has been
  2400. renamed to \f[C]mount.mergerfs\f[R] meaning the filesystem type in
  2401. \f[C]fstab\f[R] can simply be \f[C]mergerfs\f[R].
  2402. That said there should be no harm in having it installed and continuing
  2403. to using \f[C]fuse.mergerfs\f[R] as the type in \f[C]/etc/fstab\f[R].
  2404. .PP
  2405. If \f[C]mergerfs\f[R] doesn\[cq]t work as a type it could be due to how
  2406. the \f[C]mount.mergerfs\f[R] tool was installed.
  2407. Must be in \f[C]/sbin/\f[R] with proper permissions.
  2408. .SS Why was libfuse embedded into mergerfs?
  2409. .IP "1." 3
  2410. A significant number of users use mergerfs on distros with old versions
  2411. of libfuse which have serious bugs.
  2412. Requiring updated versions of libfuse on those distros isn\[cq]t
  2413. practical (no package offered, user inexperience, etc.).
  2414. The only practical way to provide a stable runtime on those systems was
  2415. to \[lq]vendor\[rq] / embed the library into the project.
  2416. .IP "2." 3
  2417. mergerfs was written to use the high level API.
  2418. There are a number of limitations in the HLAPI that make certain
  2419. features difficult or impossible to implement.
  2420. While some of these features could be patched into newer versions of
  2421. libfuse without breaking the public API some of them would require hacky
  2422. code to provide backwards compatibility.
  2423. While it may still be worth working with upstream to address these
  2424. issues in future versions, since the library needs to be vendored for
  2425. stability and compatibility reasons it is preferable / easier to modify
  2426. the API.
  2427. Longer term the plan is to rewrite mergerfs to use the low level API.
  2428. .SS Why did support for system libfuse get removed?
  2429. .PP
  2430. See above first.
  2431. .PP
  2432. If/when mergerfs is rewritten to use the low\-level API then it\[cq]ll
  2433. be plausible to support system libfuse but till then its simply too much
  2434. work to manage the differences across the versions.
  2435. .SS Why use mergerfs over mhddfs?
  2436. .PP
  2437. mhddfs is no longer maintained and has some known stability and security
  2438. issues (see below).
  2439. MergerFS provides a superset of mhddfs\[cq] features and should offer
  2440. the same or maybe better performance.
  2441. .PP
  2442. Below is an example of mhddfs and mergerfs setup to work similarly.
  2443. .PP
  2444. \f[C]mhddfs \-o mlimit=4G,allow_other /mnt/drive1,/mnt/drive2 /mnt/pool\f[R]
  2445. .PP
  2446. \f[C]mergerfs \-o minfreespace=4G,allow_other,category.create=ff /mnt/drive1:/mnt/drive2 /mnt/pool\f[R]
  2447. .SS Why use mergerfs over aufs?
  2448. .PP
  2449. aufs is mostly abandoned and no longer available in many distros.
  2450. .PP
  2451. While aufs can offer better peak performance mergerfs provides more
  2452. configurability and is generally easier to use.
  2453. mergerfs however does not offer the overlay / copy\-on\-write (CoW)
  2454. features which aufs and overlayfs have.
  2455. .SS Why use mergerfs over unionfs?
  2456. .PP
  2457. UnionFS is more like aufs than mergerfs in that it offers overlay / CoW
  2458. features.
  2459. If you\[cq]re just looking to create a union of drives and want
  2460. flexibility in file/directory placement then mergerfs offers that
  2461. whereas unionfs is more for overlaying RW filesystems over RO ones.
  2462. .SS Why use mergerfs over overlayfs?
  2463. .PP
  2464. Same reasons as with unionfs.
  2465. .SS Why use mergerfs over LVM/ZFS/BTRFS/RAID0 drive concatenation / striping?
  2466. .PP
  2467. With simple JBOD / drive concatenation / stripping / RAID0 a single
  2468. drive failure will result in full pool failure.
  2469. mergerfs performs a similar function without the possibility of
  2470. catastrophic failure and the difficulties in recovery.
  2471. Drives may fail, however, all other data will continue to be accessible.
  2472. .PP
  2473. When combined with something like SnapRaid (http://www.snapraid.it)
  2474. and/or an offsite backup solution you can have the flexibility of JBOD
  2475. without the single point of failure.
  2476. .SS Why use mergerfs over ZFS?
  2477. .PP
  2478. MergerFS is not intended to be a replacement for ZFS.
  2479. MergerFS is intended to provide flexible pooling of arbitrary drives
  2480. (local or remote), of arbitrary sizes, and arbitrary filesystems.
  2481. For \f[C]write once, read many\f[R] usecases such as bulk media storage.
  2482. Where data integrity and backup is managed in other ways.
  2483. In that situation ZFS can introduce a number of costs and limitations as
  2484. described
  2485. here (http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html),
  2486. here (https://markmcb.com/2020/01/07/five-years-of-btrfs/), and
  2487. here (https://utcc.utoronto.ca/~cks/space/blog/solaris/ZFSWhyNoRealReshaping).
  2488. .SS Why use mergerfs over UnRAID?
  2489. .PP
  2490. UnRAID is a full OS and its storage layer, as I understand, is
  2491. proprietary and closed source.
  2492. Users who have experience with both have said they prefer the
  2493. flexibility offered by mergerfs and for some the fact it is free and
  2494. open source is important.
  2495. .PP
  2496. There are a number of UnRAID users who use mergerfs as well though
  2497. I\[cq]m not entirely familiar with the use case.
  2498. .SS What should mergerfs NOT be used for?
  2499. .IP \[bu] 2
  2500. databases: Even if the database stored data in separate files (mergerfs
  2501. wouldn\[cq]t offer much otherwise) the higher latency of the indirection
  2502. will kill performance.
  2503. If it is a lightly used SQLITE database then it may be fine but
  2504. you\[cq]ll need to test.
  2505. .IP \[bu] 2
  2506. VM images: For the same reasons as databases.
  2507. VM images are accessed very aggressively and mergerfs will introduce too
  2508. much latency (if it works at all).
  2509. .IP \[bu] 2
  2510. As replacement for RAID: mergerfs is just for pooling branches.
  2511. If you need that kind of device performance aggregation or high
  2512. availability you should stick with RAID.
  2513. .SS Can drives be written to directly? Outside of mergerfs while pooled?
  2514. .PP
  2515. Yes, however it\[cq]s not recommended to use the same file from within
  2516. the pool and from without at the same time (particularly writing).
  2517. Especially if using caching of any kind (cache.files, cache.entry,
  2518. cache.attr, cache.negative_entry, cache.symlinks, cache.readdir, etc.)
  2519. as there could be a conflict between cached data and not.
  2520. .SS Why do I get an \[lq]out of space\[rq] / \[lq]no space left on device\[rq] / ENOSPC error even though there appears to be lots of space available?
  2521. .PP
  2522. First make sure you\[cq]ve read the sections above about policies, path
  2523. preservation, branch filtering, and the options \f[B]minfreespace\f[R],
  2524. \f[B]moveonenospc\f[R], \f[B]statfs\f[R], and \f[B]statfs_ignore\f[R].
  2525. .PP
  2526. mergerfs is simply presenting a union of the content within multiple
  2527. branches.
  2528. The reported free space is an aggregate of space available within the
  2529. pool (behavior modified by \f[B]statfs\f[R] and
  2530. \f[B]statfs_ignore\f[R]).
  2531. It does not represent a contiguous space.
  2532. In the same way that read\-only filesystems, those with quotas, or
  2533. reserved space report the full theoretical space available.
  2534. .PP
  2535. Due to path preservation, branch tagging, read\-only status, and
  2536. \f[B]minfreespace\f[R] settings it is perfectly valid that
  2537. \f[C]ENOSPC\f[R] / \[lq]out of space\[rq] / \[lq]no space left on
  2538. device\[rq] be returned.
  2539. It is doing what was asked of it: filtering possible branches due to
  2540. those settings.
  2541. Only one error can be returned and if one of the reasons for filtering a
  2542. branch was \f[B]minfreespace\f[R] then it will be returned as such.
  2543. \f[B]moveonenospc\f[R] is only relevant to writing a file which is too
  2544. large for the drive its currently on.
  2545. .PP
  2546. It is also possible that the filesystem selected has run out of inodes.
  2547. Use \f[C]df \-i\f[R] to list the total and available inodes per
  2548. filesystem.
  2549. .PP
  2550. If you don\[cq]t care about path preservation then simply change the
  2551. \f[C]create\f[R] policy to one which isn\[cq]t.
  2552. \f[C]mfs\f[R] is probably what most are looking for.
  2553. The reason it\[cq]s not default is because it was originally set to
  2554. \f[C]epmfs\f[R] and changing it now would change people\[cq]s setup.
  2555. Such a setting change will likely occur in mergerfs 3.
  2556. .SS Why does the total available space in mergerfs not equal outside?
  2557. .PP
  2558. Are you using ext2/3/4?
  2559. With reserve for root?
  2560. mergerfs uses available space for statfs calculations.
  2561. If you\[cq]ve reserved space for root then it won\[cq]t show up.
  2562. .PP
  2563. You can remove the reserve by running: \f[C]tune2fs \-m 0 <device>\f[R]
  2564. .SS Can mergerfs mounts be exported over NFS?
  2565. .PP
  2566. Yes, however if you do anything which may changes files out of band
  2567. (including for example using the \f[C]newest\f[R] policy) it will result
  2568. in \[lq]stale file handle\[rq] errors unless properly setup.
  2569. .PP
  2570. Be sure to use the following options:
  2571. .IP \[bu] 2
  2572. noforget
  2573. .IP \[bu] 2
  2574. use_ino
  2575. .IP \[bu] 2
  2576. inodecalc=path\-hash
  2577. .SS Can mergerfs mounts be exported over Samba / SMB?
  2578. .PP
  2579. Yes.
  2580. While some users have reported problems it appears to always be related
  2581. to how Samba is setup in relation to permissions.
  2582. .SS Can mergerfs mounts be used over SSHFS?
  2583. .PP
  2584. Yes.
  2585. .SS I notice massive slowdowns of writes when enabling cache.files.
  2586. .PP
  2587. When file caching is enabled in any form (\f[C]cache.files!=off\f[R] or
  2588. \f[C]direct_io=false\f[R]) it will issue \f[C]getxattr\f[R] requests for
  2589. \f[C]security.capability\f[R] prior to \f[I]every single write\f[R].
  2590. This will usually result in a performance degradation, especially when
  2591. using a network filesystem (such as NFS or CIFS/SMB/Samba.)
  2592. Unfortunately at this moment the kernel is not caching the response.
  2593. .PP
  2594. To work around this situation mergerfs offers a few solutions.
  2595. .IP "1." 3
  2596. Set \f[C]security_capability=false\f[R].
  2597. It will short circuit any call and return \f[C]ENOATTR\f[R].
  2598. This still means though that mergerfs will receive the request before
  2599. every write but at least it doesn\[cq]t get passed through to the
  2600. underlying filesystem.
  2601. .IP "2." 3
  2602. Set \f[C]xattr=noattr\f[R].
  2603. Same as above but applies to \f[I]all\f[R] calls to getxattr.
  2604. Not just \f[C]security.capability\f[R].
  2605. This will not be cached by the kernel either but mergerfs\[cq] runtime
  2606. config system will still function.
  2607. .IP "3." 3
  2608. Set \f[C]xattr=nosys\f[R].
  2609. Results in mergerfs returning \f[C]ENOSYS\f[R] which \f[I]will\f[R] be
  2610. cached by the kernel.
  2611. No future xattr calls will be forwarded to mergerfs.
  2612. The downside is that also means the xattr based config and query
  2613. functionality won\[cq]t work either.
  2614. .IP "4." 3
  2615. Disable file caching.
  2616. If you aren\[cq]t using applications which use \f[C]mmap\f[R] it\[cq]s
  2617. probably simpler to just disable it all together.
  2618. The kernel won\[cq]t send the requests when caching is disabled.
  2619. .SS What are these .fuse_hidden files?
  2620. .PP
  2621. Please upgrade.
  2622. mergerfs >= 2.26.0 will not have these temporary files.
  2623. See the notes on \f[C]unlink\f[R].
  2624. .SS It\[cq]s mentioned that there are some security issues with mhddfs. What are they? How does mergerfs address them?
  2625. .PP
  2626. mhddfs (https://github.com/trapexit/mhddfs) manages running as
  2627. \f[B]root\f[R] by calling
  2628. getuid() (https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
  2629. and if it returns \f[B]0\f[R] then it will
  2630. chown (http://linux.die.net/man/1/chown) the file.
  2631. Not only is that a race condition but it doesn\[cq]t handle other
  2632. situations.
  2633. Rather than attempting to simulate POSIX ACL behavior the proper way to
  2634. manage this is to use seteuid (http://linux.die.net/man/2/seteuid) and
  2635. setegid (http://linux.die.net/man/2/setegid), in effect becoming the
  2636. user making the original call, and perform the action as them.
  2637. This is what mergerfs does and why mergerfs should always run as root.
  2638. .PP
  2639. In Linux setreuid syscalls apply only to the thread.
  2640. GLIBC hides this away by using realtime signals to inform all threads to
  2641. change credentials.
  2642. Taking after \f[B]Samba\f[R], mergerfs uses
  2643. \f[B]syscall(SYS_setreuid,\&...)\f[R] to set the callers credentials for
  2644. that thread only.
  2645. Jumping back to \f[B]root\f[R] as necessary should escalated privileges
  2646. be needed (for instance: to clone paths between drives).
  2647. .PP
  2648. For non\-Linux systems mergerfs uses a read\-write lock and changes
  2649. credentials only when necessary.
  2650. If multiple threads are to be user X then only the first one will need
  2651. to change the processes credentials.
  2652. So long as the other threads need to be user X they will take a readlock
  2653. allowing multiple threads to share the credentials.
  2654. Once a request comes in to run as user Y that thread will attempt a
  2655. write lock and change to Y\[cq]s credentials when it can.
  2656. If the ability to give writers priority is supported then that flag will
  2657. be used so threads trying to change credentials don\[cq]t starve.
  2658. This isn\[cq]t the best solution but should work reasonably well
  2659. assuming there are few users.
  2660. .SH SUPPORT
  2661. .PP
  2662. Filesystems are complex and difficult to debug.
  2663. mergerfs, while being just a proxy of sorts, is also very difficult to
  2664. debug given the large number of possible settings it can have itself and
  2665. the massive number of environments it can run in.
  2666. When reporting on a suspected issue \f[B]please, please\f[R] include as
  2667. much of the below information as possible otherwise it will be difficult
  2668. or impossible to diagnose.
  2669. Also please make sure to read all of the above documentation as it
  2670. includes nearly every known system or user issue previously encountered.
  2671. .PP
  2672. \f[B]Please make sure you are using the latest
  2673. release (https://github.com/trapexit/mergerfs/releases) or have tried it
  2674. in comparison. Old versions, which are often included in distros like
  2675. Debian and Ubuntu, are not ever going to be updated and your bug may
  2676. have been addressed already.\f[R]
  2677. .SS Information to include in bug reports
  2678. .IP \[bu] 2
  2679. Version of mergerfs: \f[C]mergerfs \-V\f[R]
  2680. .IP \[bu] 2
  2681. mergerfs settings: from \f[C]/etc/fstab\f[R] or command line execution
  2682. .IP \[bu] 2
  2683. Version of Linux: \f[C]uname \-a\f[R]
  2684. .IP \[bu] 2
  2685. Versions of any additional software being used
  2686. .IP \[bu] 2
  2687. List of drives, their filesystems, and sizes (before and after issue):
  2688. \f[C]df \-h\f[R]
  2689. .IP \[bu] 2
  2690. \f[B]All\f[R] information about the relevant branches and paths:
  2691. permissions, etc.
  2692. .IP \[bu] 2
  2693. A \f[C]strace\f[R] of the app having problems:
  2694. .RS 2
  2695. .IP \[bu] 2
  2696. \f[C]strace \-f \-o /tmp/app.strace.txt <cmd>\f[R]
  2697. .RE
  2698. .IP \[bu] 2
  2699. A \f[C]strace\f[R] of mergerfs while the program is trying to do
  2700. whatever it\[cq]s failing to do:
  2701. .RS 2
  2702. .IP \[bu] 2
  2703. \f[C]strace \-f \-p <mergerfsPID> \-o /tmp/mergerfs.strace.txt\f[R]
  2704. .RE
  2705. .IP \[bu] 2
  2706. \f[B]Precise\f[R] directions on replicating the issue.
  2707. Do not leave \f[B]anything\f[R] out.
  2708. .IP \[bu] 2
  2709. Try to recreate the problem in the simplest way using standard programs.
  2710. .SS Contact / Issue submission
  2711. .IP \[bu] 2
  2712. github.com: https://github.com/trapexit/mergerfs/issues
  2713. .IP \[bu] 2
  2714. email: trapexit\[at]spawn.link
  2715. .IP \[bu] 2
  2716. twitter: https://twitter.com/_trapexit
  2717. .IP \[bu] 2
  2718. reddit: https://www.reddit.com/user/trapexit
  2719. .IP \[bu] 2
  2720. discord: https://discord.gg/MpAr69V
  2721. .SS Support development
  2722. .PP
  2723. This software is free to use and released under a very liberal license
  2724. (ISC).
  2725. That said if you like this software and would like to support its
  2726. development donations are welcome.
  2727. .PP
  2728. At the moment my preference would be GitHub Sponsors only because I am
  2729. part of the matching program.
  2730. That said please use whatever platform you prefer.
  2731. .IP \[bu] 2
  2732. PayPal: https://paypal.me/trapexit
  2733. .IP \[bu] 2
  2734. GitHub Sponsors: https://github.com/sponsors/trapexit
  2735. .IP \[bu] 2
  2736. Patreon: https://www.patreon.com/trapexit
  2737. .IP \[bu] 2
  2738. SubscribeStar: https://www.subscribestar.com/trapexit
  2739. .IP \[bu] 2
  2740. Ko\-Fi: https://ko\-fi.com/trapexit
  2741. .IP \[bu] 2
  2742. Open Collective: https://opencollective.com/trapexit
  2743. .IP \[bu] 2
  2744. Bitcoin (BTC): 1DfoUd2m5WCxJAMvcFuvDpT4DR2gWX2PWb
  2745. .IP \[bu] 2
  2746. Bitcoin Cash (BCH): qrf257j0l09yxty4kur8dk2uma8p5vntdcpks72l8z
  2747. .IP \[bu] 2
  2748. Ethereum (ETH): 0xb486C0270fF75872Fc51d85879b9c15C380E66CA
  2749. .IP \[bu] 2
  2750. Litecoin (LTC): LW1rvHRPWtm2NUEMhJpP4DjHZY1FaJ1WYs
  2751. .IP \[bu] 2
  2752. Monero (XMR):
  2753. 8AuU7PeK1fVhGP9yug8fdgKBssvUQoBVFKGhtT5DzWQt7fcTKC1SUx3Eb7xCAiVt3McWJp2Z9gX2wU7SPhh1GfWYBTCs6SS
  2754. .IP \[bu] 2
  2755. Basic Attention Token (BAT): 0xE651d4900B4C305284Da43E2e182e9abE149A87A
  2756. .IP \[bu] 2
  2757. LBRY Credits (LBC): bFusyoZPkSuzM2Pr8mcthgvkymaosJZt5r
  2758. .IP \[bu] 2
  2759. Zcash (ZEC): t1ZwTgmbQF23DJrzqbAmw8kXWvU2xUkkhTt
  2760. .IP \[bu] 2
  2761. Zcoin (XZC): a8L5Vz35KdCQe7Y7urK2pcCGau7JsqZ5Gw
  2762. .IP \[bu] 2
  2763. Other crypto currencies: contact me for address
  2764. .SH LINKS
  2765. .IP \[bu] 2
  2766. https://spawn.link
  2767. .IP \[bu] 2
  2768. https://github.com/trapexit/mergerfs
  2769. .IP \[bu] 2
  2770. https://github.com/trapexit/mergerfs/wiki
  2771. .IP \[bu] 2
  2772. https://github.com/trapexit/mergerfs\-tools
  2773. .IP \[bu] 2
  2774. https://github.com/trapexit/scorch
  2775. .IP \[bu] 2
  2776. https://github.com/trapexit/bbf
  2777. .IP \[bu] 2
  2778. https://github.com/trapexit/backup\-and\-recovery\-howtos
  2779. .SH AUTHORS
  2780. Antonio SJ Musumeci <trapexit@spawn.link>.