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.

1040 lines
37 KiB

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