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.

1068 lines
38 KiB

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
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
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
8 years ago
9 years ago
9 years ago
9 years ago
  1. .\"t
  2. .TH "mergerfs" "1" "2016\-12\-14" "mergerfs user manual" ""
  3. .SH NAME
  4. .PP
  5. mergerfs \- another (FUSE based) union filesystem
  6. .SH SYNOPSIS
  7. .PP
  8. mergerfs \-o<options> <srcmounts> <mountpoint>
  9. .SH DESCRIPTION
  10. .PP
  11. \f[B]mergerfs\f[] is a union filesystem geared towards simplifying
  12. storage and management of files across numerous commodity storage
  13. devices.
  14. It is similar to \f[B]mhddfs\f[], \f[B]unionfs\f[], and \f[B]aufs\f[].
  15. .SH FEATURES
  16. .IP \[bu] 2
  17. Runs in userspace (FUSE)
  18. .IP \[bu] 2
  19. Configurable behaviors
  20. .IP \[bu] 2
  21. Support for extended attributes (xattrs)
  22. .IP \[bu] 2
  23. Support for file attributes (chattr)
  24. .IP \[bu] 2
  25. Runtime configurable (via xattrs)
  26. .IP \[bu] 2
  27. Safe to run as root
  28. .IP \[bu] 2
  29. Opportunistic credential caching
  30. .IP \[bu] 2
  31. Works with heterogeneous filesystem types
  32. .IP \[bu] 2
  33. Handling of writes to full drives (transparently move file to drive with
  34. capacity)
  35. .IP \[bu] 2
  36. Handles pool of readonly and read/write drives
  37. .SH OPTIONS
  38. .SS options
  39. .IP \[bu] 2
  40. \f[B]defaults\f[]: a shortcut for FUSE\[aq]s \f[B]atomic_o_trunc\f[],
  41. \f[B]auto_cache\f[], \f[B]big_writes\f[], \f[B]default_permissions\f[],
  42. \f[B]splice_move\f[], \f[B]splice_read\f[], and \f[B]splice_write\f[].
  43. These options seem to provide the best performance.
  44. .IP \[bu] 2
  45. \f[B]direct_io\f[]: causes FUSE to bypass caching which can increase
  46. write speeds at the detriment of reads.
  47. Note that not enabling \f[C]direct_io\f[] will cause double caching of
  48. files and therefore less memory for caching generally.
  49. However, \f[C]mmap\f[] does not work when \f[C]direct_io\f[] is enabled.
  50. .IP \[bu] 2
  51. \f[B]minfreespace\f[]: the minimum space value used for creation
  52. policies.
  53. Understands \[aq]K\[aq], \[aq]M\[aq], and \[aq]G\[aq] to represent
  54. kilobyte, megabyte, and gigabyte respectively.
  55. (default: 4G)
  56. .IP \[bu] 2
  57. \f[B]moveonenospc\f[]: when enabled (set to \f[B]true\f[]) if a
  58. \f[B]write\f[] fails with \f[B]ENOSPC\f[] or \f[B]EDQUOT\f[] a scan of
  59. all drives will be done looking for the drive with most free space which
  60. is at least the size of the file plus the amount which failed to write.
  61. An attempt to move the file to that drive will occur (keeping all
  62. metadata possible) and if successful the original is unlinked and the
  63. write retried.
  64. (default: false)
  65. .IP \[bu] 2
  66. \f[B]func.<func>=<policy>\f[]: sets the specific FUSE function\[aq]s
  67. policy.
  68. See below for the list of value types.
  69. Example: \f[B]func.getattr=newest\f[]
  70. .IP \[bu] 2
  71. \f[B]category.<category>=<policy>\f[]: Sets policy of all FUSE functions
  72. in the provided category.
  73. Example: \f[B]category.create=mfs\f[]
  74. .IP \[bu] 2
  75. \f[B]fsname\f[]: sets the name of the filesystem as seen in
  76. \f[B]mount\f[], \f[B]df\f[], etc.
  77. Defaults to a list of the source paths concatenated together with the
  78. longest common prefix removed.
  79. .IP \[bu] 2
  80. \f[B]use_ino\f[]: causes mergerfs to supply file/directory inodes rather
  81. than libfuse.
  82. While not a default it is generally recommended it be enabled so that
  83. hard linked files share the same inode value.
  84. .PP
  85. \f[B]NOTE:\f[] Options are evaluated in the order listed so if the
  86. options are \f[B]func.rmdir=rand,category.action=ff\f[] the
  87. \f[B]action\f[] category setting will override the \f[B]rmdir\f[]
  88. setting.
  89. .SS srcmounts
  90. .PP
  91. The srcmounts (source mounts) argument is a colon (\[aq]:\[aq])
  92. delimited list of paths to be included in the pool.
  93. It does not matter if the paths are on the same or different drives nor
  94. does it matter the filesystem.
  95. Used and available space will not be duplicated for paths on the same
  96. device and any features which aren\[aq]t supported by the underlying
  97. filesystem (such as file attributes or extended attributes) will return
  98. the appropriate errors.
  99. .PP
  100. To make it easier to include multiple source mounts mergerfs supports
  101. globbing (http://linux.die.net/man/7/glob).
  102. \f[B]The globbing tokens MUST be escaped when using via the shell else
  103. the shell itself will expand it.\f[]
  104. .IP
  105. .nf
  106. \f[C]
  107. $\ mergerfs\ \-o\ defaults,allow_other,use_ino\ /mnt/disk\\*:/mnt/cdrom\ /media/drives
  108. \f[]
  109. .fi
  110. .PP
  111. The above line will use all mount points in /mnt prefixed with
  112. \f[B]disk\f[] and the \f[B]cdrom\f[].
  113. .PP
  114. To have the pool mounted at boot or otherwise accessable from related
  115. tools use \f[B]/etc/fstab\f[].
  116. .IP
  117. .nf
  118. \f[C]
  119. #\ <file\ system>\ \ \ \ \ \ \ \ <mount\ point>\ \ <type>\ \ \ \ \ \ \ \ \ <options>\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ <dump>\ \ <pass>
  120. /mnt/disk*:/mnt/cdrom\ \ /media/drives\ \ fuse.mergerfs\ \ defaults,allow_other,use_ino\ \ 0\ \ \ \ \ \ \ 0
  121. \f[]
  122. .fi
  123. .PP
  124. \f[B]NOTE:\f[] the globbing is done at mount or xattr update time (see
  125. below).
  126. If a new directory is added matching the glob after the fact it will not
  127. be automatically included.
  128. .PP
  129. \f[B]NOTE:\f[] for mounting via \f[B]fstab\f[] to work you must have
  130. \f[B]mount.fuse\f[] installed.
  131. For Ubuntu/Debian it is included in the \f[B]fuse\f[] package.
  132. .SH FUNCTIONS / POLICIES / CATEGORIES
  133. .PP
  134. The POSIX filesystem API has a number of functions.
  135. \f[B]creat\f[], \f[B]stat\f[], \f[B]chown\f[], etc.
  136. In mergerfs these functions are grouped into 3 categories:
  137. \f[B]action\f[], \f[B]create\f[], and \f[B]search\f[].
  138. Functions and categories can be assigned a policy which dictates how
  139. \f[B]mergerfs\f[] behaves.
  140. Any policy can be assigned to a function or category though some are not
  141. very practical.
  142. For instance: \f[B]rand\f[] (random) may be useful for file creation
  143. (create) but could lead to very odd behavior if used for \f[C]chmod\f[]
  144. (though only if there were more than one copy of the file).
  145. .PP
  146. Policies, when called to create, will ignore drives which are readonly
  147. or have less than \f[B]minfreespace\f[].
  148. This allows for read/write and readonly drives to be mixed together and
  149. keep drives which may remount as readonly on error from further
  150. affecting the pool.
  151. .SS Function / Category classifications
  152. .PP
  153. .TS
  154. tab(@);
  155. l l.
  156. T{
  157. Category
  158. T}@T{
  159. FUSE Functions
  160. T}
  161. _
  162. T{
  163. action
  164. T}@T{
  165. chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate,
  166. unlink, utimens
  167. T}
  168. T{
  169. create
  170. T}@T{
  171. create, mkdir, mknod, symlink
  172. T}
  173. T{
  174. search
  175. T}@T{
  176. access, getattr, getxattr, ioctl, listxattr, open, readlink
  177. T}
  178. T{
  179. N/A
  180. T}@T{
  181. fallocate, fgetattr, fsync, ftruncate, ioctl, read, readdir, release,
  182. statfs, write
  183. T}
  184. .TE
  185. .PP
  186. Due to FUSE limitations \f[B]ioctl\f[] behaves differently if its acting
  187. on a directory.
  188. It\[aq]ll use the \f[B]getattr\f[] policy to find and open the directory
  189. before issuing the \f[B]ioctl\f[].
  190. In other cases where something may be searched (to confirm a directory
  191. exists across all source mounts) \f[B]getattr\f[] will also be used.
  192. .SS Policy descriptions
  193. .PP
  194. .TS
  195. tab(@);
  196. l l.
  197. T{
  198. Policy
  199. T}@T{
  200. Description
  201. T}
  202. _
  203. T{
  204. all
  205. T}@T{
  206. Search category: acts like \f[B]ff\f[].
  207. Action category: apply to all found.
  208. Create category: for \f[B]mkdir\f[], \f[B]mknod\f[], and
  209. \f[B]symlink\f[] it will apply to all found.
  210. \f[B]create\f[] works like \f[B]ff\f[].
  211. It will exclude readonly drives and those with free space less than
  212. \f[B]minfreespace\f[].
  213. T}
  214. T{
  215. epall (existing path, all)
  216. T}@T{
  217. Search category: acts like \f[B]epff\f[].
  218. Action category: apply to all found.
  219. Create category: for \f[B]mkdir\f[], \f[B]mknod\f[], and
  220. \f[B]symlink\f[] it will apply to all existing paths found.
  221. \f[B]create\f[] works like \f[B]epff\f[].
  222. It will exclude readonly drives and those with free space less than
  223. \f[B]minfreespace\f[].
  224. T}
  225. T{
  226. epff
  227. T}@T{
  228. Given the order of the drives, as defined at mount time or when
  229. configured via the xattr interface, act on the first one found where the
  230. path already exists.
  231. For \f[B]create\f[] category it will exclude readonly drives and those
  232. with free space less than \f[B]minfreespace\f[] (unless there is no
  233. other option).
  234. Falls back to \f[B]ff\f[].
  235. T}
  236. T{
  237. eplfs (existing path, least free space)
  238. T}@T{
  239. If the path exists on multiple drives use the one with the least free
  240. space.
  241. For \f[B]create\f[] category it will exclude readonly drives and those
  242. with free space less than \f[B]minfreespace\f[].
  243. Falls back to \f[B]lfs\f[].
  244. T}
  245. T{
  246. eplus (existing path, least used space)
  247. T}@T{
  248. If the path exists on multiple drives use the one with the least used
  249. space.
  250. For \f[B]create\f[] category it will exclude readonly drives and those
  251. with free space less than \f[B]minfreespace\f[].
  252. Falls back to \f[B]lus\f[].
  253. T}
  254. T{
  255. epmfs (existing path, most free space)
  256. T}@T{
  257. If the path exists on multiple drives use the one with the most free
  258. space.
  259. For \f[B]create\f[] category it will exclude readonly drives and those
  260. with free space less than \f[B]minfreespace\f[].
  261. Falls back to \f[B]mfs\f[].
  262. T}
  263. T{
  264. eprand (existing path, random)
  265. T}@T{
  266. Calls \f[B]epall\f[] and then randomizes.
  267. T}
  268. T{
  269. erofs
  270. T}@T{
  271. Exclusively return \f[B]\-1\f[] with \f[B]errno\f[] set to
  272. \f[B]EROFS\f[].
  273. By setting \f[B]create\f[] functions to this you can in effect turn the
  274. filesystem readonly.
  275. T}
  276. T{
  277. ff (first found)
  278. T}@T{
  279. Given the order of the drives, as defined at mount time or when
  280. configured via xattr interface, act on the first one found.
  281. For \f[B]create\f[] category it will exclude readonly drives and those
  282. with free space less than \f[B]minfreespace\f[] (unless there is no
  283. other option).
  284. T}
  285. T{
  286. lfs (least free space)
  287. T}@T{
  288. Pick the drive with the least available free space.
  289. For \f[B]create\f[] category it will exclude readonly drives and those
  290. with free space less than \f[B]minfreespace\f[].
  291. Falls back to \f[B]mfs\f[].
  292. T}
  293. T{
  294. lus (least used space)
  295. T}@T{
  296. Pick the drive with the least used space.
  297. For \f[B]create\f[] category it will exclude readonly drives and those
  298. with free space less than \f[B]minfreespace\f[].
  299. Falls back to \f[B]mfs\f[].
  300. T}
  301. T{
  302. mfs (most free space)
  303. T}@T{
  304. Pick the drive with the most available free space.
  305. For \f[B]create\f[] category it will exclude readonly drives.
  306. Falls back to \f[B]ff\f[].
  307. T}
  308. T{
  309. newest (newest file)
  310. T}@T{
  311. Pick the file / directory with the largest mtime.
  312. For \f[B]create\f[] category it will exclude readonly drives and those
  313. with free space less than \f[B]minfreespace\f[] (unless there is no
  314. other option).
  315. T}
  316. T{
  317. rand (random)
  318. T}@T{
  319. Calls \f[B]all\f[] and then randomizes.
  320. T}
  321. .TE
  322. .PP
  323. \f[B]epff\f[], \f[B]eplfs\f[], \f[B]eplus\f[], and \f[B]epmf\f[] are
  324. path preserving policies.
  325. As the descriptions above explain they will only consider drives where
  326. the path being accessed exists.
  327. Non\-path preserving policies will clone paths as necessary.
  328. .SS Defaults
  329. .PP
  330. .TS
  331. tab(@);
  332. l l.
  333. T{
  334. Category
  335. T}@T{
  336. Policy
  337. T}
  338. _
  339. T{
  340. action
  341. T}@T{
  342. all
  343. T}
  344. T{
  345. create
  346. T}@T{
  347. epmfs
  348. T}
  349. T{
  350. search
  351. T}@T{
  352. ff
  353. T}
  354. .TE
  355. .SS rename & link
  356. .PP
  357. rename (http://man7.org/linux/man-pages/man2/rename.2.html) is a tricky
  358. function in a merged system.
  359. Normally if a rename can\[aq]t be done atomically due to the source and
  360. destination paths existing on different mount points it will return
  361. \f[B]\-1\f[] with \f[B]errno = EXDEV\f[].
  362. The atomic rename is most critical for replacing files in place
  363. atomically (such as securing writing to a temp file and then replacing a
  364. target).
  365. The problem is that by merging multiple paths you can have N instances
  366. of the source and destinations on different drives.
  367. This can lead to several undesirable situtations with or without errors
  368. and it\[aq]s not entirely obvious what to do when an error occurs.
  369. .PP
  370. Originally mergerfs would return EXDEV whenever a rename was requested
  371. which was cross directory in any way.
  372. This made the code simple and was technically complient with POSIX
  373. requirements.
  374. However, many applications fail to handle EXDEV at all and treat it as a
  375. normal error or they only partially support EXDEV (don\[aq]t respond the
  376. same as \f[C]mv\f[] would).
  377. Such apps include: gvfsd\-fuse v1.20.3 and prior, Finder / CIFS/SMB
  378. client in Apple OSX 10.9+, NZBGet, Samba\[aq]s recycling bin feature.
  379. .IP \[bu] 2
  380. If using a \f[B]create\f[] policy which tries to preserve directory
  381. paths (epff,eplfs,eplus,epmfs)
  382. .IP \[bu] 2
  383. Using the \f[B]rename\f[] policy get the list of files to rename
  384. .IP \[bu] 2
  385. For each file attempt rename:
  386. .RS 2
  387. .IP \[bu] 2
  388. If failure with ENOENT run \f[B]create\f[] policy
  389. .IP \[bu] 2
  390. If create policy returns the same drive as currently evaluating then
  391. clone the path
  392. .IP \[bu] 2
  393. Re\-attempt rename
  394. .RE
  395. .IP \[bu] 2
  396. If \f[B]any\f[] of the renames succeed the higher level rename is
  397. considered a success
  398. .IP \[bu] 2
  399. If \f[B]no\f[] renames succeed the first error encountered will be
  400. returned
  401. .IP \[bu] 2
  402. On success:
  403. .RS 2
  404. .IP \[bu] 2
  405. Remove the target from all drives with no source file
  406. .IP \[bu] 2
  407. Remove the source from all drives which failed to rename
  408. .RE
  409. .IP \[bu] 2
  410. If using a \f[B]create\f[] policy which does \f[B]not\f[] try to
  411. preserve directory paths
  412. .IP \[bu] 2
  413. Using the \f[B]rename\f[] policy get the list of files to rename
  414. .IP \[bu] 2
  415. Using the \f[B]getattr\f[] policy get the target path
  416. .IP \[bu] 2
  417. For each file attempt rename:
  418. .RS 2
  419. .IP \[bu] 2
  420. If the source drive != target drive:
  421. .IP \[bu] 2
  422. Clone target path from target drive to source drive
  423. .IP \[bu] 2
  424. Rename
  425. .RE
  426. .IP \[bu] 2
  427. If \f[B]any\f[] of the renames succeed the higher level rename is
  428. considered a success
  429. .IP \[bu] 2
  430. If \f[B]no\f[] renames succeed the first error encountered will be
  431. returned
  432. .IP \[bu] 2
  433. On success:
  434. .RS 2
  435. .IP \[bu] 2
  436. Remove the target from all drives with no source file
  437. .IP \[bu] 2
  438. Remove the source from all drives which failed to rename
  439. .RE
  440. .PP
  441. The the removals are subject to normal entitlement checks.
  442. .PP
  443. The above behavior will help minimize the likelihood of EXDEV being
  444. returned but it will still be possible.
  445. To remove the possibility all together mergerfs would need to perform
  446. the as \f[B]mv\f[] does when it receives EXDEV normally.
  447. .PP
  448. \f[B]link\f[] uses the same basic strategy.
  449. .SS readdir
  450. .PP
  451. readdir (http://linux.die.net/man/3/readdir) is different from all other
  452. filesystem functions.
  453. While it could have it\[aq]s own set of policies to tweak its behavior
  454. at this time it provides a simple union of files and directories found.
  455. Remember that any action or information queried about these files and
  456. directories come from the respective function.
  457. For instance: an \f[B]ls\f[] is a \f[B]readdir\f[] and for each
  458. file/directory returned \f[B]getattr\f[] is called.
  459. Meaning the policy of \f[B]getattr\f[] is responsible for choosing the
  460. file/directory which is the source of the metadata you see in an
  461. \f[B]ls\f[].
  462. .SS statvfs
  463. .PP
  464. statvfs (http://linux.die.net/man/2/statvfs) normalizes the source
  465. drives based on the fragment size and sums the number of adjusted blocks
  466. and inodes.
  467. This means you will see the combined space of all sources.
  468. Total, used, and free.
  469. The sources however are dedupped based on the drive so multiple sources
  470. on the same drive will not result in double counting it\[aq]s space.
  471. .SH BUILDING
  472. .PP
  473. \f[B]NOTE:\f[] Prebuilt packages can be found at:
  474. https://github.com/trapexit/mergerfs/releases
  475. .PP
  476. First get the code from github (http://github.com/trapexit/mergerfs).
  477. .IP
  478. .nf
  479. \f[C]
  480. $\ git\ clone\ https://github.com/trapexit/mergerfs.git
  481. $\ #\ or
  482. $\ wget\ https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs\-<ver>.tar.gz
  483. \f[]
  484. .fi
  485. .SS Debian / Ubuntu
  486. .IP
  487. .nf
  488. \f[C]
  489. $\ sudo\ apt\-get\ install\ g++\ pkg\-config\ git\ git\-buildpackage\ pandoc\ debhelper\ libfuse\-dev\ libattr1\-dev\ python
  490. $\ cd\ mergerfs
  491. $\ make\ deb
  492. $\ sudo\ dpkg\ \-i\ ../mergerfs_version_arch.deb
  493. \f[]
  494. .fi
  495. .SS Fedora
  496. .IP
  497. .nf
  498. \f[C]
  499. $\ su\ \-
  500. #\ dnf\ install\ rpm\-build\ fuse\-devel\ libattr\-devel\ pandoc\ gcc\-c++\ git\ make\ which\ python
  501. #\ cd\ mergerfs
  502. #\ make\ rpm
  503. #\ rpm\ \-i\ rpmbuild/RPMS/<arch>/mergerfs\-<verion>.<arch>.rpm
  504. \f[]
  505. .fi
  506. .SS Generically
  507. .PP
  508. Have git, python, pkg\-config, pandoc, libfuse, libattr1 installed.
  509. .IP
  510. .nf
  511. \f[C]
  512. $\ cd\ mergerfs
  513. $\ make
  514. $\ make\ man
  515. $\ sudo\ make\ install
  516. \f[]
  517. .fi
  518. .SH RUNTIME
  519. .SS \&.mergerfs pseudo file
  520. .IP
  521. .nf
  522. \f[C]
  523. <mountpoint>/.mergerfs
  524. \f[]
  525. .fi
  526. .PP
  527. There is a pseudo file available at the mount point which allows for the
  528. runtime modification of certain \f[B]mergerfs\f[] options.
  529. The file will not show up in \f[B]readdir\f[] but can be
  530. \f[B]stat\f[]\[aq]ed and manipulated via
  531. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls.
  532. .PP
  533. Even if xattrs are disabled for mergerfs the
  534. {list,get,set}xattrs (http://linux.die.net/man/2/listxattr) calls
  535. against this pseudo file will still work.
  536. .PP
  537. Any changes made at runtime are \f[B]not\f[] persisted.
  538. If you wish for values to persist they must be included as options
  539. wherever you configure the mounting of mergerfs (fstab).
  540. .SS Keys
  541. .PP
  542. Use \f[C]xattr\ \-l\ /mount/point/.mergerfs\f[] to see all supported
  543. keys.
  544. Some are informational and therefore readonly.
  545. .SS user.mergerfs.srcmounts
  546. .PP
  547. Used to query or modify the list of source mounts.
  548. When modifying there are several shortcuts to easy manipulation of the
  549. list.
  550. .PP
  551. .TS
  552. tab(@);
  553. l l.
  554. T{
  555. Value
  556. T}@T{
  557. Description
  558. T}
  559. _
  560. T{
  561. [list]
  562. T}@T{
  563. set
  564. T}
  565. T{
  566. +<[list]
  567. T}@T{
  568. prepend
  569. T}
  570. T{
  571. +>[list]
  572. T}@T{
  573. append
  574. T}
  575. T{
  576. \-[list]
  577. T}@T{
  578. remove all values provided
  579. T}
  580. T{
  581. \-<
  582. T}@T{
  583. remove first in list
  584. T}
  585. T{
  586. \->
  587. T}@T{
  588. remove last in list
  589. T}
  590. .TE
  591. .SS minfreespace
  592. .PP
  593. Input: interger with an optional multiplier suffix.
  594. \f[B]K\f[], \f[B]M\f[], or \f[B]G\f[].
  595. .PP
  596. Output: value in bytes
  597. .SS moveonenospc
  598. .PP
  599. Input: \f[B]true\f[] and \f[B]false\f[]
  600. .PP
  601. Ouput: \f[B]true\f[] or \f[B]false\f[]
  602. .SS categories / funcs
  603. .PP
  604. Input: short policy string as described elsewhere in this document
  605. .PP
  606. Output: the policy string except for categories where its funcs have
  607. multiple types.
  608. In that case it will be a comma separated list
  609. .SS Example
  610. .IP
  611. .nf
  612. \f[C]
  613. [trapexit:/tmp/mount]\ $\ xattr\ \-l\ .mergerfs
  614. user.mergerfs.srcmounts:\ /tmp/a:/tmp/b
  615. user.mergerfs.minfreespace:\ 4294967295
  616. user.mergerfs.moveonenospc:\ false
  617. \&...
  618. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  619. ff
  620. [trapexit:/tmp/mount]\ $\ xattr\ \-w\ user.mergerfs.category.search\ newest\ .mergerfs
  621. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.category.search\ .mergerfs
  622. newest
  623. [trapexit:/tmp/mount]\ $\ xattr\ \-w\ user.mergerfs.srcmounts\ +/tmp/c\ .mergerfs
  624. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.srcmounts\ .mergerfs
  625. /tmp/a:/tmp/b:/tmp/c
  626. [trapexit:/tmp/mount]\ $\ xattr\ \-w\ user.mergerfs.srcmounts\ =/tmp/c\ .mergerfs
  627. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.srcmounts\ .mergerfs
  628. /tmp/c
  629. [trapexit:/tmp/mount]\ $\ xattr\ \-w\ user.mergerfs.srcmounts\ \[aq]+</tmp/a:/tmp/b\[aq]\ .mergerfs
  630. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.srcmounts\ .mergerfs
  631. /tmp/a:/tmp/b:/tmp/c
  632. \f[]
  633. .fi
  634. .SS file / directory xattrs
  635. .PP
  636. While they won\[aq]t show up when using
  637. listxattr (http://linux.die.net/man/2/listxattr) \f[B]mergerfs\f[]
  638. offers a number of special xattrs to query information about the files
  639. served.
  640. To access the values you will need to issue a
  641. getxattr (http://linux.die.net/man/2/getxattr) for one of the following:
  642. .IP \[bu] 2
  643. \f[B]user.mergerfs.basepath:\f[] the base mount point for the file given
  644. the current getattr policy
  645. .IP \[bu] 2
  646. \f[B]user.mergerfs.relpath:\f[] the relative path of the file from the
  647. perspective of the mount point
  648. .IP \[bu] 2
  649. \f[B]user.mergerfs.fullpath:\f[] the full path of the original file
  650. given the getattr policy
  651. .IP \[bu] 2
  652. \f[B]user.mergerfs.allpaths:\f[] a NUL (\[aq]\[aq]) separated list of
  653. full paths to all files found
  654. .IP
  655. .nf
  656. \f[C]
  657. [trapexit:/tmp/mount]\ $\ ls
  658. A\ B\ C
  659. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.fullpath\ A
  660. /mnt/a/full/path/to/A
  661. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.basepath\ A
  662. /mnt/a
  663. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.relpath\ A
  664. /full/path/to/A
  665. [trapexit:/tmp/mount]\ $\ xattr\ \-p\ user.mergerfs.allpaths\ A\ |\ tr\ \[aq]\\0\[aq]\ \[aq]\\n\[aq]
  666. /mnt/a/full/path/to/A
  667. /mnt/b/full/path/to/A
  668. \f[]
  669. .fi
  670. .SH TOOLING
  671. .IP \[bu] 2
  672. https://github.com/trapexit/mergerfs\-tools
  673. .IP \[bu] 2
  674. mergerfs.ctl: A tool to make it easier to query and configure mergerfs
  675. at runtime
  676. .IP \[bu] 2
  677. mergerfs.fsck: Provides permissions and ownership auditing and the
  678. ability to fix them
  679. .IP \[bu] 2
  680. mergerfs.dedup: Will help identify and optionally remove duplicate files
  681. .IP \[bu] 2
  682. mergerfs.mktrash: Creates FreeDesktop.org Trash specification compatible
  683. directories on a mergerfs mount
  684. .IP \[bu] 2
  685. https://github.com/trapexit/scorch
  686. .IP \[bu] 2
  687. scorch: A tool to help discover silent corruption of files
  688. .SH TIPS / NOTES
  689. .IP \[bu] 2
  690. The recommended options are
  691. \f[B]defaults,allow_other,direct_io,use_ino\f[].
  692. .IP \[bu] 2
  693. Run mergerfs as \f[C]root\f[] unless you\[aq]re merging paths which are
  694. owned by the same user otherwise strange permission issues may arise.
  695. .IP \[bu] 2
  696. https://github.com/trapexit/backup\-and\-recovery\-howtos : A set of
  697. guides / howtos on creating a data storage system, backing it up,
  698. maintaining it, and recovering from failure.
  699. .IP \[bu] 2
  700. If you don\[aq]t see some directories / files you expect in a merged
  701. point be sure the user has permission to all the underlying directories.
  702. Use \f[C]mergerfs.fsck\f[] to audit the drive for out of sync
  703. permissions.
  704. .IP \[bu] 2
  705. Do \f[I]not\f[] use \f[C]direct_io\f[] if you expect applications (such
  706. as rtorrent) to mmap (http://linux.die.net/man/2/mmap) files.
  707. It is not currently supported in FUSE w/ \f[C]direct_io\f[] enabled.
  708. .IP \[bu] 2
  709. Since POSIX gives you only error or success on calls its difficult to
  710. determine the proper behavior when applying the behavior to multiple
  711. targets.
  712. \f[B]mergerfs\f[] will return an error only if all attempts of an action
  713. fail.
  714. Any success will lead to a success returned.
  715. This means however that some odd situations may arise.
  716. .IP \[bu] 2
  717. Remember that some policies mixed with some functions may result in
  718. strange behaviors.
  719. Not that some of these behaviors and race conditions couldn\[aq]t happen
  720. outside \f[B]mergerfs\f[] but that they are far more likely to occur on
  721. account of attempt to merge together multiple sources of data which
  722. could be out of sync due to the different policies.
  723. .IP \[bu] 2
  724. An example: Kodi (http://kodi.tv) and Plex (http://plex.tv) can use
  725. directory mtime (http://linux.die.net/man/2/stat) to more efficiently
  726. determine whether to scan for new content rather than simply performing
  727. a full scan.
  728. If using the current default \f[B]getattr\f[] policy of \f[B]ff\f[] its
  729. possible \f[B]Kodi\f[] will miss an update on account of it returning
  730. the first directory found\[aq]s \f[B]stat\f[] info and its a later
  731. directory on another mount which had the \f[B]mtime\f[] recently
  732. updated.
  733. To fix this you will want to set \f[B]func.getattr=newest\f[].
  734. Remember though that this is just \f[B]stat\f[].
  735. If the file is later \f[B]open\f[]\[aq]ed or \f[B]unlink\f[]\[aq]ed and
  736. the policy is different for those then a completely different file or
  737. directory could be acted on.
  738. .IP \[bu] 2
  739. Due to previously mentioned issues its generally best to set
  740. \f[B]category\f[] wide policies rather than individual
  741. \f[B]func\f[]\[aq]s.
  742. This will help limit the confusion of tools such as
  743. rsync (http://linux.die.net/man/1/rsync).
  744. However, the flexibility is there if needed.
  745. .SH KNOWN ISSUES / BUGS
  746. .SS cached memory appears greater than it should be
  747. .PP
  748. Use the \f[C]direct_io\f[] option as described above.
  749. Due to what mergerfs is doing there ends up being two caches of a file
  750. under normal usage.
  751. One from the underlying filesystem and one from mergerfs.
  752. Enabling \f[C]direct_io\f[] removes the mergerfs cache.
  753. This saves on memory but means the kernel needs to communicate with
  754. mergerfs more often and can therefore result in slower read speeds.
  755. .PP
  756. Since enabling \f[C]direct_io\f[] disables \f[C]mmap\f[] this is not an
  757. ideal situation however write speeds should be increased and there are
  758. some tweaks being developed which may help in minimizing the extra
  759. caching.
  760. .SS NFS clients don\[aq]t work
  761. .PP
  762. Some NFS clients appear to fail when a mergerfs mount is exported.
  763. Kodi in particular seems to have issues.
  764. .PP
  765. Try enabling the \f[C]use_ino\f[] option.
  766. Some have reported that it fixes the issue.
  767. .SS rtorrent fails with ENODEV (No such device)
  768. .PP
  769. Be sure to turn off \f[C]direct_io\f[].
  770. rtorrent and some other applications use
  771. mmap (http://linux.die.net/man/2/mmap) to read and write to files and
  772. offer no failback to traditional methods.
  773. FUSE does not currently support mmap while using \f[C]direct_io\f[].
  774. There will be a performance penalty on writes with \f[C]direct_io\f[]
  775. off as well as the problem of double caching but it\[aq]s the only way
  776. to get such applications to work.
  777. If the performance loss is too high for other apps you can mount
  778. mergerfs twice.
  779. Once with \f[C]direct_io\f[] enabled and one without it.
  780. .SS mmap performance is really bad
  781. .PP
  782. There is a bug (https://lkml.org/lkml/2016/3/16/260) in caching which
  783. affects overall performance of mmap through FUSE in Linux 4.x kernels.
  784. It is fixed in 4.4.10 and 4.5.4 (https://lkml.org/lkml/2016/5/11/59).
  785. .SS Trashing files occasionally fails
  786. .PP
  787. This is the same issue as with Samba.
  788. \f[C]rename\f[] returns \f[C]EXDEV\f[] (in our case that will really
  789. only happen with path preserving policies like \f[C]epmfs\f[]) and the
  790. software doesn\[aq]t handle the situtation well.
  791. This is unfortunately a common failure of software which moves files
  792. around.
  793. The standard indicates that an implementation \f[C]MAY\f[] choose to
  794. support non\-user home directory trashing of files (which is a
  795. \f[C]MUST\f[]).
  796. The implementation \f[C]MAY\f[] also support "top directory trashes"
  797. which many probably do.
  798. .PP
  799. To create a \f[C]$topdir/.Trash\f[] directory as defined in the standard
  800. use the mergerfs\-tools (https://github.com/trapexit/mergerfs-tools)
  801. tool \f[C]mergerfs.mktrash\f[].
  802. .SS Samba: Moving files / directories fails
  803. .PP
  804. Workaround: Copy the file/directory and then remove the original rather
  805. than move.
  806. .PP
  807. This isn\[aq]t an issue with Samba but some SMB clients.
  808. GVFS\-fuse v1.20.3 and prior (found in Ubuntu 14.04 among others) failed
  809. to handle certain error codes correctly.
  810. Particularly \f[B]STATUS_NOT_SAME_DEVICE\f[] which comes from the
  811. \f[B]EXDEV\f[] which is returned by \f[B]rename\f[] when the call is
  812. crossing mount points.
  813. When a program gets an \f[B]EXDEV\f[] it needs to explicitly take an
  814. alternate action to accomplish it\[aq]s goal.
  815. In the case of \f[B]mv\f[] or similar it tries \f[B]rename\f[] and on
  816. \f[B]EXDEV\f[] falls back to a manual copying of data between the two
  817. locations and unlinking the source.
  818. In these older versions of GVFS\-fuse if it received \f[B]EXDEV\f[] it
  819. would translate that into \f[B]EIO\f[].
  820. This would cause \f[B]mv\f[] or most any application attempting to move
  821. files around on that SMB share to fail with a IO error.
  822. .PP
  823. GVFS\-fuse v1.22.0 (https://bugzilla.gnome.org/show_bug.cgi?id=734568)
  824. and above fixed this issue but a large number of systems use the older
  825. release.
  826. On Ubuntu the version can be checked by issuing
  827. \f[C]apt\-cache\ showpkg\ gvfs\-fuse\f[].
  828. Most distros released in 2015 seem to have the updated release and will
  829. work fine but older systems may not.
  830. Upgrading gvfs\-fuse or the distro in general will address the problem.
  831. .PP
  832. In Apple\[aq]s MacOSX 10.9 they replaced Samba (client and server) with
  833. their own product.
  834. It appears their new client does not handle \f[B]EXDEV\f[] either and
  835. responds similar to older release of gvfs on Linux.
  836. .SS Supplemental user groups
  837. .PP
  838. Due to the overhead of
  839. getgroups/setgroups (http://linux.die.net/man/2/setgroups) mergerfs
  840. utilizes a cache.
  841. This cache is opportunistic and per thread.
  842. Each thread will query the supplemental groups for a user when that
  843. particular thread needs to change credentials and will keep that data
  844. for the lifetime of the thread.
  845. This means that if a user is added to a group it may not be picked up
  846. without the restart of mergerfs.
  847. However, since the high level FUSE API\[aq]s (at least the standard
  848. version) thread pool dynamically grows and shrinks it\[aq]s possible
  849. that over time a thread will be killed and later a new thread with no
  850. cache will start and query the new data.
  851. .PP
  852. The gid cache uses fixed storage to simplify the design and be
  853. compatible with older systems which may not have C++11 compilers.
  854. There is enough storage for 256 users\[aq] supplemental groups.
  855. Each user is allowed upto 32 supplemental groups.
  856. Linux >= 2.6.3 allows upto 65535 groups per user but most other *nixs
  857. allow far less.
  858. NFS allowing only 16.
  859. The system does handle overflow gracefully.
  860. If the user has more than 32 supplemental groups only the first 32 will
  861. be used.
  862. If more than 256 users are using the system when an uncached user is
  863. found it will evict an existing user\[aq]s cache at random.
  864. So long as there aren\[aq]t more than 256 active users this should be
  865. fine.
  866. If either value is too low for your needs you will have to modify
  867. \f[C]gidcache.hpp\f[] to increase the values.
  868. Note that doing so will increase the memory needed by each thread.
  869. .SS mergerfs or libfuse crashing
  870. .PP
  871. If suddenly the mergerfs mount point disappears and
  872. \f[C]Transport\ endpoint\ is\ not\ connected\f[] is returned when
  873. attempting to perform actions within the mount directory \f[B]and\f[]
  874. the version of libfuse (use \f[C]mergerfs\ \-v\f[] to find the version)
  875. is older than \f[C]2.9.4\f[] its likely due to a bug in libfuse.
  876. Affected versions of libfuse can be found in Debian Wheezy, Ubuntu
  877. Precise and others.
  878. .PP
  879. In order to fix this please install newer versions of libfuse.
  880. If using a Debian based distro (Debian,Ubuntu,Mint) you can likely just
  881. install newer versions of
  882. libfuse (https://packages.debian.org/unstable/libfuse2) and
  883. fuse (https://packages.debian.org/unstable/fuse) from the repo of a
  884. newer release.
  885. .SS mergerfs under heavy load and memory preasure leads to kernel panic
  886. .PP
  887. https://lkml.org/lkml/2016/9/14/527
  888. .IP
  889. .nf
  890. \f[C]
  891. [25192.515454]\ kernel\ BUG\ at\ /build/linux\-a2WvEb/linux\-4.4.0/mm/workingset.c:346!
  892. [25192.517521]\ invalid\ opcode:\ 0000\ [#1]\ SMP
  893. [25192.519602]\ Modules\ linked\ in:\ netconsole\ ip6t_REJECT\ nf_reject_ipv6\ ipt_REJECT\ nf_reject_ipv4\ configfs\ binfmt_misc\ veth\ bridge\ stp\ llc\ nf_conntrack_ipv6\ nf_defrag_ipv6\ xt_conntrack\ ip6table_filter\ ip6_tables\ xt_multiport\ iptable_filter\ ipt_MASQUERADE\ nf_nat_masquerade_ipv4\ xt_comment\ xt_nat\ iptable_nat\ nf_conntrack_ipv4\ nf_defrag_ipv4\ nf_nat_ipv4\ nf_nat\ nf_conntrack\ xt_CHECKSUM\ xt_tcpudp\ iptable_mangle\ ip_tables\ x_tables\ intel_rapl\ x86_pkg_temp_thermal\ intel_powerclamp\ eeepc_wmi\ asus_wmi\ coretemp\ sparse_keymap\ kvm_intel\ ppdev\ kvm\ irqbypass\ mei_me\ 8250_fintek\ input_leds\ serio_raw\ parport_pc\ tpm_infineon\ mei\ shpchp\ mac_hid\ parport\ lpc_ich\ autofs4\ drbg\ ansi_cprng\ dm_crypt\ algif_skcipher\ af_alg\ btrfs\ raid456\ async_raid6_recov\ async_memcpy\ async_pq\ async_xor\ async_tx\ xor\ raid6_pq\ libcrc32c\ raid0\ multipath\ linear\ raid10\ raid1\ i915\ crct10dif_pclmul\ crc32_pclmul\ aesni_intel\ i2c_algo_bit\ aes_x86_64\ drm_kms_helper\ lrw\ gf128mul\ glue_helper\ ablk_helper\ syscopyarea\ cryptd\ sysfillrect\ sysimgblt\ fb_sys_fops\ drm\ ahci\ r8169\ libahci\ mii\ wmi\ fjes\ video\ [last\ unloaded:\ netconsole]
  894. [25192.540910]\ CPU:\ 2\ PID:\ 63\ Comm:\ kswapd0\ Not\ tainted\ 4.4.0\-36\-generic\ #55\-Ubuntu
  895. [25192.543411]\ Hardware\ name:\ System\ manufacturer\ System\ Product\ Name/P8H67\-M\ PRO,\ BIOS\ 3904\ 04/27/2013
  896. [25192.545840]\ task:\ ffff88040cae6040\ ti:\ ffff880407488000\ task.ti:\ ffff880407488000
  897. [25192.548277]\ RIP:\ 0010:[<ffffffff811ba501>]\ \ [<ffffffff811ba501>]\ shadow_lru_isolate+0x181/0x190
  898. [25192.550706]\ RSP:\ 0018:ffff88040748bbe0\ \ EFLAGS:\ 00010002
  899. [25192.553127]\ RAX:\ 0000000000001c81\ RBX:\ ffff8802f91ee928\ RCX:\ ffff8802f91eeb38
  900. [25192.555544]\ RDX:\ ffff8802f91ee938\ RSI:\ ffff8802f91ee928\ RDI:\ ffff8804099ba2c0
  901. [25192.557914]\ RBP:\ ffff88040748bc08\ R08:\ 000000000001a7b6\ R09:\ 000000000000003f
  902. [25192.560237]\ R10:\ 000000000001a750\ R11:\ 0000000000000000\ R12:\ ffff8804099ba2c0
  903. [25192.562512]\ R13:\ ffff8803157e9680\ R14:\ ffff8803157e9668\ R15:\ ffff8804099ba2c8
  904. [25192.564724]\ FS:\ \ 0000000000000000(0000)\ GS:ffff88041f280000(0000)\ knlGS:0000000000000000
  905. [25192.566990]\ CS:\ \ 0010\ DS:\ 0000\ ES:\ 0000\ CR0:\ 0000000080050033
  906. [25192.569201]\ CR2:\ 00007ffabb690000\ CR3:\ 0000000001e0a000\ CR4:\ 00000000000406e0
  907. [25192.571419]\ Stack:
  908. [25192.573550]\ \ ffff8804099ba2c0\ ffff88039e4f86f0\ ffff8802f91ee928\ ffff8804099ba2c8
  909. [25192.575695]\ \ ffff88040748bd08\ ffff88040748bc58\ ffffffff811b99bf\ 0000000000000052
  910. [25192.577814]\ \ 0000000000000000\ ffffffff811ba380\ 000000000000008a\ 0000000000000080
  911. [25192.579947]\ Call\ Trace:
  912. [25192.582022]\ \ [<ffffffff811b99bf>]\ __list_lru_walk_one.isra.3+0x8f/0x130
  913. [25192.584137]\ \ [<ffffffff811ba380>]\ ?\ memcg_drain_all_list_lrus+0x190/0x190
  914. [25192.586165]\ \ [<ffffffff811b9a83>]\ list_lru_walk_one+0x23/0x30
  915. [25192.588145]\ \ [<ffffffff811ba544>]\ scan_shadow_nodes+0x34/0x50
  916. [25192.590074]\ \ [<ffffffff811a0e9d>]\ shrink_slab.part.40+0x1ed/0x3d0
  917. [25192.591985]\ \ [<ffffffff811a53da>]\ shrink_zone+0x2ca/0x2e0
  918. [25192.593863]\ \ [<ffffffff811a64ce>]\ kswapd+0x51e/0x990
  919. [25192.595737]\ \ [<ffffffff811a5fb0>]\ ?\ mem_cgroup_shrink_node_zone+0x1c0/0x1c0
  920. [25192.597613]\ \ [<ffffffff810a0808>]\ kthread+0xd8/0xf0
  921. [25192.599495]\ \ [<ffffffff810a0730>]\ ?\ kthread_create_on_node+0x1e0/0x1e0
  922. [25192.601335]\ \ [<ffffffff8182e34f>]\ ret_from_fork+0x3f/0x70
  923. [25192.603193]\ \ [<ffffffff810a0730>]\ ?\ kthread_create_on_node+0x1e0/0x1e0
  924. \f[]
  925. .fi
  926. .PP
  927. There is a bug in the kernel.
  928. A work around appears to be turning off \f[C]splice\f[].
  929. Add \f[C]no_splice_write,no_splice_move,no_splice_read\f[] to
  930. mergerfs\[aq] options.
  931. Should be placed after \f[C]defaults\f[] if it is used since it will
  932. turn them on.
  933. This however is not guaranteed to work.
  934. .SH FAQ
  935. .SS Why use mergerfs over mhddfs?
  936. .PP
  937. mhddfs is no longer maintained and has some known stability and security
  938. issues (see below).
  939. MergerFS provides a superset of mhddfs\[aq] features and should offer
  940. the same or maybe better performance.
  941. .SS Why use mergerfs over aufs?
  942. .PP
  943. While aufs can offer better peak performance mergerfs offers more
  944. configurability and is generally easier to use.
  945. mergerfs however does not offer the overlay / copy\-on\-write (COW)
  946. features which aufs and overlayfs have.
  947. .SS Why use mergerfs over LVM/ZFS/BTRFS/RAID0 drive concatenation /
  948. striping?
  949. .PP
  950. With simple JBOD / drive concatenation / stripping / RAID0 a single
  951. drive failure will lead to full pool failure.
  952. mergerfs performs a similar behavior without the catastrophic failure
  953. and general lack of recovery.
  954. Drives can fail and all other data will continue to be accessable.
  955. .PP
  956. When combined with something like SnapRaid (http://www.snapraid.it)
  957. and/or an offsite full backup solution you can have the flexibilty of
  958. JBOD without the single point of failure.
  959. .SS Why use mergerfs over ZFS?
  960. .PP
  961. MergerFS is not intended to be a replacement for ZFS.
  962. MergerFS is intended to provide flexible pooling of arbitrary drives
  963. (local or remote), of arbitrary sizes, and arbitrary filesystems.
  964. For \f[C]write\ once,\ read\ many\f[] usecases such as media storage.
  965. And where data integrity and backup can be managed in other ways.
  966. In that situation ZFS can introduce major maintance and cost burdens as
  967. described
  968. here (http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html).
  969. .SS Can drives be written to directly? Outside of mergerfs while pooled?
  970. .PP
  971. Yes.
  972. It will be represented immediately in the pool as the policies would
  973. describe.
  974. .SS Why do I get an "out of space" error even though the system says
  975. there\[aq]s lots of space left?
  976. .PP
  977. Please reread the sections above about policies, path preserving, and
  978. the \f[B]moveonenospc\f[] option.
  979. If the policy is path preserving and a drive is almost full and the
  980. drive the policy would pick then the writing of the file may fill the
  981. drive and receive ENOSPC errors.
  982. That is expected with those settings.
  983. If you don\[aq]t want that: enable \f[B]moveonenospc\f[] and don\[aq]t
  984. use a path preserving policy.
  985. .SS Can mergerfs mounts be exported over NFS?
  986. .PP
  987. Yes.
  988. Some clients (Kodi) have issues but users have found that enabling the
  989. \f[C]use_ino\f[] option often address the problem.
  990. .SS Can mergerfs mounts be exported over Samba / SMB?
  991. .PP
  992. Yes.
  993. .SS How are inodes calculated?
  994. .PP
  995. mergerfs\-inode = (original\-inode | (device\-id << 32))
  996. .PP
  997. While \f[C]ino_t\f[] is 64 bits only a few filesystems use more than 32.
  998. Similarly, while \f[C]dev_t\f[] is also 64 bits it was traditionally 16
  999. bits.
  1000. Bitwise or\[aq]ing them together should work most of the time.
  1001. While totally unique inodes are preferred the overhead which would be
  1002. needed does not seem to outweighted by the benefits.
  1003. .SS It\[aq]s mentioned that there are some security issues with mhddfs.
  1004. What are they? How does mergerfs address them?
  1005. .PP
  1006. mhddfs (https://github.com/trapexit/mhddfs) manages running as
  1007. \f[B]root\f[] by calling
  1008. getuid() (https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
  1009. and if it returns \f[B]0\f[] then it will
  1010. chown (http://linux.die.net/man/1/chown) the file.
  1011. Not only is that a race condition but it doesn\[aq]t handle many other
  1012. situations.
  1013. Rather than attempting to simulate POSIX ACL behavior the proper way to
  1014. manage this is to use seteuid (http://linux.die.net/man/2/seteuid) and
  1015. setegid (http://linux.die.net/man/2/setegid), in effect becoming the
  1016. user making the original call, and perform the action as them.
  1017. This is what mergerfs does.
  1018. .PP
  1019. In Linux setreuid syscalls apply only to the thread.
  1020. GLIBC hides this away by using realtime signals to inform all threads to
  1021. change credentials.
  1022. Taking after \f[B]Samba\f[], mergerfs uses
  1023. \f[B]syscall(SYS_setreuid,...)\f[] to set the callers credentials for
  1024. that thread only.
  1025. Jumping back to \f[B]root\f[] as necessary should escalated privileges
  1026. be needed (for instance: to clone paths between drives).
  1027. .PP
  1028. For non\-Linux systems mergerfs uses a read\-write lock and changes
  1029. credentials only when necessary.
  1030. If multiple threads are to be user X then only the first one will need
  1031. to change the processes credentials.
  1032. So long as the other threads need to be user X they will take a readlock
  1033. allowing multiple threads to share the credentials.
  1034. Once a request comes in to run as user Y that thread will attempt a
  1035. write lock and change to Y\[aq]s credentials when it can.
  1036. If the ability to give writers priority is supported then that flag will
  1037. be used so threads trying to change credentials don\[aq]t starve.
  1038. This isn\[aq]t the best solution but should work reasonably well
  1039. assuming there are few users.
  1040. .SH SUPPORT
  1041. .SS Issues with the software
  1042. .IP \[bu] 2
  1043. github.com: https://github.com/trapexit/mergerfs/issues
  1044. .IP \[bu] 2
  1045. email: trapexit\@spawn.link
  1046. .IP \[bu] 2
  1047. twitter: https://twitter.com/_trapexit
  1048. .SS Support development
  1049. .IP \[bu] 2
  1050. Gratipay: https://gratipay.com/~trapexit
  1051. .IP \[bu] 2
  1052. BitCoin: 12CdMhEPQVmjz3SSynkAEuD5q9JmhTDCZA
  1053. .SH LINKS
  1054. .IP \[bu] 2
  1055. http://github.com/trapexit/mergerfs
  1056. .IP \[bu] 2
  1057. http://github.com/trapexit/mergerfs\-tools
  1058. .IP \[bu] 2
  1059. http://github.com/trapexit/scorch
  1060. .IP \[bu] 2
  1061. http://github.com/trapexit/backup\-and\-recovery\-howtos
  1062. .SH AUTHORS
  1063. Antonio SJ Musumeci <trapexit@spawn.link>.