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.

114 lines
3.8 KiB

  1. # Runtime Interfaces
  2. ## Runtime Config
  3. ### .mergerfs pseudo file
  4. ```
  5. <mountpoint>/.mergerfs
  6. ```
  7. There is a pseudo file available at the mount point which allows for
  8. the runtime modification of certain **mergerfs** options. The file
  9. will not show up in **readdir** but can be **stat**'ed and manipulated
  10. via [{list,get,set}xattrs](http://linux.die.net/man/2/listxattr)
  11. calls.
  12. Any changes made at runtime are **not** persisted. If you wish for
  13. values to persist they must be included as options wherever you
  14. configure the mounting of mergerfs (/etc/fstab).
  15. #### Keys
  16. Use `getfattr -d /mountpoint/.mergerfs` or `xattr -l
  17. /mountpoint/.mergerfs` to see all supported keys. Some are
  18. informational and therefore read-only. `setxattr` will return EINVAL
  19. (invalid argument) on read-only keys.
  20. #### Values
  21. Same as the command line.
  22. ##### user.mergerfs.branches
  23. Used to query or modify the list of branches. When modifying there are
  24. several shortcuts to easy manipulation of the list.
  25. | Value | Description |
  26. | -------- | -------------------------- |
  27. | [list] | set |
  28. | +<[list] | prepend |
  29. | +>[list] | append |
  30. | -[list] | remove all values provided |
  31. | -< | remove first in list |
  32. | -> | remove last in list |
  33. `xattr -w user.mergerfs.branches +</mnt/drive3 /mnt/pool/.mergerfs`
  34. The `=NC`, `=RO`, `=RW` syntax works just as on the command line.
  35. ##### Example
  36. ```
  37. [trapexit:/mnt/mergerfs] $ getfattr -d .mergerfs
  38. user.mergerfs.branches="/mnt/a=RW:/mnt/b=RW"
  39. user.mergerfs.minfreespace="4294967295"
  40. user.mergerfs.moveonenospc="false"
  41. ...
  42. [trapexit:/mnt/mergerfs] $ getfattr -n user.mergerfs.category.search .mergerfs
  43. user.mergerfs.category.search="ff"
  44. [trapexit:/mnt/mergerfs] $ setfattr -n user.mergerfs.category.search -v newest .mergerfs
  45. [trapexit:/mnt/mergerfs] $ getfattr -n user.mergerfs.category.search .mergerfs
  46. user.mergerfs.category.search="newest"
  47. ```
  48. ### file / directory xattrs
  49. While they won't show up when using `getfattr` **mergerfs** offers a
  50. number of special xattrs to query information about the files
  51. served. To access the values you will need to issue a
  52. [getxattr](http://linux.die.net/man/2/getxattr) for one of the
  53. following:
  54. - **user.mergerfs.basepath**: the base mount point for the file given the current getattr policy
  55. - **user.mergerfs.relpath**: the relative path of the file from the perspective of the mount point
  56. - **user.mergerfs.fullpath**: the full path of the original file given the getattr policy
  57. - **user.mergerfs.allpaths**: a NUL ('\0') separated list of full paths to all files found
  58. ## Signals
  59. - USR1: This will cause mergerfs to send invalidation notifications to
  60. the kernel for all files. This will cause all unused files to be
  61. released from memory.
  62. - USR2: Trigger a general cleanup of currently unused memory. A more
  63. thorough version of what happens every ~15 minutes.
  64. ## ioctl
  65. Found in `fuse_ioctl.cpp`:
  66. ```C++
  67. typedef char IOCTL_BUF[4096];
  68. #define IOCTL_APP_TYPE 0xDF
  69. #define IOCTL_FILE_INFO _IOWR(IOCTL_APP_TYPE,0,IOCTL_BUF)
  70. #define IOCTL_GC _IO(IOCTL_APP_TYPE,1)
  71. #define IOCTL_GC1 _IO(IOCTL_APP_TYPE,2)
  72. #define IOCTL_INVALIDATE_ALL_NODES _IO(IOCTL_APP_TYPE,3)
  73. ```
  74. - IOCTL_FILE_INFO: Same as the "file / directory xattrs" mentioned
  75. above. Use a buffer size of 4096 bytes. Pass in a string of
  76. "basepath", "relpath", "fullpath", or "allpaths". Receive details in
  77. same buffer.
  78. - IOCTL_GC: Triggers a thorough garbage collection of excess
  79. memory. Same as SIGUSR2.
  80. - IOCTL_GC1: Triggers a simple garbage collection of excess
  81. memory. Same as what happens every 15 minutes normally.
  82. - IOCTL_INVALIDATE_ALL_NODES: Same as SIGUSR1. Send invalidation
  83. notifications to the kernel for all files causing unused files to be
  84. released from memory.