Compare commits

...
50 Commits
Author SHA1 Message Date
Antonio SJ Musumeci bcbff5c82e Add FAQ entry regarding inotify 2025-03-05 16:58:27 -06:00
trapexit c0d5f4795a Merge pull request #1415 from trapexit/docs
Update docs on out-of-band usage
2025-02-19 14:13:32 -06:00
Antonio SJ Musumeci ef9074ab4a Update docs on out-of-band usage 2025-02-19 14:13:06 -06:00
trapexit 2d03b89c2d Merge pull request #1414 from theHenMan/patch-2
Update terminology.md
2025-02-19 00:09:55 -06:00
trapexit 64cc63b2bc Merge pull request #1413 from theHenMan/patch-1
Update quickstart.md
2025-02-18 23:04:59 -06:00
Hennie Botha 514c478a39 Update terminology.md
Fixed typo
2025-02-19 07:04:11 +02:00
Hennie Botha 8179f91c48 Update quickstart.md
Fixed a typo
2025-02-19 07:02:22 +02:00
trapexit 371764d800 Merge pull request #1412 from trapexit/docs
Rework questions on what settings and policies to use
2025-02-11 19:47:18 -06:00
Antonio SJ Musumeci 1c44ef7967 Rework questions on what settings and policies to use 2025-02-11 19:46:33 -06:00
trapexit aa97bac533 Merge pull request #1409 from trapexit/docs
Add details about logging to syslog
2025-01-25 20:58:57 -06:00
Antonio SJ Musumeci 12d6302457 Add details about logging to syslog 2025-01-25 20:56:28 -06:00
trapexit 740fc3f84a Merge pull request #1408 from trapexit/docs
Add details about user namespacing and root squashing
2025-01-25 13:54:43 -06:00
Antonio SJ Musumeci f18719ced2 Add details about user namespacing and root squashing 2025-01-25 13:54:06 -06:00
trapexit 366f5fcc4c Merge pull request #1407 from trapexit/docs
Misc doc updates
2025-01-25 13:02:36 -06:00
Antonio SJ Musumeci 1729835b8c Misc doc updates 2025-01-25 13:00:00 -06:00
trapexit 1180fd6dd3 Merge pull request #1402 from trapexit/docs
Doc and mover script updates
2025-01-20 01:45:51 -06:00
Antonio SJ Musumeci 19509e33d2 Doc and mover script updates 2025-01-20 01:43:58 -06:00
trapexit 8f355d7dd5 Merge pull request #1399 from oregonpillow/master
Readability changes to mkdocs installation
2025-01-18 15:21:20 -06:00
debian 2aa9697c87 re-order OS, shorten Debian based OS instructions 2025-01-18 01:14:50 +01:00
trapexit 978d067921 Merge pull request #1398 from trapexit/freebsd
Improve FreeBSD compatibility
2025-01-15 22:16:13 -06:00
Antonio SJ Musumeci b83bd5fd14 Improve FreeBSD compatibility
First draft. Need to investigate why upstream patches include certain
function that appear to exist in FreeBSD 14.2.
2025-01-15 22:10:02 -06:00
trapexit dd906c8a4c Merge pull request #1395 from oregonpillow/latest-release
fix edit uri
2025-01-11 18:07:15 -06:00
debian 6fb9111c03 fix edit uri 2025-01-12 00:56:39 +01:00
trapexit bc382e0fd2 Merge pull request #1392 from trapexit/usr1
Send invalidate node request outside lock
2025-01-10 00:35:59 -05:00
trapexit 0197984db3 Send invalidate node request outside lock 2025-01-09 23:22:07 -06:00
trapexit 248b1aca1c Merge pull request #1391 from trapexit/cpp
Move fuse.c and fuse_lowlevel.c to C++
2025-01-09 20:10:35 -05:00
Antonio SJ Musumeci 9056898bbf Move fuse.c and fuse_lowlevel.c to C++ 2025-01-09 19:05:32 -06:00
trapexit 5e584f246a Merge pull request #1390 from trapexit/tiered
Add tiered cache details to docs
2025-01-08 00:56:48 -05:00
Antonio SJ Musumeci 7e964283b9 Add tiered cache details to docs 2025-01-07 23:55:13 -06:00
trapexit 03dc17fff2 Merge pull request #1389 from trapexit/misc
Update funding and cirrus builds
2025-01-07 00:18:32 -05:00
Antonio SJ Musumeci 8cb68dce4a Update funding and cirrus builds 2025-01-06 23:07:33 -06:00
trapexit 28260c434a Merge pull request #1388 from trapexit/mkdocs
Update README to point to docs, update project comparisons
2025-01-05 23:40:54 -06:00
Antonio SJ Musumeci fae9b993fe Update README to point to docs, update project comparisons 2025-01-05 23:39:48 -06:00
trapexit 171eb9c7c0 Merge pull request #1387 from trapexit/workflows
Fix pip install in mkdocs workflow
2025-01-03 12:41:47 -06:00
Antonio SJ Musumeci 174e703d2e Fix pip install in mkdocs workflow 2025-01-03 12:40:50 -06:00
trapexit efd0dfaa2f Merge pull request #1386 from trapexit/docs
Rework mkdocs based documentation
2025-01-03 12:33:54 -06:00
Antonio SJ Musumeci 75d7a93724 Rework mkdocs based documentation
Lots of restructoring and extra information.
2025-01-03 12:17:26 -06:00
Timothy Pillow 50fa7ac694 add mkdocs
Initial commit of a mkdocs based docs setup
2024-12-21 09:36:07 -06:00
trapexit 7d64a47b88 Merge pull request #1377 from trapexit/movecopy-readme
Add FAQ entry on 'move' and 'copy'
2024-11-30 00:23:39 -06:00
Antonio SJ Musumeci 5fba42f076 Add FAQ entry on 'move' and 'copy' 2024-11-30 00:12:44 -06:00
trapexit b0bb7ef38c Merge pull request #1346 from grunthos503/master
Add missing --relative flag to rsync in percent-full mover script
2024-07-18 15:28:42 -05:00
Alan Millar 85ce7d6178 Add missing --relative flag to rsync in percent-full mover script 2024-07-18 12:14:02 -07:00
trapexit 40359df453 Merge pull request #1342 from techie2000/patch-2
Update README.md
2024-07-18 13:50:29 -05:00
techie2000 9b2a5a75ee Update README.md
Correcting a couple of typos.
Enhancing readability.
2024-06-28 10:15:02 +01:00
trapexit b21172c609 Merge pull request #1321 from trapexit/allowmmap
Add support for 'direct-io-allow-mmap' if supported by kernel
2024-03-21 21:54:04 -04:00
Antonio SJ Musumeci f0444a1ca9 Add support for 'direct-io-allow-mmap' if supported by kernel 2024-03-21 20:48:42 -05:00
trapexit 977d04229f Merge pull request #1320 from trapexit/readme
Suggest cache.files=auto-full rather than partial
2024-03-21 21:36:27 -04:00
Antonio SJ Musumeci 757ae66327 Suggest cache.files=auto-full rather than partial 2024-03-17 00:47:33 -05:00
trapexit 42d0b5734c Merge pull request #1312 from trapexit/preload-tmpfile
Special case O_TMPFILE in preload
2024-02-29 15:41:22 -05:00
Antonio SJ Musumeci 78050ed6b0 Special case O_TMPFILE in preload 2024-02-29 14:33:27 -06:00
80 changed files with 4534 additions and 4446 deletions
+19 -396
View File
@@ -1,128 +1,3 @@
freebsd_task:
name: "freebsd:11.4"
freebsd_instance:
image_family: freebsd-11-4
env:
ASSUME_ALWAYS_YES: yes
script:
- buildtools/install-build-pkgs
- gmake -j4
freebsd_task:
name: "freebsd:12.1"
freebsd_instance:
image_family: freebsd-12-1
env:
ASSUME_ALWAYS_YES: yes
script:
- buildtools/install-build-pkgs
- gmake -j4
freebsd_task:
name: "freebsd:12.2"
freebsd_instance:
image_family: freebsd-12-2
env:
ASSUME_ALWAYS_YES: yes
script:
- buildtools/install-build-pkgs
- gmake -j4
freebsd_task:
name: "freebsd:13.0"
freebsd_instance:
image_family: freebsd-13-0
env:
ASSUME_ALWAYS_YES: yes
script:
- buildtools/install-build-pkgs
- gmake -j4
#macos_task:
# osx_instance:
# image: catalina-base
# script:
# - buildtools/install-build-pkgs
# - gmake -j4
linux_task:
name: "alpine:3.11"
container:
image: alpine:3.11
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make STATIC=1 LTO=1
linux_task:
name: "alpine:3.12"
container:
image: alpine:3.12
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make STATIC=1 LTO=1
linux_task:
name: "alpine:3.13"
container:
image: alpine:3.13
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make STATIC=1 LTO=1
linux_task:
name: "alpine:3.14"
container:
image: alpine:3.14
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make STATIC=1 LTO=1
linux_task:
name: "alpine:3.15"
container:
image: alpine:3.15
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make STATIC=1 LTO=1
linux_task:
name: "alpine:3.16"
container:
image: alpine:3.16
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make STATIC=1 LTO=1
linux_task:
name: "alpine:3.17"
container:
image: alpine:3.17
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make STATIC=1 LTO=1
linux_task:
name: "alpine:latest"
container:
@@ -146,9 +21,9 @@ linux_task:
- make STATIC=1 LTO=1
linux_task:
name: "centos:7"
name: "fedora:41"
container:
image: centos:7
image: fedora:41
cpu: 4
memory: 4G
timeout_in: 15m
@@ -158,141 +33,9 @@ linux_task:
- make rpm
linux_task:
name: "rocky:8"
container:
image: rocky:8
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora:30"
container:
image: fedora:30
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora:31"
container:
image: fedora:31
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora:32"
container:
image: fedora:32
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora:33"
container:
image: fedora:33
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora:34"
container:
image: fedora:34
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora:35"
container:
image: fedora:35
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora:36"
container:
image: fedora:36
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora:37"
container:
image: fedora:37
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora:38"
container:
image: fedora:38
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora:latest"
container:
image: fedora:latest
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- make
- make rpm
linux_task:
name: "fedora-arm:latest"
name: "fedora-arm:41"
arm_container:
image: fedora:latest
image: fedora:41
cpu: 4
memory: 4G
timeout_in: 15m
@@ -301,66 +44,6 @@ linux_task:
- make
- make rpm
linux_task:
name: "ubuntu:14.04"
container:
image: ubuntu:14.04
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- git fetch
- make deb
- apt-get -y install fuse
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "ubuntu:16.04"
container:
image: ubuntu:16.04
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- git fetch
- make deb
- apt-get -y install fuse
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "ubuntu:18.04"
container:
image: ubuntu:18.04
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- git fetch
- make deb
- apt-get -y install fuse
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "ubuntu:20.04"
container:
image: ubuntu:20.04
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- git fetch
- make deb
- apt-get -y install fuse
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "ubuntu:22.04"
container:
@@ -376,6 +59,21 @@ linux_task:
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "ubuntu:24.04"
container:
image: ubuntu:24.04
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- git fetch
- make deb
- apt-get -y install fuse
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "ubuntu:latest"
container:
@@ -406,81 +104,6 @@ linux_task:
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "debian:7"
container:
image: debian:8
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- git fetch
- make deb
- apt-get -y install fuse
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "debian:8"
container:
image: debian:8
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- git fetch
- make deb
- apt-get -y install fuse
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "debian:9"
container:
image: debian:9
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- git fetch
- make deb
- apt-get -y install fuse
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "debian:10"
container:
image: debian:10
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- git fetch
- make deb
- apt-get -y install fuse
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "debian:11"
container:
image: debian:11
cpu: 4
memory: 4G
timeout_in: 15m
script:
- buildtools/install-build-pkgs
- git fetch
- make deb
- apt-get -y install fuse
- dpkg -i ../*.deb
- mergerfs -v || true
linux_task:
name: "debian:12"
container:
+1 -6
View File
@@ -1,7 +1,2 @@
# These are supported funding model platforms
github: [trapexit]
patreon: trapexit
custom: ['https://paypal.me/trapexit','https://buymeacoff.ee/trapexit']
ko_fi: trapexit
open_collective: trapexit
custom: ['https://github.com/trapexit/support']
+23
View File
@@ -0,0 +1,23 @@
name: "mkdocs"
on:
push:
branches:
- master
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install --no-cache-dir mkdocs mkdocs-material pymdown-extensions
working-directory: ./mkdocs
- run: mkdocs gh-deploy --force
working-directory: ./mkdocs
+4
View File
@@ -23,3 +23,7 @@ debian/changelog
# RPM files
rpmbuild/
# mkdocs files
mkdocs/venv
__pycache__/
+60 -2691
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -71,6 +71,8 @@ CFLAGS := \
-Wall \
-pipe \
-MMD
CXXFLAGS ?= \
$(OPT_FLAGS)
CXXFLAGS := \
${CXXFLAGS} \
$(LTO_FLAGS) \
+24 -60
View File
@@ -108,23 +108,26 @@ struct fuse_file_info_t
* FUSE_CAP_IOCTL_DIR: ioctl support on directories
* FUSE_CAP_CACHE_SYMLINKS: cache READLINK responses
*/
#define FUSE_CAP_ASYNC_READ (1 << 0)
#define FUSE_CAP_POSIX_LOCKS (1 << 1)
#define FUSE_CAP_ATOMIC_O_TRUNC (1 << 3)
#define FUSE_CAP_EXPORT_SUPPORT (1 << 4)
#define FUSE_CAP_BIG_WRITES (1 << 5)
#define FUSE_CAP_DONT_MASK (1 << 6)
#define FUSE_CAP_FLOCK_LOCKS (1 << 10)
#define FUSE_CAP_IOCTL_DIR (1 << 11)
#define FUSE_CAP_READDIR_PLUS (1 << 13)
#define FUSE_CAP_READDIR_PLUS_AUTO (1 << 14)
#define FUSE_CAP_ASYNC_DIO (1 << 15)
#define FUSE_CAP_WRITEBACK_CACHE (1 << 16)
#define FUSE_CAP_PARALLEL_DIROPS (1 << 18)
#define FUSE_CAP_POSIX_ACL (1 << 19)
#define FUSE_CAP_CACHE_SYMLINKS (1 << 20)
#define FUSE_CAP_MAX_PAGES (1 << 21)
#define FUSE_CAP_SETXATTR_EXT (1 << 22)
#define FUSE_CAP_ASYNC_READ (1ULL << 0)
#define FUSE_CAP_POSIX_LOCKS (1ULL << 1)
#define FUSE_CAP_ATOMIC_O_TRUNC (1ULL << 3)
#define FUSE_CAP_EXPORT_SUPPORT (1ULL << 4)
#define FUSE_CAP_BIG_WRITES (1ULL << 5)
#define FUSE_CAP_DONT_MASK (1ULL << 6)
#define FUSE_CAP_FLOCK_LOCKS (1ULL << 10)
#define FUSE_CAP_IOCTL_DIR (1ULL << 11)
#define FUSE_CAP_READDIR_PLUS (1ULL << 13)
#define FUSE_CAP_READDIR_PLUS_AUTO (1ULL << 14)
#define FUSE_CAP_ASYNC_DIO (1ULL << 15)
#define FUSE_CAP_WRITEBACK_CACHE (1ULL << 16)
#define FUSE_CAP_PARALLEL_DIROPS (1ULL << 18)
#define FUSE_CAP_POSIX_ACL (1ULL << 19)
#define FUSE_CAP_CACHE_SYMLINKS (1ULL << 20)
#define FUSE_CAP_MAX_PAGES (1ULL << 21)
#define FUSE_CAP_SETXATTR_EXT (1ULL << 22)
#define FUSE_CAP_DIRECT_IO_ALLOW_MMAP (1ULL << 23)
#define FUSE_CAP_CREATE_SUPP_GROUP (1ULL << 24)
/**
* Ioctl flags
@@ -150,56 +153,17 @@ struct fuse_file_info_t
* indicate the value requested by the filesystem. The requested
* value must usually be smaller than the indicated value.
*/
struct fuse_conn_info {
/**
* Major version of the protocol (read-only)
*/
struct fuse_conn_info
{
unsigned proto_major;
/**
* Minor version of the protocol (read-only)
*/
unsigned proto_minor;
/**
* Maximum size of the write buffer
*/
unsigned max_write;
/**
* Maximum readahead
*/
unsigned max_readahead;
/**
* Capability flags, that the kernel supports
*/
unsigned capable;
/**
* Capability flags, that the filesystem wants to enable
*/
unsigned want;
/**
* Maximum number of backgrounded requests
*/
uint64_t capable;
uint64_t want;
unsigned max_background;
/**
* Kernel congestion threshold parameter
*/
unsigned congestion_threshold;
/**
* Max pages
*/
uint16_t max_pages;
/**
* For future use.
*/
unsigned reserved[22];
};
struct fuse_session;
+1 -1
View File
@@ -442,7 +442,7 @@ struct fuse_file_lock {
#define FUSE_HANDLE_KILLPRIV_V2 (1 << 28)
#define FUSE_SETXATTR_EXT (1 << 29)
#define FUSE_INIT_EXT (1 << 30)
#define FUSE_INIT_RESERVED (1 << 31)
#define FUSE_INIT_RESERVED (1ULL << 31)
/* bits 32..63 get shifted down 32 bits into the flags2 field */
#define FUSE_SECURITY_CTX (1ULL << 32)
#define FUSE_HAS_INODE_DAX (1ULL << 33)
+48 -884
View File
@@ -131,891 +131,55 @@ struct fuse_ctx
*/
struct fuse_lowlevel_ops
{
/**
* Initialize filesystem
*
* Called before any other filesystem method
*
* There's no reply to this function
*
* @param userdata the user data passed to fuse_lowlevel_new()
*/
void (*init)(void *userdata, struct fuse_conn_info *conn);
/**
* Clean up filesystem
*
* Called on filesystem exit
*
* There's no reply to this function
*
* @param userdata the user data passed to fuse_lowlevel_new()
*/
void (*access)(fuse_req_t req, struct fuse_in_header *hdr);
void (*bmap)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*copy_file_range)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*create)(fuse_req_t req, struct fuse_in_header *hdr);
void (*destroy)(void *userdata);
/**
* Look up a directory entry by name and get its attributes.
*
* Valid replies:
* fuse_reply_entry
* fuse_reply_err
*
* @param req request handle
* @param parent inode number of the parent directory
* @param name the name to look up
*/
void (*lookup)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Forget about an inode
*
* This function is called when the kernel removes an inode
* from its internal caches.
*
* The inode's lookup count increases by one for every call to
* fuse_reply_entry and fuse_reply_create. The nlookup parameter
* indicates by how much the lookup count should be decreased.
*
* Inodes with a non-zero lookup count may receive request from
* the kernel even after calls to unlink, rmdir or (when
* overwriting an existing file) rename. Filesystems must handle
* such requests properly and it is recommended to defer removal
* of the inode until the lookup count reaches zero. Calls to
* unlink, remdir or rename will be followed closely by forget
* unless the file or directory is open, in which case the
* kernel issues forget only after the release or releasedir
* calls.
*
* Note that if a file system will be exported over NFS the
* inodes lifetime must extend even beyond forget. See the
* generation field in struct fuse_entry_param above.
*
* On unmount the lookup count for all inodes implicitly drops
* to zero. It is not guaranteed that the file system will
* receive corresponding forget messages for the affected
* inodes.
*
* Valid replies:
* fuse_reply_none
*
* @param req request handle
* @param ino the inode number
* @param nlookup the number of lookups to forget
*/
void (*forget)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Get file attributes
*
* Valid replies:
* fuse_reply_attr
* fuse_reply_err
*/
void (*getattr)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Set file attributes
*
* In the 'attr' argument only members indicated by the 'to_set'
* bitmask contain valid values. Other members contain undefined
* values.
*
* If the setattr was invoked from the ftruncate() system call
* under Linux kernel versions 2.6.15 or later, the fi->fh will
* contain the value set by the open method or will be undefined
* if the open method didn't set any value. Otherwise (not
* ftruncate call, or kernel version earlier than 2.6.15) the fi
* parameter will be NULL.
*
* Valid replies:
* fuse_reply_attr
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param attr the attributes
* @param to_set bit mask of attributes which should be set
* @param fi file information, or NULL
*
* Changed in version 2.5:
* file information filled in for ftruncate
*/
void (*setattr)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Read symbolic link
*
* Valid replies:
* fuse_reply_readlink
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
*/
void (*readlink)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Create file node
*
* Create a regular file, character device, block device, fifo or
* socket node.
*
* Valid replies:
* fuse_reply_entry
* fuse_reply_err
*
* @param req request handle
* @param parent inode number of the parent directory
* @param name to create
* @param mode file type and mode with which to create the new file
* @param rdev the device number (only valid if created file is a device)
*/
void (*mknod)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Create a directory
*
* Valid replies:
* fuse_reply_entry
* fuse_reply_err
*
* @param req request handle
* @param parent inode number of the parent directory
* @param name to create
* @param mode with which to create the new file
*/
void (*mkdir)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Remove a file
*
* If the file's inode's lookup count is non-zero, the file
* system is expected to postpone any removal of the inode
* until the lookup count reaches zero (see description of the
* forget function).
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param parent inode number of the parent directory
* @param name to remove
*/
void (*unlink)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Remove a directory
*
* If the directory's inode's lookup count is non-zero, the
* file system is expected to postpone any removal of the
* inode until the lookup count reaches zero (see description
* of the forget function).
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param parent inode number of the parent directory
* @param name to remove
*/
void (*rmdir)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Create a symbolic link
*
* Valid replies:
* fuse_reply_entry
* fuse_reply_err
*
* @param req request handle
* @param link the contents of the symbolic link
* @param parent inode number of the parent directory
* @param name to create
*/
void (*symlink)(fuse_req_t req,
struct fuse_in_header *hdr);
/** Rename a file
*
* If the target exists it should be atomically replaced. If
* the target's inode's lookup count is non-zero, the file
* system is expected to postpone any removal of the inode
* until the lookup count reaches zero (see description of the
* forget function).
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param parent inode number of the old parent directory
* @param name old name
* @param newparent inode number of the new parent directory
* @param newname new name
*/
void (*rename)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Create a hard link
*
* Valid replies:
* fuse_reply_entry
* fuse_reply_err
*
* @param req request handle
* @param ino the old inode number
* @param newparent inode number of the new parent directory
* @param newname new name to create
*/
void (*link)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Open a file
*
* Open flags (with the exception of O_CREAT, O_EXCL, O_NOCTTY and
* O_TRUNC) are available in fi->flags.
*
* Filesystem may store an arbitrary file handle (pointer, index,
* etc) in fi->fh, and use this in other all other file operations
* (read, write, flush, release, fsync).
*
* Filesystem may also implement stateless file I/O and not store
* anything in fi->fh.
*
* There are also some flags (direct_io, keep_cache) which the
* filesystem may set in fi, to change the way the file is opened.
* See fuse_file_info structure in <fuse_common.h> for more details.
*
* Valid replies:
* fuse_reply_open
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param fi file information
*/
void (*open)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Read data
*
* Read should send exactly the number of bytes requested except
* on EOF or error, otherwise the rest of the data will be
* substituted with zeroes. An exception to this is when the file
* has been opened in 'direct_io' mode, in which case the return
* value of the read system call will reflect the return value of
* this operation.
*
* fi->fh will contain the value set by the open method, or will
* be undefined if the open method didn't set any value.
*
* Valid replies:
* fuse_reply_buf
* fuse_reply_iov
* fuse_reply_data
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param size number of bytes to read
* @param off offset to read from
* @param fi file information
*/
void (*read)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Write data
*
* Write should return exactly the number of bytes requested
* except on error. An exception to this is when the file has
* been opened in 'direct_io' mode, in which case the return value
* of the write system call will reflect the return value of this
* operation.
*
* fi->fh will contain the value set by the open method, or will
* be undefined if the open method didn't set any value.
*
* Valid replies:
* fuse_reply_write
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param buf data to write
* @param size number of bytes to write
* @param off offset to write to
* @param fi file information
*/
void (*write)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Flush method
*
* This is called on each close() of the opened file.
*
* Since file descriptors can be duplicated (dup, dup2, fork), for
* one open call there may be many flush calls.
*
* Filesystems shouldn't assume that flush will always be called
* after some writes, or that if will be called at all.
*
* fi->fh will contain the value set by the open method, or will
* be undefined if the open method didn't set any value.
*
* NOTE: the name of the method is misleading, since (unlike
* fsync) the filesystem is not forced to flush pending writes.
* One reason to flush data, is if the filesystem wants to return
* write errors.
*
* If the filesystem supports file locking operations (setlk,
* getlk) it should remove all locks belonging to 'fi->owner'.
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param fi file information
*/
void (*flush)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Release an open file
*
* Release is called when there are no more references to an open
* file: all file descriptors are closed and all memory mappings
* are unmapped.
*
* For every open call there will be exactly one release call.
*
* The filesystem may reply with an error, but error values are
* not returned to close() or munmap() which triggered the
* release.
*
* fi->fh will contain the value set by the open method, or will
* be undefined if the open method didn't set any value.
* fi->flags will contain the same flags as for open.
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param fi file information
*/
void (*release)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Synchronize file contents
*
* If the datasync parameter is non-zero, then only the user data
* should be flushed, not the meta data.
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param datasync flag indicating if only data should be flushed
* @param fi file information
*/
void (*fsync)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Open a directory
*
* Filesystem may store an arbitrary file handle (pointer, index,
* etc) in fi->fh, and use this in other all other directory
* stream operations (readdir, releasedir, fsyncdir).
*
* Filesystem may also implement stateless directory I/O and not
* store anything in fi->fh, though that makes it impossible to
* implement standard conforming directory stream operations in
* case the contents of the directory can change between opendir
* and releasedir.
*
* Valid replies:
* fuse_reply_open
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param fi file information
*/
void (*opendir)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Read directory
*
* Send a buffer filled using fuse_add_direntry(), with size not
* exceeding the requested size. Send an empty buffer on end of
* stream.
*
* fi->fh will contain the value set by the opendir method, or
* will be undefined if the opendir method didn't set any value.
*
* Valid replies:
* fuse_reply_buf
* fuse_reply_data
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param size maximum number of bytes to send
* @param off offset to continue reading the directory stream
* @param fi file information
*/
void (*readdir)(fuse_req_t req,
struct fuse_in_header *hdr);
void (*readdir_plus)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Release an open directory
*
* For every opendir call there will be exactly one releasedir
* call.
*
* fi->fh will contain the value set by the opendir method, or
* will be undefined if the opendir method didn't set any value.
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param fi file information
*/
void (*releasedir)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Synchronize directory contents
*
* If the datasync parameter is non-zero, then only the directory
* contents should be flushed, not the meta data.
*
* fi->fh will contain the value set by the opendir method, or
* will be undefined if the opendir method didn't set any value.
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param datasync flag indicating if only data should be flushed
* @param fi file information
*/
void (*fsyncdir)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Get file system statistics
*
* Valid replies:
* fuse_reply_statfs
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number, zero means "undefined"
*/
void (*statfs)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Set an extended attribute
*
* Valid replies:
* fuse_reply_err
*/
void (*setxattr)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Get an extended attribute
*
* If size is zero, the size of the value should be sent with
* fuse_reply_xattr.
*
* If the size is non-zero, and the value fits in the buffer, the
* value should be sent with fuse_reply_buf.
*
* If the size is too small for the value, the ERANGE error should
* be sent.
*
* Valid replies:
* fuse_reply_buf
* fuse_reply_data
* fuse_reply_xattr
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param name of the extended attribute
* @param size maximum size of the value to send
*/
void (*getxattr)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* List extended attribute names
*
* If size is zero, the total size of the attribute list should be
* sent with fuse_reply_xattr.
*
* If the size is non-zero, and the null character separated
* attribute list fits in the buffer, the list should be sent with
* fuse_reply_buf.
*
* If the size is too small for the list, the ERANGE error should
* be sent.
*
* Valid replies:
* fuse_reply_buf
* fuse_reply_data
* fuse_reply_xattr
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param size maximum size of the list to send
*/
void (*listxattr)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Remove an extended attribute
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param name of the extended attribute
*/
void (*removexattr)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Check file access permissions
*
* This will be called for the access() system call. If the
* 'default_permissions' mount option is given, this method is not
* called.
*
* This method is not called under Linux kernel versions 2.4.x
*
* Introduced in version 2.5
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param mask requested access mode
*/
void (*access)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Create and open a file
*
* If the file does not exist, first create it with the specified
* mode, and then open it.
*
* Open flags (with the exception of O_NOCTTY) are available in
* fi->flags.
*
* Filesystem may store an arbitrary file handle (pointer, index,
* etc) in fi->fh, and use this in other all other file operations
* (read, write, flush, release, fsync).
*
* There are also some flags (direct_io, keep_cache) which the
* filesystem may set in fi, to change the way the file is opened.
* See fuse_file_info structure in <fuse_common.h> for more details.
*
* If this method is not implemented or under Linux kernel
* versions earlier than 2.6.15, the mknod() and open() methods
* will be called instead.
*
* Introduced in version 2.5
*
* Valid replies:
* fuse_reply_create
* fuse_reply_err
*
* @param req request handle
* @param parent inode number of the parent directory
* @param name to create
* @param mode file type and mode with which to create the new file
* @param fi file information
*/
void (*create)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Test for a POSIX file lock
*
* Introduced in version 2.6
*
* Valid replies:
* fuse_reply_lock
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param fi file information
* @param lock the region/type to test
*/
void (*getlk)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Acquire, modify or release a POSIX file lock
*
* For POSIX threads (NPTL) there's a 1-1 relation between pid and
* owner, but otherwise this is not always the case. For checking
* lock ownership, 'fi->owner' must be used. The l_pid field in
* 'struct flock' should only be used to fill in this field in
* getlk().
*
* Note: if the locking methods are not implemented, the kernel
* will still allow file locking to work locally. Hence these are
* only interesting for network filesystems and similar.
*
* Introduced in version 2.6
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param fi file information
* @param lock the region/type to set
* @param sleep locking operation may sleep
*/
void (*setlk)(fuse_req_t req, uint64_t ino,
fuse_file_info_t *fi,
struct flock *lock, int sleep);
/**
* Map block index within file to block index within device
*
* Note: This makes sense only for block device backed filesystems
* mounted with the 'blkdev' option
*
* Introduced in version 2.6
*
* Valid replies:
* fuse_reply_bmap
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param blocksize unit of block index
* @param idx block index within file
*/
void (*bmap)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Ioctl
*
* Note: For unrestricted ioctls (not allowed for FUSE
* servers), data in and out areas can be discovered by giving
* iovs and setting FUSE_IOCTL_RETRY in @flags. For
* restricted ioctls, kernel prepares in/out data area
* according to the information encoded in cmd.
*
* Introduced in version 2.8
*
* Valid replies:
* fuse_reply_ioctl_retry
* fuse_reply_ioctl
* fuse_reply_ioctl_iov
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param cmd ioctl command
* @param arg ioctl argument
* @param fi file information
* @param flags for FUSE_IOCTL_* flags
* @param in_buf data fetched from the caller
* @param in_bufsz number of fetched bytes
* @param out_bufsz maximum size of output data
*/
void (*ioctl)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Poll for IO readiness
*
* Introduced in version 2.8
*
* Note: If ph is non-NULL, the client should notify
* when IO readiness events occur by calling
* fuse_lowelevel_notify_poll() with the specified ph.
*
* Regardless of the number of times poll with a non-NULL ph
* is received, single notification is enough to clear all.
* Notifying more times incurs overhead but doesn't harm
* correctness.
*
* The callee is responsible for destroying ph with
* fuse_pollhandle_destroy() when no longer in use.
*
* Valid replies:
* fuse_reply_poll
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param fi file information
* @param ph poll handle to be used for notification
*/
void (*poll)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Callback function for the retrieve request
*
* Introduced in version 2.9
*
* Valid replies:
* fuse_reply_none
*
* @param req request handle
* @param cookie user data supplied to fuse_lowlevel_notify_retrieve()
* @param ino the inode number supplied to fuse_lowlevel_notify_retrieve()
* @param offset the offset supplied to fuse_lowlevel_notify_retrieve()
* @param bufv the buffer containing the returned data
*/
void (*retrieve_reply)(fuse_req_t req,
void *cookie,
uint64_t ino,
off_t offset);
/**
* Forget about multiple inodes
*
* See description of the forget function for more
* information.
*
* Introduced in version 2.9
*
* Valid replies:
* fuse_reply_none
*
* @param req request handle
*/
void (*forget_multi)(fuse_req_t req,
struct fuse_in_header *hdr);
/**
* Acquire, modify or release a BSD file lock
*
* Note: if the locking methods are not implemented, the kernel
* will still allow file locking to work locally. Hence these are
* only interesting for network filesystems and similar.
*
* Introduced in version 2.9
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param fi file information
* @param op the locking operation, see flock(2)
*/
void (*flock)(fuse_req_t req, uint64_t ino,
fuse_file_info_t *fi, int op);
/**
* Allocate requested space. If this function returns success then
* subsequent writes to the specified range shall not fail due to the lack
* of free space on the file system storage media.
*
* Introduced in version 2.9
*
* Valid replies:
* fuse_reply_err
*
* @param req request handle
* @param ino the inode number
* @param offset starting point for allocated region
* @param length size of allocated region
* @param mode determines the operation to be performed on the given range,
* see fallocate(2)
*/
void (*fallocate)(fuse_req_t req,
const struct fuse_in_header *hdr);
/**
* Copy a range of data from one file to another
*
* Performs an optimized copy between two file descriptors without
* the
* additional cost of transferring data through the FUSE kernel
* module
* to user space (glibc) and then back into the FUSE filesystem
* again.
*
* In case this method is not implemented, glibc falls back to
* reading
* data from the source and writing to the destination. Effectively
* doing an inefficient copy of the data.
*
* If this request is answered with an error code of ENOSYS, this is
* treated as a permanent failure with error code EOPNOTSUPP,
* i.e. all
* future copy_file_range() requests will fail with EOPNOTSUPP
* without
* being send to the filesystem process.
*
* Valid replies:
* fuse_reply_write
* fuse_reply_err
*
* @param req request handle
* @param ino_in the inode number of the source file
* @param off_in starting point from were the data should be read
* @param fi_in file information of the source file
* @param ino_out the inode number of the destination file
* @param off_out starting point where the data should be written
* @param fi_out file information of the destination file
* @param len maximum size of the data to copy
* @param flags passed along with the copy_file_range() syscall
*/
void (*copy_file_range)(fuse_req_t req,
const struct fuse_in_header *hdr);
void (*setupmapping)(fuse_req_t req,
const struct fuse_in_header *hdr);
void (*removemapping)(fuse_req_t req,
const struct fuse_in_header *hdr);
void (*syncfs)(fuse_req_t req,
const struct fuse_in_header *hdr);
void (*tmpfile)(fuse_req_t req,
const struct fuse_in_header *hdr);
void (*fallocate)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*flock)(fuse_req_t req, uint64_t ino, fuse_file_info_t *fi, int op);
void (*flush)(fuse_req_t req, struct fuse_in_header *hdr);
void (*forget)(fuse_req_t req, struct fuse_in_header *hdr);
void (*forget_multi)(fuse_req_t req, struct fuse_in_header *hdr);
void (*fsync)(fuse_req_t req, struct fuse_in_header *hdr);
void (*fsyncdir)(fuse_req_t req, struct fuse_in_header *hdr);
void (*getattr)(fuse_req_t req, struct fuse_in_header *hdr);
void (*getlk)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*getxattr)(fuse_req_t req, struct fuse_in_header *hdr);
void (*init)(void *userdata, struct fuse_conn_info *conn);
void (*ioctl)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*link)(fuse_req_t req, struct fuse_in_header *hdr);
void (*listxattr)(fuse_req_t req, struct fuse_in_header *hdr);
void (*lookup)(fuse_req_t req, struct fuse_in_header *hdr);
void (*lseek)(fuse_req_t req, struct fuse_in_header *hdr);
void (*mkdir)(fuse_req_t req, struct fuse_in_header *hdr);
void (*mknod)(fuse_req_t req, struct fuse_in_header *hdr);
void (*open)(fuse_req_t req, struct fuse_in_header *hdr);
void (*opendir)(fuse_req_t req, struct fuse_in_header *hdr);
void (*poll)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*read)(fuse_req_t req, struct fuse_in_header *hdr);
void (*readdir)(fuse_req_t req, struct fuse_in_header *hdr);
void (*readdir_plus)(fuse_req_t req, struct fuse_in_header *hdr);
void (*readlink)(fuse_req_t req, struct fuse_in_header *hdr);
void (*release)(fuse_req_t req, struct fuse_in_header *hdr);
void (*releasedir)(fuse_req_t req, struct fuse_in_header *hdr);
void (*removemapping)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*removexattr)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*rename)(fuse_req_t req, struct fuse_in_header *hdr);
void (*rename2)(fuse_req_t req, struct fuse_in_header *hdr);
void (*retrieve_reply)(fuse_req_t req, void *cookie, uint64_t ino, off_t offset);
void (*rmdir)(fuse_req_t req, struct fuse_in_header *hdr);
void (*setattr)(fuse_req_t req, struct fuse_in_header *hdr);
void (*setlk)(fuse_req_t req, uint64_t ino, fuse_file_info_t *fi, struct flock *lock, int sleep);
void (*setupmapping)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*setxattr)(fuse_req_t req, struct fuse_in_header *hdr);
void (*statfs)(fuse_req_t req, struct fuse_in_header *hdr);
void (*statx)(fuse_req_t req, struct fuse_in_header *hdr);
void (*symlink)(fuse_req_t req, struct fuse_in_header *hdr);
void (*syncfs)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*tmpfile)(fuse_req_t req, const struct fuse_in_header *hdr);
void (*unlink)(fuse_req_t req, struct fuse_in_header *hdr);
void (*write)(fuse_req_t req, struct fuse_in_header *hdr);
};
/**
+25 -10
View File
@@ -1,22 +1,37 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
/*
ISC License
Copyright (c) 2024, Antonio SJ Musumeci <trapexit@spawn.link>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "cpu.hpp"
#include "ghc/filesystem.hpp"
#include "fmt/core.h"
#include <pthread.h>
#include <sched.h>
#include <fstream>
int
CPU::getaffinity(const pthread_t thread_id_,
cpu_set_t *cpuset_)
CPU::getaffinity(cpu_set_t *cpuset_)
{
const pid_t pid = 0;
CPU_ZERO(cpuset_);
return sched_getaffinity(thread_id_,
return sched_getaffinity(pid,
sizeof(cpu_set_t),
cpuset_);
}
@@ -70,7 +85,7 @@ CPU::count()
int rv;
cpu_set_t cpuset;
rv = CPU::getaffinity(0,&cpuset);
rv = CPU::getaffinity(&cpuset);
if(rv < 0)
return rv;
@@ -83,7 +98,7 @@ CPU::cpus()
cpu_set_t cpuset;
CPU::CPUVec cpuvec;
CPU::getaffinity(0,&cpuset);
CPU::getaffinity(&cpuset);
for(int i = 0; i < CPU_SETSIZE; i++)
{
@@ -102,7 +117,7 @@ CPU::cpu2core()
cpu_set_t cpuset;
CPU::CPU2CoreMap c2c;
CPU::getaffinity(0,&cpuset);
CPU::getaffinity(&cpuset);
for(int i = 0; i < CPU_SETSIZE; i++)
{
@@ -135,7 +150,7 @@ CPU::core2cpus()
cpu_set_t cpuset;
CPU::Core2CPUsMap c2c;
CPU::getaffinity(0,&cpuset);
CPU::getaffinity(&cpuset);
for(int i = 0; i < CPU_SETSIZE; i++)
{
+4 -5
View File
@@ -1,10 +1,9 @@
#pragma once
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <pthread.h>
#ifdef __FreeBSD__
#include <pthread_np.h>
#endif
#include <sched.h>
#include <set>
@@ -22,7 +21,7 @@ public:
public:
static int count();
static int getaffinity(const pthread_t thread_id, cpu_set_t *cpuset);
static int getaffinity(cpu_set_t *cpuset);
static int setaffinity(const pthread_t thread_id, cpu_set_t *cpuset);
static int setaffinity(const pthread_t thread_id, const int cpu);
static int setaffinity(const pthread_t thread_id, const std::set<int> cpus);
+9
View File
@@ -19,6 +19,11 @@
#ifndef CRC32B_H_INCLUDED
#define CRC32B_H_INCLUDED
#ifdef __cplusplus
extern "C"
{
#endif
typedef unsigned int crc32b_t;
crc32b_t crc32b_start(void);
@@ -29,4 +34,8 @@ crc32b_t crc32b_finish(const crc32b_t crc);
crc32b_t crc32b(const void *buf, crc32b_t len);
#ifdef __cplusplus
}
#endif
#endif
+164 -145
View File
@@ -16,7 +16,9 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "fuse_kernel.h"
@@ -158,9 +160,9 @@ open_flag_to_str(const uint64_t offset_)
static
const
char*
fuse_flag_to_str(const uint32_t offset_)
fuse_flag_to_str(const uint64_t offset_)
{
switch(1 << offset_)
switch(1ULL << offset_)
{
FUSE_INIT_FLAG_CASE(ASYNC_READ);
FUSE_INIT_FLAG_CASE(POSIX_LOCKS);
@@ -189,6 +191,16 @@ fuse_flag_to_str(const uint32_t offset_)
FUSE_INIT_FLAG_CASE(NO_OPENDIR_SUPPORT);
FUSE_INIT_FLAG_CASE(EXPLICIT_INVAL_DATA);
FUSE_INIT_FLAG_CASE(MAP_ALIGNMENT);
FUSE_INIT_FLAG_CASE(SUBMOUNTS);
FUSE_INIT_FLAG_CASE(HANDLE_KILLPRIV_V2);
FUSE_INIT_FLAG_CASE(SETXATTR_EXT);
FUSE_INIT_FLAG_CASE(INIT_EXT);
FUSE_INIT_FLAG_CASE(INIT_RESERVED);
FUSE_INIT_FLAG_CASE(SECURITY_CTX);
FUSE_INIT_FLAG_CASE(HAS_INODE_DAX);
FUSE_INIT_FLAG_CASE(CREATE_SUPP_GROUP);
FUSE_INIT_FLAG_CASE(HAS_EXPIRE_ONLY);
FUSE_INIT_FLAG_CASE(DIRECT_IO_ALLOW_MMAP);
}
return NULL;
@@ -200,8 +212,8 @@ static
void
debug_open_flags(const uint32_t flags_)
{
fprintf(stderr,"%s,",open_accmode_to_str(flags_));
for(int i = 0; i < (sizeof(flags_) * 8); i++)
fprintf(stderr,"%s, ",open_accmode_to_str(flags_));
for(size_t i = 0; i < (sizeof(flags_) * 8); i++)
{
const char *str;
@@ -212,7 +224,7 @@ debug_open_flags(const uint32_t flags_)
if(str == NULL)
continue;
fprintf(stderr,"%s,",str);
fprintf(stderr,"%s, ",str);
}
}
@@ -242,11 +254,11 @@ debug_fuse_open_out(const struct fuse_open_out *arg_)
{
fprintf(stderr,
"fuse_open_out:"
" fh=0x%"PRIx64";"
" fh=0x%" PRIx64 ";"
" open_flags=0x%X (",
arg_->fh,
arg_->open_flags);
for(int i = 0; i < (sizeof(arg_->open_flags) * 8); i++)
for(size_t i = 0; i < (sizeof(arg_->open_flags) * 8); i++)
{
const char *str;
@@ -266,7 +278,7 @@ static
void
debug_fuse_lookup(const void *arg_)
{
const char *name = arg_;
const char *name = (const char*)arg_;
fprintf(g_OUTPUT,
"fuse_lookup:"
@@ -280,12 +292,12 @@ static
void
debug_fuse_getattr_in(const void *arg_)
{
const struct fuse_getattr_in *arg = arg_;
const struct fuse_getattr_in *arg = (const fuse_getattr_in*)arg_;
fprintf(g_OUTPUT,
"fuse_getattr_in:"
" getattr_flags=0x%08X;"
" fh=0x%"PRIx64";\n",
" fh=0x%" PRIx64 ";\n",
arg->getattr_flags,
arg->fh);
}
@@ -294,12 +306,12 @@ static
void
debug_fuse_setattr_in(const void *arg_)
{
const struct fuse_setattr_in *arg = arg_;
const struct fuse_setattr_in *arg = (const fuse_setattr_in*)arg_;
fprintf(g_OUTPUT,
"fuse_setattr_in:"
" valid=%u;"
" fh=0x%"PRIx64";"
" fh=0x%" PRIx64 ";"
" size=%zu;"
" lock_owner=%zu;"
" atime=%zu;"
@@ -332,7 +344,7 @@ static
void
debug_fuse_access_in(const void *arg_)
{
const struct fuse_access_in *arg = arg_;
const struct fuse_access_in *arg = (const fuse_access_in*)arg_;
fprintf(g_OUTPUT,
"fuse_access_in:"
@@ -346,7 +358,7 @@ static
void
debug_fuse_mknod_in(const void *arg_)
{
const struct fuse_mknod_in *arg = arg_;
const struct fuse_mknod_in *arg = (const fuse_mknod_in*)arg_;
fprintf(g_OUTPUT,
"fuse_mknod_in:"
@@ -364,7 +376,7 @@ static
void
debug_fuse_mkdir_in(const void *arg_)
{
const struct fuse_mkdir_in *arg = arg_;
const struct fuse_mkdir_in *arg = (const fuse_mkdir_in*)arg_;
fprintf(g_OUTPUT,
"fuse_mkdir_in:"
@@ -382,7 +394,7 @@ static
void
debug_fuse_unlink(const void *arg_)
{
const char *name = arg_;
const char *name = (const char*)arg_;
fprintf(g_OUTPUT,
"fuse_unlink:"
@@ -396,7 +408,7 @@ static
void
debug_fuse_rmdir(const void *arg_)
{
const char *name = arg_;
const char *name = (const char*)arg_;
fprintf(g_OUTPUT,
"fuse_mkdir:"
@@ -413,7 +425,7 @@ debug_fuse_symlink(const void *arg_)
const char *name;
const char *linkname;
name = arg_;
name = (const char*)arg_;
linkname = (name + (strlen(name) + 1));
fprintf(g_OUTPUT,
@@ -432,7 +444,7 @@ debug_fuse_rename_in(const void *arg_)
{
const char *oldname;
const char *newname;
const struct fuse_rename_in *arg = arg_;
const struct fuse_rename_in *arg = (const fuse_rename_in*)arg_;
oldname = PARAM(arg);
newname = (oldname + strlen(oldname) + 1);
@@ -454,7 +466,7 @@ void
debug_fuse_link_in(const void *arg_)
{
const char *name;
const struct fuse_link_in *arg = arg_;
const struct fuse_link_in *arg = (const fuse_link_in*)arg_;
name = PARAM(arg);
@@ -473,7 +485,7 @@ void
debug_fuse_create_in(const void *arg_)
{
const char *name;
const struct fuse_create_in *arg = arg_;
const struct fuse_create_in *arg = (const fuse_create_in*)arg_;
name = PARAM(arg);
@@ -495,7 +507,7 @@ static
void
debug_fuse_open_in(const void *arg_)
{
const struct fuse_open_in *arg = arg_;
const struct fuse_open_in *arg = (const fuse_open_in*)arg_;
fprintf(g_OUTPUT,
"fuse_open_in:"
@@ -509,15 +521,15 @@ static
void
debug_fuse_read_in(const void *arg_)
{
const struct fuse_read_in *arg = arg_;
const struct fuse_read_in *arg = (const fuse_read_in*)arg_;
fprintf(g_OUTPUT,
"fuse_read_in:"
" fh=0x%"PRIx64";"
" fh=0x%" PRIx64 ";"
" offset=%zu;"
" size=%u;"
" read_flags=%X;"
" lock_owner=0x%"PRIx64";"
" lock_owner=0x%" PRIx64 ";"
" flags=0x%X ("
,
arg->fh,
@@ -534,14 +546,14 @@ static
void
debug_fuse_write_in(const void *arg_)
{
const struct fuse_write_in *arg = arg_;
const struct fuse_write_in *arg = (const fuse_write_in*)arg_;
fprintf(g_OUTPUT,
"fuse_write_in:"
" fh=0x%"PRIx64";"
" fh=0x%" PRIx64 ";"
" offset=%zu;"
" size=%u;"
" lock_owner=0x%"PRIx64";"
" lock_owner=0x%" PRIx64 ";"
" flags=0x%X ("
,
arg->fh,
@@ -553,7 +565,7 @@ debug_fuse_write_in(const void *arg_)
fprintf(g_OUTPUT,
"); write_flags=0x%X (",
arg->write_flags);
for(int i = 0; i < (sizeof(arg->write_flags) * 8); i++)
for(size_t i = 0; i < (sizeof(arg->write_flags) * 8); i++)
{
const char *str;
@@ -573,12 +585,12 @@ static
void
debug_fuse_flush_in(const void *arg_)
{
const struct fuse_flush_in *arg = arg_;
const struct fuse_flush_in *arg = (const fuse_flush_in*)arg_;
fprintf(g_OUTPUT,
"fuse_flush_in:"
" fh=0x%"PRIx64";"
" lock_owner=0x%"PRIx64";"
" fh=0x%" PRIx64 ";"
" lock_owner=0x%" PRIx64 ";"
"\n"
,
arg->fh,
@@ -589,13 +601,13 @@ static
void
debug_fuse_release_in(const void *arg_)
{
const struct fuse_release_in *arg = arg_;
const struct fuse_release_in *arg = (const fuse_release_in*)arg_;
fprintf(g_OUTPUT,
"fuse_release_in:"
" fh=0x%"PRIx64";"
" fh=0x%" PRIx64 ";"
" release_flags=0x%X;"
" lock_owner=0x%"PRIx64";"
" lock_owner=0x%" PRIx64 ";"
" flags=0x%X ("
,
arg->fh,
@@ -610,11 +622,11 @@ static
void
debug_fuse_fsync_in(const void *arg_)
{
const struct fuse_fsync_in *arg = arg_;
const struct fuse_fsync_in *arg = (const fuse_fsync_in*)arg_;
fprintf(g_OUTPUT,
"fuse_fsync_in:"
" fh=0x%"PRIx64";"
" fh=0x%" PRIx64 ";"
" fsync_flags=0x%X;"
"\n"
,
@@ -628,7 +640,7 @@ debug_fuse_setxattr_in(const void *arg_)
{
const char *name;
const char *value;
const struct fuse_setxattr_in *arg = arg_;
const struct fuse_setxattr_in *arg = (const fuse_setxattr_in*)arg_;
name = PARAM(arg);
value = (name + strlen(name) + 1);
@@ -652,7 +664,7 @@ void
debug_fuse_getxattr_in(const void *arg_)
{
const char *name;
const struct fuse_getxattr_in *arg = arg_;
const struct fuse_getxattr_in *arg = (const fuse_getxattr_in*)arg_;
name = PARAM(arg);
@@ -670,7 +682,7 @@ static
void
debug_fuse_listxattr(const void *arg_)
{
const struct fuse_getxattr_in *arg = arg_;
const struct fuse_getxattr_in *arg = (const fuse_getxattr_in*)arg_;
fprintf(g_OUTPUT,
"fuse_listxattr:"
@@ -684,7 +696,7 @@ static
void
debug_fuse_removexattr(const void *arg_)
{
const char *name = arg_;
const char *name = (const char*)arg_;
fprintf(g_OUTPUT,
"fuse_removexattr:"
@@ -698,11 +710,11 @@ static
void
debug_fuse_fallocate_in(const void *arg_)
{
const struct fuse_fallocate_in *arg = arg_;
const struct fuse_fallocate_in *arg = (const fuse_fallocate_in*)arg_;
fprintf(g_OUTPUT,
"fuse_fallocate_in:"
" fh=0x%"PRIx64";"
" fh=0x%" PRIx64 ";"
" offset=%zu;"
" length=%zu;"
" mode=%o;"
@@ -717,28 +729,31 @@ debug_fuse_fallocate_in(const void *arg_)
void
debug_fuse_init_in(const struct fuse_init_in *arg_)
{
uint64_t flags;
flags = (((uint64_t)arg_->flags) | ((uint64_t)arg_->flags2) << 32);
fprintf(g_OUTPUT,
"FUSE_INIT_IN: "
" major=%u;"
" minor=%u;"
" max_readahead=%u;"
" flags=0x%08X (",
" flags=0x%016lx (",
arg_->major,
arg_->minor,
arg_->max_readahead,
arg_->flags);
for(uint64_t i = 0; i < (sizeof(arg_->flags)*8); i++)
flags);
for(uint64_t i = 0; i < (sizeof(flags)*8); i++)
{
const char *str;
if(!(arg_->flags & (1ULL << i)))
if(!(flags & (1ULL << i)))
continue;
str = fuse_flag_to_str(i);
if(str == NULL)
continue;
fprintf(g_OUTPUT,"%s,",str);
fprintf(g_OUTPUT,"%s, ",str);
}
fprintf(g_OUTPUT,")\n");
}
@@ -748,37 +763,40 @@ debug_fuse_init_out(const uint64_t unique_,
const struct fuse_init_out *arg_,
const uint64_t argsize_)
{
uint64_t flags;
const struct fuse_init_out *arg = arg_;
flags = (((uint64_t)arg->flags) | ((uint64_t)arg->flags2) << 32);
fprintf(g_OUTPUT,
/* "unique=0x%016"PRIx64";" */
/* "unique=0x%016" PRIx64 ";" */
/* " opcode=RESPONSE;" */
/* " error=0 (Success);" */
/* " len=%"PRIu64"; || " */
/* " len=%" PRIu64 "; || " */
"FUSE_INIT_OUT:"
" major=%u;"
" minor=%u;"
" max_readahead=%u;"
" flags=0x%08X ("
" flags=0x%016lx ("
,
/* unique_, */
/* sizeof(struct fuse_out_header) + argsize_, */
arg->major,
arg->minor,
arg->max_readahead,
arg->flags);
flags);
for(uint64_t i = 0; i < (sizeof(arg->flags)*8); i++)
for(uint64_t i = 0; i < (sizeof(flags)*8); i++)
{
const char *str;
if(!(arg->flags & (1ULL << i)))
if(!(flags & (1ULL << i)))
continue;
str = fuse_flag_to_str(i);
if(str == NULL)
continue;
fprintf(g_OUTPUT,"%s,",str);
fprintf(g_OUTPUT,"%s, ",str);
}
fprintf(g_OUTPUT,
@@ -803,14 +821,14 @@ debug_fuse_attr(const struct fuse_attr *attr_)
{
fprintf(g_OUTPUT,
"attr:"
" ino=0x%016"PRIx64";"
" size=%"PRIu64";"
" blocks=%"PRIu64";"
" atime=%"PRIu64";"
" ino=0x%016" PRIx64 ";"
" size=%" PRIu64 ";"
" blocks=%" PRIu64 ";"
" atime=%" PRIu64 ";"
" atimensec=%u;"
" mtime=%"PRIu64";"
" mtime=%" PRIu64 ";"
" mtimensec=%u;"
" ctime=%"PRIu64";"
" ctime=%" PRIu64 ";"
" ctimesec=%u;"
" mode=%o;"
" nlink=%u;"
@@ -842,11 +860,11 @@ debug_fuse_entry(const struct fuse_entry_out *entry_)
{
fprintf(g_OUTPUT,
" fuse_entry_out:"
" nodeid=0x%016"PRIx64";"
" generation=0x%016"PRIx64";"
" entry_valid=%"PRIu64";"
" nodeid=0x%016" PRIx64 ";"
" generation=0x%016" PRIx64 ";"
" entry_valid=%" PRIu64 ";"
" entry_valid_nsec=%u;"
" attr_valid=%"PRIu64";"
" attr_valid=%" PRIu64 ";"
" attr_valid_nsec=%u;"
" ",
entry_->nodeid,
@@ -864,10 +882,10 @@ debug_fuse_entry_out(const uint64_t unique_,
const uint64_t argsize_)
{
fprintf(g_OUTPUT,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=RESPONSE;"
" error=0 (Success);"
" len=%"PRIu64"; || "
" len=%" PRIu64 "; || "
,
unique_,
sizeof(struct fuse_out_header) + argsize_);
@@ -881,10 +899,10 @@ debug_fuse_attr_out(const uint64_t unique_,
const uint64_t argsize_)
{
fprintf(g_OUTPUT,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=RESPONSE;"
" error=0 (Success);"
" len=%"PRIu64"; || "
" len=%" PRIu64 "; || "
"fuse_attr_out:"
" attr_valid=%zu;"
" attr_valid_nsec=%u;"
@@ -929,11 +947,11 @@ static
void
debug_fuse_interrupt_in(const void *arg_)
{
const struct fuse_interrupt_in *arg = arg_;
const struct fuse_interrupt_in *arg = (const fuse_interrupt_in*)arg_;
fprintf(g_OUTPUT,
"fuse_interrupt_in:"
" unique=0x%016"PRIx64";"
" unique=0x%016" PRIx64 ";"
"\n"
,
arg->unique);
@@ -946,53 +964,54 @@ opcode_name(enum fuse_opcode op_)
{
static const char *names[] =
{
[FUSE_LOOKUP] = "LOOKUP",
[FUSE_FORGET] = "FORGET",
[FUSE_GETATTR] = "GETATTR",
[FUSE_SETATTR] = "SETATTR",
[FUSE_READLINK] = "READLINK",
[FUSE_SYMLINK] = "SYMLINK",
[FUSE_MKNOD] = "MKNOD",
[FUSE_MKDIR] = "MKDIR",
[FUSE_UNLINK] = "UNLINK",
[FUSE_RMDIR] = "RMDIR",
[FUSE_RENAME] = "RENAME",
[FUSE_LINK] = "LINK",
[FUSE_OPEN] = "OPEN",
[FUSE_READ] = "READ",
[FUSE_WRITE] = "WRITE",
[FUSE_STATFS] = "STATFS",
[FUSE_RELEASE] = "RELEASE",
[FUSE_FSYNC] = "FSYNC",
[FUSE_SETXATTR] = "SETXATTR",
[FUSE_GETXATTR] = "GETXATTR",
[FUSE_LISTXATTR] = "LISTXATTR",
[FUSE_REMOVEXATTR] = "REMOVEXATTR",
[FUSE_FLUSH] = "FLUSH",
[FUSE_INIT] = "INIT",
[FUSE_OPENDIR] = "OPENDIR",
[FUSE_READDIR] = "READDIR",
[FUSE_RELEASEDIR] = "RELEASEDIR",
[FUSE_FSYNCDIR] = "FSYNCDIR",
[FUSE_GETLK] = "GETLK",
[FUSE_SETLK] = "SETLK",
[FUSE_SETLKW] = "SETLKW",
[FUSE_ACCESS] = "ACCESS",
[FUSE_CREATE] = "CREATE",
[FUSE_INTERRUPT] = "INTERRUPT",
[FUSE_BMAP] = "BMAP",
[FUSE_DESTROY] = "DESTROY",
[FUSE_IOCTL] = "IOCTL",
[FUSE_POLL] = "POLL",
[FUSE_NOTIFY_REPLY] = "NOTIFY_REPLY",
[FUSE_BATCH_FORGET] = "BATCH_FORGET",
[FUSE_FALLOCATE] = "FALLOCATE",
[FUSE_READDIRPLUS] = "READDIRPLUS",
[FUSE_RENAME2] = "RENAME2",
[FUSE_LSEEK] = "LSEEK",
[FUSE_COPY_FILE_RANGE] = "COPY_FILE_RANGE",
[FUSE_SETUPMAPPING] = "SETUPMAPPING",
[FUSE_REMOVEMAPPING] = "REMOVEMAPPING"
"INVALID",
"LOOKUP",
"FORGET",
"GETATTR",
"SETATTR",
"READLINK",
"SYMLINK",
"MKNOD",
"MKDIR",
"UNLINK",
"RMDIR",
"RENAME",
"LINK",
"OPEN",
"READ",
"WRITE",
"STATFS",
"RELEASE",
"FSYNC",
"SETXATTR",
"GETXATTR",
"LISTXATTR",
"REMOVEXATTR",
"FLUSH",
"INIT",
"OPENDIR",
"READDIR",
"RELEASEDIR",
"FSYNCDIR",
"GETLK",
"SETLK",
"SETLKW",
"ACCESS",
"CREATE",
"INTERRUPT",
"BMAP",
"DESTROY",
"IOCTL",
"POLL",
"NOTIFY_REPLY",
"BATCH_FORGET",
"FALLOCATE",
"READDIRPLUS",
"RENAME2",
"LSEEK",
"COPY_FILE_RANGE",
"SETUPMAPPING",
"REMOVEMAPPING"
};
if(op_ >= (sizeof(names) / sizeof(names[0])))
@@ -1007,14 +1026,14 @@ debug_fuse_in_header(const struct fuse_in_header *hdr_)
const void *arg = &hdr_[1];
fprintf(stderr,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=%s (%u);"
" nodeid=%zu;"
" uid=%u;"
" gid=%u;"
" pid=%u; || ",
hdr_->unique,
opcode_name(hdr_->opcode),
opcode_name((fuse_opcode)hdr_->opcode),
hdr_->opcode,
hdr_->nodeid,
hdr_->uid,
@@ -1027,7 +1046,7 @@ debug_fuse_in_header(const struct fuse_in_header *hdr_)
debug_fuse_lookup(arg);
break;
case FUSE_INIT:
debug_fuse_init_in(arg);
debug_fuse_init_in((const fuse_init_in*)arg);
break;
case FUSE_GETATTR:
debug_fuse_getattr_in(arg);
@@ -1120,10 +1139,10 @@ void
debug_fuse_out_header(const struct fuse_out_header *hdr_)
{
fprintf(g_OUTPUT,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=RESPONSE;"
" error=%d (%s);"
" len=%"PRIu64";"
" len=%" PRIu64 ";"
,
hdr_->unique,
hdr_->error,
@@ -1137,10 +1156,10 @@ debug_fuse_entry_open_out(const uint64_t unique_,
const struct fuse_open_out *open_)
{
fprintf(g_OUTPUT,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=RESPONSE;"
" error=0 (Success);"
" len=%"PRIu64"; || "
" len=%" PRIu64 "; || "
,
unique_,
sizeof(struct fuse_entry_out) + sizeof(struct fuse_open_out));
@@ -1153,10 +1172,10 @@ debug_fuse_readlink(const uint64_t unique_,
const char *linkname_)
{
fprintf(g_OUTPUT,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=RESPONSE;"
" error=0 (Success);"
" len=%"PRIu64"; || "
" len=%" PRIu64 "; || "
"readlink: linkname=%s"
"\n"
,
@@ -1170,10 +1189,10 @@ debug_fuse_write_out(const uint64_t unique_,
const struct fuse_write_out *arg_)
{
fprintf(g_OUTPUT,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=RESPONSE;"
" error=0 (Success);"
" len=%"PRIu64"; || "
" len=%" PRIu64 "; || "
" fuse_write_out:"
" size=%u"
"\n"
@@ -1188,16 +1207,16 @@ debug_fuse_statfs_out(const uint64_t unique_,
const struct fuse_statfs_out *arg_)
{
fprintf(g_OUTPUT,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=RESPONSE;"
" error=0 (Success);"
" len=%"PRIu64"; || "
" len=%" PRIu64 "; || "
" fuse_statfs_out:"
" blocks=%"PRIu64";"
" bfree=%"PRIu64";"
" bavail=%"PRIu64";"
" files=%"PRIu64";"
" ffree=%"PRIu64";"
" blocks=%" PRIu64 ";"
" bfree=%" PRIu64 ";"
" bavail=%" PRIu64 ";"
" files=%" PRIu64 ";"
" ffree=%" PRIu64 ";"
" bsize=%u;"
" namelen=%u;"
" frsize=%u;"
@@ -1220,10 +1239,10 @@ debug_fuse_getxattr_out(const uint64_t unique_,
const struct fuse_getxattr_out *arg_)
{
fprintf(g_OUTPUT,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=RESPONSE;"
" error=0 (Success);"
" len=%"PRIu64"; || "
" len=%" PRIu64 "; || "
" fuse_getxattr_out:"
" size=%u;"
"\n"
@@ -1239,13 +1258,13 @@ debug_fuse_lk_out(const uint64_t unique_,
const struct fuse_lk_out *arg_)
{
fprintf(g_OUTPUT,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=RESPONSE;"
" error=0 (Success);"
" len=%"PRIu64"; || "
" len=%" PRIu64 "; || "
" fuse_file_lock:"
" start=%"PRIu64";"
" end=%"PRIu64";"
" start=%" PRIu64 ";"
" end=%" PRIu64 ";"
" type=%u;"
" pid=%u;"
"\n"
@@ -1263,12 +1282,12 @@ debug_fuse_bmap_out(const uint64_t unique_,
const struct fuse_bmap_out *arg_)
{
fprintf(g_OUTPUT,
"unique=0x%016"PRIx64";"
"unique=0x%016" PRIx64 ";"
" opcode=RESPONSE;"
" error=0 (Success);"
" len=%"PRIu64"; || "
" len=%" PRIu64 "; || "
" fuse_bmap_out:"
" block=%"PRIu64";"
" block=%" PRIu64 ";"
"\n"
,
unique_,
+1 -1
View File
@@ -328,7 +328,7 @@ fmp_gc_slab(fmp_t *fmp_,
slab_idx_ = (slab_idx_ % kv_size(fmp_->slabs));
slab = kv_A(fmp_->slabs,slab_idx_);
slab = (char*)kv_A(fmp_->slabs,slab_idx_);
objs_per_slab = fmp_objs_per_slab(fmp_);
objs_in_slab = fmp_objs_in_slab(fmp_,slab);
+110 -101
View File
@@ -7,7 +7,9 @@
*/
/* For pthread_rwlock_t */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "crc32b.h"
#include "fuse_node.h"
@@ -25,6 +27,9 @@
#include "fuse_pollhandle.h"
#include "fuse_msgbuf.hpp"
#include <vector>
#include <string>
#include <assert.h>
#include <dlfcn.h>
#include <errno.h>
@@ -104,13 +109,6 @@ struct node_table
size_t split;
};
#define container_of(ptr,type,member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#define list_entry(ptr,type,member) \
container_of(ptr,type,member)
struct list_head
{
struct list_head *next;
@@ -218,32 +216,32 @@ fuse_hdr_arg(const struct fuse_in_header *hdr_)
static
void
list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
list_add(struct list_head *new_,
struct list_head *prev_,
struct list_head *next_)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
next_->prev = new_;
new_->next = next_;
new_->prev = prev_;
prev_->next = new_;
}
static
inline
void
list_add_head(struct list_head *new,
struct list_head *head)
list_add_head(struct list_head *new_,
struct list_head *head_)
{
list_add(new,head,head->next);
list_add(new_,head_,head_->next);
}
static
inline
void
list_add_tail(struct list_head *new,
struct list_head *head)
list_add_tail(struct list_head *new_,
struct list_head *head_)
{
list_add(new,head->prev,head);
list_add(new_,head_->prev,head_);
}
static
@@ -384,7 +382,7 @@ node_table_reduce(struct node_table *t)
newarray = realloc(t->array,sizeof(node_t*) * newsize);
if(newarray != NULL)
t->array = newarray;
t->array = (node_t**)newarray;
t->size = newsize;
t->split = t->size / 2;
@@ -450,7 +448,7 @@ node_table_resize(struct node_table *t)
if(newarray == NULL)
return -1;
t->array = newarray;
t->array = (node_t**)newarray;
memset(t->array + t->size,0,t->size * sizeof(node_t*));
t->size = newsize;
t->split = 0;
@@ -795,7 +793,7 @@ add_name(char **buf,
newbufsize *= 2;
}
newbuf = realloc(*buf,newbufsize);
newbuf = (char*)realloc(*buf,newbufsize);
if(newbuf == NULL)
return NULL;
@@ -857,7 +855,7 @@ try_get_path(struct fuse *f,
*path = NULL;
err = -ENOMEM;
buf = malloc(bufsize);
buf = (char*)malloc(bufsize);
if(buf == NULL)
goto out_err;
@@ -1562,7 +1560,7 @@ fuse_lib_lookup(fuse_req_t req,
node_t *dot = NULL;
struct fuse_entry_param e = {0};
name = fuse_hdr_arg(hdr_);
name = (const char*)fuse_hdr_arg(hdr_);
nodeid = hdr_->nodeid;
f = req_fuse_prepare(req);
@@ -1628,7 +1626,7 @@ fuse_lib_forget(fuse_req_t req,
struct fuse_forget_in *arg;
f = req_fuse(req);
arg = fuse_hdr_arg(hdr_);
arg = (fuse_forget_in*)fuse_hdr_arg(hdr_);
forget_node(f,hdr_->nodeid,arg->nlookup);
@@ -1645,8 +1643,8 @@ fuse_lib_forget_multi(fuse_req_t req,
struct fuse_forget_one *entry;
f = req_fuse(req);
arg = fuse_hdr_arg(hdr_);
entry = PARAM(arg);
arg = (fuse_batch_forget_in*)fuse_hdr_arg(hdr_);
entry = (fuse_forget_one*)PARAM(arg);
for(uint32_t i = 0; i < arg->count; i++)
{
@@ -1673,7 +1671,7 @@ fuse_lib_getattr(fuse_req_t req,
fuse_file_info_t ffi = {0};
const struct fuse_getattr_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_getattr_in*)fuse_hdr_arg(hdr_);
f = req_fuse_prepare(req);
if(arg->getattr_flags & FUSE_GETATTR_FH)
@@ -1735,7 +1733,7 @@ fuse_lib_setattr(fuse_req_t req,
fuse_file_info_t ffi = {0};
struct fuse_setattr_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_setattr_in*)fuse_hdr_arg(hdr_);
fi = NULL;
if(arg->valid & FATTR_FH)
@@ -1796,12 +1794,12 @@ fuse_lib_setattr(fuse_req_t req,
if(arg->valid & FATTR_ATIME_NOW)
tv[0].tv_nsec = UTIME_NOW;
else if(arg->valid & FATTR_ATIME)
tv[0] = (struct timespec){ arg->atime, arg->atimensec };
tv[0] = (struct timespec){ static_cast<time_t>(arg->atime), arg->atimensec };
if(arg->valid & FATTR_MTIME_NOW)
tv[1].tv_nsec = UTIME_NOW;
else if(arg->valid & FATTR_MTIME)
tv[1] = (struct timespec){ arg->mtime, arg->mtimensec };
tv[1] = (struct timespec){ static_cast<time_t>(arg->mtime), arg->mtimensec };
err = ((fi == NULL) ?
f->fs->op.utimens(path,tv) :
@@ -1853,7 +1851,7 @@ fuse_lib_access(fuse_req_t req,
struct fuse *f;
struct fuse_access_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_access_in*)fuse_hdr_arg(hdr_);
f = req_fuse_prepare(req);
@@ -1909,8 +1907,8 @@ fuse_lib_mknod(fuse_req_t req,
struct fuse_entry_param e;
struct fuse_mknod_in *arg;
arg = fuse_hdr_arg(hdr_);
name = PARAM(arg);
arg = (fuse_mknod_in*)fuse_hdr_arg(hdr_);
name = (const char*)PARAM(arg);
if(req->f->conn.proto_minor >= 12)
req->ctx.umask = arg->umask;
else
@@ -1961,8 +1959,8 @@ fuse_lib_mkdir(fuse_req_t req,
struct fuse_entry_param e;
struct fuse_mkdir_in *arg;
arg = fuse_hdr_arg(hdr_);
name = PARAM(arg);
arg = (fuse_mkdir_in*)fuse_hdr_arg(hdr_);
name = (const char*)PARAM(arg);
if(req->f->conn.proto_minor >= 12)
req->ctx.umask = arg->umask;
@@ -1991,7 +1989,7 @@ fuse_lib_unlink(fuse_req_t req,
const char *name;
node_t *wnode;
name = PARAM(hdr_);
name = (const char*)PARAM(hdr_);
f = req_fuse_prepare(req);
err = get_path_wrlock(f,hdr_->nodeid,name,&path,&wnode);
@@ -2024,7 +2022,7 @@ fuse_lib_rmdir(fuse_req_t req,
const char *name;
node_t *wnode;
name = PARAM(hdr_);
name = (const char*)PARAM(hdr_);
f = req_fuse_prepare(req);
@@ -2052,7 +2050,7 @@ fuse_lib_symlink(fuse_req_t req_,
const char *linkname;
struct fuse_entry_param e = {0};
name = fuse_hdr_arg(hdr_);
name = (const char*)fuse_hdr_arg(hdr_);
linkname = (name + strlen(name) + 1);
f = req_fuse_prepare(req_);
@@ -2084,8 +2082,8 @@ fuse_lib_rename(fuse_req_t req,
node_t *wnode2;
struct fuse_rename_in *arg;
arg = fuse_hdr_arg(hdr_);
oldname = PARAM(arg);
arg = (fuse_rename_in*)fuse_hdr_arg(hdr_);
oldname = (const char*)PARAM(arg);
newname = (oldname + strlen(oldname) + 1);
f = req_fuse_prepare(req);
@@ -2122,8 +2120,8 @@ fuse_lib_link(fuse_req_t req,
struct fuse_link_in *arg;
struct fuse_entry_param e = {0};
arg = fuse_hdr_arg(hdr_);
newname = PARAM(arg);
arg = (fuse_link_in*)fuse_hdr_arg(hdr_);
newname = (const char*)PARAM(arg);
f = req_fuse_prepare(req);
@@ -2186,8 +2184,8 @@ fuse_lib_create(fuse_req_t req,
struct fuse_entry_param e;
struct fuse_create_in *arg;
arg = fuse_hdr_arg(hdr_);
name = PARAM(arg);
arg = (fuse_create_in*)fuse_hdr_arg(hdr_);
name = (const char*)PARAM(arg);
ffi.flags = arg->flags;
@@ -2287,7 +2285,7 @@ fuse_lib_open(fuse_req_t req,
fuse_file_info_t ffi = {0};
struct fuse_open_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_open_in*)fuse_hdr_arg(hdr_);
ffi.flags = arg->flags;
@@ -2332,7 +2330,7 @@ fuse_lib_read(fuse_req_t req,
struct fuse_read_in *arg;
fuse_msgbuf_t *msgbuf;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_read_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh;
if(req->f->conn.proto_minor >= 9)
{
@@ -2365,7 +2363,7 @@ fuse_lib_write(fuse_req_t req,
fuse_file_info_t ffi = {0};
struct fuse_write_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_write_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh;
ffi.writepage = !!(arg->write_flags & 1);
if(req->f->conn.proto_minor < 9)
@@ -2376,7 +2374,7 @@ fuse_lib_write(fuse_req_t req,
{
ffi.flags = arg->flags;
ffi.lock_owner = arg->lock_owner;
data = PARAM(arg);
data = (char*)PARAM(arg);
}
f = req_fuse_prepare(req);
@@ -2400,7 +2398,7 @@ fuse_lib_fsync(fuse_req_t req,
struct fuse_fsync_in *arg;
fuse_file_info_t ffi = {0};
arg = fuse_hdr_arg(hdr_);
arg = (fuse_fsync_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh;
f = req_fuse_prepare(req);
@@ -2435,7 +2433,7 @@ fuse_lib_opendir(fuse_req_t req,
struct fuse *f;
struct fuse_open_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_open_in*)fuse_hdr_arg(hdr_);
llffi.flags = arg->flags;
f = req_fuse_prepare(req);
@@ -2522,7 +2520,7 @@ fuse_lib_readdir(fuse_req_t req_,
fuse_file_info_t llffi = {0};
struct fuse_read_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_read_in*)fuse_hdr_arg(hdr_);
size = arg->size;
llffi.fh = arg->fh;
@@ -2566,7 +2564,7 @@ fuse_lib_readdir_plus(fuse_req_t req_,
fuse_file_info_t llffi = {0};
struct fuse_read_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_read_in*)fuse_hdr_arg(hdr_);
size = arg->size;
llffi.fh = arg->fh;
@@ -2607,7 +2605,7 @@ fuse_lib_releasedir(fuse_req_t req_,
fuse_file_info_t llffi = {0};
struct fuse_release_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_release_in*)fuse_hdr_arg(hdr_);
llffi.fh = arg->fh;
llffi.flags = arg->flags;
@@ -2636,7 +2634,7 @@ fuse_lib_fsyncdir(fuse_req_t req,
fuse_file_info_t llffi = {0};
struct fuse_fsync_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_fsync_in*)fuse_hdr_arg(hdr_);
llffi.fh = arg->fh;
f = req_fuse_prepare(req);
@@ -2688,9 +2686,9 @@ fuse_lib_setxattr(fuse_req_t req,
struct fuse *f;
struct fuse_setxattr_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_setxattr_in*)fuse_hdr_arg(hdr_);
if((req->f->conn.capable & FUSE_SETXATTR_EXT) && (req->f->conn.want & FUSE_SETXATTR_EXT))
name = PARAM(arg);
name = (const char*)PARAM(arg);
else
name = (((char*)arg) + FUSE_COMPAT_SETXATTR_IN_SIZE);
@@ -2741,8 +2739,8 @@ fuse_lib_getxattr(fuse_req_t req,
const char* name;
struct fuse_getxattr_in *arg;
arg = fuse_hdr_arg(hdr_);
name = PARAM(arg);
arg = (fuse_getxattr_in*)fuse_hdr_arg(hdr_);
name = (const char*)PARAM(arg);
f = req_fuse_prepare(req);
@@ -2802,7 +2800,7 @@ fuse_lib_listxattr(fuse_req_t req,
struct fuse *f;
struct fuse_getxattr_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_getxattr_in*)fuse_hdr_arg(hdr_);
f = req_fuse_prepare(req);
@@ -2842,7 +2840,7 @@ fuse_lib_removexattr(fuse_req_t req,
const char *name;
struct fuse *f;
name = fuse_hdr_arg(hdr_);
name = (const char*)fuse_hdr_arg(hdr_);
f = req_fuse_prepare(req);
@@ -2867,7 +2865,7 @@ fuse_lib_copy_file_range(fuse_req_t req_,
fuse_file_info_t ffi_out = {0};
const struct fuse_copy_file_range_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_copy_file_range_in*)fuse_hdr_arg(hdr_);
ffi_in.fh = arg->fh_in;
ffi_out.fh = arg->fh_out;
@@ -2927,8 +2925,8 @@ fuse_lib_tmpfile(fuse_req_t req_,
struct fuse_entry_param e;
struct fuse_create_in *arg;
arg = fuse_hdr_arg(hdr_);
name = PARAM(arg);
arg = (fuse_create_in*)fuse_hdr_arg(hdr_);
name = (const char*)PARAM(arg);
ffi.flags = arg->flags;
@@ -3026,8 +3024,8 @@ locks_insert(node_t *node,
if(lock->type != F_UNLCK || lock->start != 0 || lock->end != OFFSET_MAX)
{
newl1 = malloc(sizeof(lock_t));
newl2 = malloc(sizeof(lock_t));
newl1 = (lock_t*)malloc(sizeof(lock_t));
newl2 = (lock_t*)malloc(sizeof(lock_t));
if(!newl1 || !newl2)
{
@@ -3055,7 +3053,7 @@ locks_insert(node_t *node,
lock->start = l->start;
if(lock->end < l->end)
lock->end = l->end;
goto delete;
goto delete_lock;
}
else
{
@@ -3064,7 +3062,7 @@ locks_insert(node_t *node,
if(lock->end < l->start)
break;
if(lock->start <= l->start && l->end <= lock->end)
goto delete;
goto delete_lock;
if(l->end <= lock->end)
{
l->end = lock->start - 1;
@@ -3085,7 +3083,7 @@ locks_insert(node_t *node,
lp = &l->next;
continue;
delete:
delete_lock:
delete_lock(lp);
}
if(lock->type != F_UNLCK)
@@ -3168,7 +3166,7 @@ fuse_lib_release(fuse_req_t req,
fuse_file_info_t ffi = {0};
struct fuse_release_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_release_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh;
ffi.flags = arg->flags;
if(req->f->conn.proto_minor >= 8)
@@ -3206,7 +3204,7 @@ fuse_lib_flush(fuse_req_t req,
fuse_file_info_t ffi = {0};
struct fuse_flush_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_flush_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh;
ffi.flush = 1;
@@ -3265,7 +3263,7 @@ fuse_lib_getlk(fuse_req_t req,
fuse_file_info_t ffi = {0};
const struct fuse_lk_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_lk_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh;
ffi.lock_owner = arg->owner;
@@ -3341,7 +3339,7 @@ fuse_lib_bmap(fuse_req_t req,
uint64_t block;
const struct fuse_bmap_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_bmap_in*)fuse_hdr_arg(hdr_);
block = arg->block;
f = req_fuse_prepare(req);
@@ -3373,7 +3371,7 @@ fuse_lib_ioctl(fuse_req_t req,
uint32_t out_size;
const struct fuse_ioctl_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_ioctl_in*)fuse_hdr_arg(hdr_);
if((arg->flags & FUSE_IOCTL_DIR) && !(req->f->conn.want & FUSE_CAP_IOCTL_DIR))
{
fuse_reply_err(req,ENOTTY);
@@ -3403,7 +3401,7 @@ fuse_lib_ioctl(fuse_req_t req,
if(out_size)
{
err = -ENOMEM;
out_buf = malloc(out_size);
out_buf = (char*)malloc(out_size);
if(!out_buf)
goto err;
}
@@ -3441,7 +3439,7 @@ fuse_lib_poll(fuse_req_t req,
fuse_pollhandle_t *ph = NULL;
const struct fuse_poll_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_poll_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh;
if(arg->flags & FUSE_POLL_SCHEDULE_NOTIFY)
@@ -3476,7 +3474,7 @@ fuse_lib_fallocate(fuse_req_t req,
fuse_file_info_t ffi = {0};
const struct fuse_fallocate_in *arg;
arg = fuse_hdr_arg(hdr_);
arg = (fuse_fallocate_in*)fuse_hdr_arg(hdr_);
ffi.fh = arg->fh;
f = req_fuse_prepare(req);
@@ -3494,8 +3492,8 @@ int
remembered_node_cmp(const void *a_,
const void *b_)
{
const remembered_node_t *a = a_;
const remembered_node_t *b = b_;
const remembered_node_t *a = (const remembered_node_t*)a_;
const remembered_node_t *b = (const remembered_node_t*)b_;
return (a->time - b->time);
}
@@ -3830,21 +3828,21 @@ metrics_log_nodes_info(struct fuse *f_,
snprintf(buf,sizeof(buf),
"time: %s\n"
"sizeof(node): %"PRIu64"\n"
"node id_table size: %"PRIu64"\n"
"node id_table usage: %"PRIu64"\n"
"node id_table total allocated memory: %"PRIu64"\n"
"node name_table size: %"PRIu64"\n"
"node name_table usage: %"PRIu64"\n"
"node name_table total allocated memory: %"PRIu64"\n"
"node memory pool slab count: %"PRIu64"\n"
"sizeof(node): %" PRIu64 "\n"
"node id_table size: %" PRIu64 "\n"
"node id_table usage: %" PRIu64 "\n"
"node id_table total allocated memory: %" PRIu64 "\n"
"node name_table size: %" PRIu64 "\n"
"node name_table usage: %" PRIu64 "\n"
"node name_table total allocated memory: %" PRIu64 "\n"
"node memory pool slab count: %" PRIu64 "\n"
"node memory pool usage ratio: %f\n"
"node memory pool avail objs: %"PRIu64"\n"
"node memory pool total allocated memory: %"PRIu64"\n"
"msgbuf bufsize: %"PRIu64"\n"
"msgbuf allocation count: %"PRIu64"\n"
"msgbuf available count: %"PRIu64"\n"
"msgbuf total allocated memory: %"PRIu64"\n"
"node memory pool avail objs: %" PRIu64 "\n"
"node memory pool total allocated memory: %" PRIu64 "\n"
"msgbuf bufsize: %" PRIu64 "\n"
"msgbuf allocation count: %" PRIu64 "\n"
"msgbuf available count: %" PRIu64 "\n"
"msgbuf total allocated memory: %" PRIu64 "\n"
"\n"
,
time_str,
@@ -3907,11 +3905,10 @@ void
fuse_invalidate_all_nodes()
{
struct fuse *f = fuse_get_fuse_obj();
syslog(LOG_INFO,"invalidating file entries");
std::vector<std::string> names;
pthread_mutex_lock(&f->lock);
for(int i = 0; i < f->id_table.size; i++)
for(size_t i = 0; i < f->id_table.size; i++)
{
node_t *node;
@@ -3919,16 +3916,28 @@ fuse_invalidate_all_nodes()
{
if(node->nodeid == FUSE_ROOT_ID)
continue;
if(node->name == NULL)
continue;
if(node->parent == NULL)
continue;
if(node->parent->nodeid != FUSE_ROOT_ID)
continue;
fuse_lowlevel_notify_inval_entry(f->se->ch,
node->parent->nodeid,
node->name,
strlen(node->name));
names.emplace_back(node->name);
}
}
pthread_mutex_unlock(&f->lock);
syslog(LOG_INFO,
"invalidating %ld file entries",
names.size());
for(auto &name : names)
{
fuse_lowlevel_notify_inval_entry(f->se->ch,
FUSE_ROOT_ID,
name.c_str(),
name.size());
}
}
void
@@ -6,12 +6,14 @@
See the file COPYING.LIB
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "lfmp.h"
#include "config.h"
#include "debug.h"
#include "debug.hpp"
#include "fuse_i.h"
#include "fuse_kernel.h"
#include "fuse_opt.h"
@@ -41,7 +43,7 @@
#define OFFSET_MAX 0x7fffffffffffffffLL
#define container_of(ptr, type, member) ({ \
const typeof( ((type*)0)->member ) *__mptr = (ptr); \
const decltype( ((type*)0)->member ) *__mptr = (ptr); \
(type *)( (char*)__mptr - offsetof(type,member) );})
static size_t pagesize;
@@ -135,7 +137,7 @@ fuse_send_msg(struct fuse_ll *f,
int count)
{
int rv;
struct fuse_out_header *out = iov[0].iov_base;
struct fuse_out_header *out = (fuse_out_header*)iov[0].iov_base;
out->len = iov_length(iov, count);
@@ -410,7 +412,7 @@ fuse_send_data_iov_fallback(struct fuse_ll *f,
return -ENOMEM;
mem_buf.buf[0].mem = msgbuf->mem;
res = fuse_buf_copy(&mem_buf, buf, 0);
res = fuse_buf_copy(&mem_buf, buf, (fuse_buf_copy_flags)0);
if(res < 0)
{
msgbuf_free(msgbuf);
@@ -550,7 +552,7 @@ fuse_ioctl_iovec_copy(const struct iovec *iov,
struct fuse_ioctl_iovec *fiov;
size_t i;
fiov = malloc(sizeof(fiov[0]) * count);
fiov = (fuse_ioctl_iovec*)malloc(sizeof(fiov[0]) * count);
if(!fiov)
return NULL;
@@ -683,7 +685,7 @@ fuse_reply_ioctl_iov(fuse_req_t req,
struct fuse_ioctl_out arg = {0};
int res;
padded_iov = malloc((count + 2) * sizeof(struct iovec));
padded_iov = (iovec*)malloc((count + 2) * sizeof(struct iovec));
if(padded_iov == NULL)
return fuse_reply_err(req, ENOMEM);
@@ -896,8 +898,8 @@ do_readdir(fuse_req_t req,
static
void
do_readdir_plus(fuse_req_t req_,
struct fuse_in_header *hdr_)
do_readdirplus(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
req_->f->op.readdir_plus(req_,hdr_);
}
@@ -1097,6 +1099,11 @@ do_init(fuse_req_t req,
struct fuse_init_in *arg = (struct fuse_init_in *) &hdr_[1];
struct fuse_ll *f = req->f;
size_t bufsize = fuse_chan_bufsize(req->ch);
uint64_t inargflags;
uint64_t outargflags;
inargflags = 0;
outargflags = 0;
if(f->debug)
debug_fuse_init_in(arg);
@@ -1127,40 +1134,49 @@ do_init(fuse_req_t req,
if(arg->minor >= 6)
{
inargflags = arg->flags;
if(inargflags & FUSE_INIT_EXT)
inargflags |= (((uint64_t)arg->flags2) << 32);
if(arg->max_readahead < f->conn.max_readahead)
f->conn.max_readahead = arg->max_readahead;
if(arg->flags & FUSE_ASYNC_READ)
if(inargflags & FUSE_ASYNC_READ)
f->conn.capable |= FUSE_CAP_ASYNC_READ;
if(arg->flags & FUSE_POSIX_LOCKS)
if(inargflags & FUSE_POSIX_LOCKS)
f->conn.capable |= FUSE_CAP_POSIX_LOCKS;
if(arg->flags & FUSE_ATOMIC_O_TRUNC)
if(inargflags & FUSE_ATOMIC_O_TRUNC)
f->conn.capable |= FUSE_CAP_ATOMIC_O_TRUNC;
if(arg->flags & FUSE_EXPORT_SUPPORT)
if(inargflags & FUSE_EXPORT_SUPPORT)
f->conn.capable |= FUSE_CAP_EXPORT_SUPPORT;
if(arg->flags & FUSE_BIG_WRITES)
if(inargflags & FUSE_BIG_WRITES)
f->conn.capable |= FUSE_CAP_BIG_WRITES;
if(arg->flags & FUSE_DONT_MASK)
if(inargflags & FUSE_DONT_MASK)
f->conn.capable |= FUSE_CAP_DONT_MASK;
if(arg->flags & FUSE_FLOCK_LOCKS)
if(inargflags & FUSE_FLOCK_LOCKS)
f->conn.capable |= FUSE_CAP_FLOCK_LOCKS;
if(arg->flags & FUSE_POSIX_ACL)
if(inargflags & FUSE_POSIX_ACL)
f->conn.capable |= FUSE_CAP_POSIX_ACL;
if(arg->flags & FUSE_CACHE_SYMLINKS)
if(inargflags & FUSE_CACHE_SYMLINKS)
f->conn.capable |= FUSE_CAP_CACHE_SYMLINKS;
if(arg->flags & FUSE_ASYNC_DIO)
if(inargflags & FUSE_ASYNC_DIO)
f->conn.capable |= FUSE_CAP_ASYNC_DIO;
if(arg->flags & FUSE_PARALLEL_DIROPS)
if(inargflags & FUSE_PARALLEL_DIROPS)
f->conn.capable |= FUSE_CAP_PARALLEL_DIROPS;
if(arg->flags & FUSE_MAX_PAGES)
if(inargflags & FUSE_MAX_PAGES)
f->conn.capable |= FUSE_CAP_MAX_PAGES;
if(arg->flags & FUSE_WRITEBACK_CACHE)
if(inargflags & FUSE_WRITEBACK_CACHE)
f->conn.capable |= FUSE_CAP_WRITEBACK_CACHE;
if(arg->flags & FUSE_DO_READDIRPLUS)
if(inargflags & FUSE_DO_READDIRPLUS)
f->conn.capable |= FUSE_CAP_READDIR_PLUS;
if(arg->flags & FUSE_READDIRPLUS_AUTO)
if(inargflags & FUSE_READDIRPLUS_AUTO)
f->conn.capable |= FUSE_CAP_READDIR_PLUS_AUTO;
if(arg->flags & FUSE_SETXATTR_EXT)
if(inargflags & FUSE_SETXATTR_EXT)
f->conn.capable |= FUSE_CAP_SETXATTR_EXT;
if(inargflags & FUSE_DIRECT_IO_ALLOW_MMAP)
f->conn.capable |= FUSE_CAP_DIRECT_IO_ALLOW_MMAP;
if(inargflags & FUSE_CREATE_SUPP_GROUP)
f->conn.capable |= FUSE_CAP_CREATE_SUPP_GROUP;
}
else
{
@@ -1191,44 +1207,57 @@ do_init(fuse_req_t req,
if(f->op.init)
f->op.init(f->userdata, &f->conn);
if((arg->flags & FUSE_MAX_PAGES) && (f->conn.want & FUSE_CAP_MAX_PAGES))
outargflags = outarg.flags;
if((inargflags & FUSE_MAX_PAGES) && (f->conn.want & FUSE_CAP_MAX_PAGES))
{
outarg.flags |= FUSE_MAX_PAGES;
outargflags |= FUSE_MAX_PAGES;
outarg.max_pages = f->conn.max_pages;
msgbuf_set_bufsize(outarg.max_pages + 1);
}
if(f->conn.want & FUSE_CAP_ASYNC_READ)
outarg.flags |= FUSE_ASYNC_READ;
outargflags |= FUSE_ASYNC_READ;
if(f->conn.want & FUSE_CAP_POSIX_LOCKS)
outarg.flags |= FUSE_POSIX_LOCKS;
outargflags |= FUSE_POSIX_LOCKS;
if(f->conn.want & FUSE_CAP_ATOMIC_O_TRUNC)
outarg.flags |= FUSE_ATOMIC_O_TRUNC;
outargflags |= FUSE_ATOMIC_O_TRUNC;
if(f->conn.want & FUSE_CAP_EXPORT_SUPPORT)
outarg.flags |= FUSE_EXPORT_SUPPORT;
outargflags |= FUSE_EXPORT_SUPPORT;
if(f->conn.want & FUSE_CAP_BIG_WRITES)
outarg.flags |= FUSE_BIG_WRITES;
outargflags |= FUSE_BIG_WRITES;
if(f->conn.want & FUSE_CAP_DONT_MASK)
outarg.flags |= FUSE_DONT_MASK;
outargflags |= FUSE_DONT_MASK;
if(f->conn.want & FUSE_CAP_FLOCK_LOCKS)
outarg.flags |= FUSE_FLOCK_LOCKS;
outargflags |= FUSE_FLOCK_LOCKS;
if(f->conn.want & FUSE_CAP_POSIX_ACL)
outarg.flags |= FUSE_POSIX_ACL;
outargflags |= FUSE_POSIX_ACL;
if(f->conn.want & FUSE_CAP_CACHE_SYMLINKS)
outarg.flags |= FUSE_CACHE_SYMLINKS;
outargflags |= FUSE_CACHE_SYMLINKS;
if(f->conn.want & FUSE_CAP_ASYNC_DIO)
outarg.flags |= FUSE_ASYNC_DIO;
outargflags |= FUSE_ASYNC_DIO;
if(f->conn.want & FUSE_CAP_PARALLEL_DIROPS)
outarg.flags |= FUSE_PARALLEL_DIROPS;
outargflags |= FUSE_PARALLEL_DIROPS;
if(f->conn.want & FUSE_CAP_WRITEBACK_CACHE)
outarg.flags |= FUSE_WRITEBACK_CACHE;
outargflags |= FUSE_WRITEBACK_CACHE;
if(f->conn.want & FUSE_CAP_READDIR_PLUS)
outarg.flags |= FUSE_DO_READDIRPLUS;
outargflags |= FUSE_DO_READDIRPLUS;
if(f->conn.want & FUSE_CAP_READDIR_PLUS_AUTO)
outarg.flags |= FUSE_READDIRPLUS_AUTO;
outargflags |= FUSE_READDIRPLUS_AUTO;
if(f->conn.want & FUSE_CAP_SETXATTR_EXT)
outarg.flags |= FUSE_SETXATTR_EXT;
outargflags |= FUSE_SETXATTR_EXT;
if(f->conn.want & FUSE_CAP_CREATE_SUPP_GROUP)
outargflags |= FUSE_CREATE_SUPP_GROUP;
if(f->conn.want & FUSE_CAP_DIRECT_IO_ALLOW_MMAP)
outargflags |= FUSE_DIRECT_IO_ALLOW_MMAP;
if(inargflags & FUSE_INIT_EXT)
{
outargflags |= FUSE_INIT_EXT;
outarg.flags2 = (outargflags >> 32);
}
outarg.flags = outargflags;
outarg.max_readahead = f->conn.max_readahead;
outarg.max_write = f->conn.max_write;
@@ -1247,6 +1276,9 @@ do_init(fuse_req_t req,
outarg.congestion_threshold = f->conn.congestion_threshold;
}
if(f->conn.proto_minor >= 23)
outarg.time_gran = 1;
size_t outargsize;
if(arg->minor < 5)
outargsize = FUSE_COMPAT_INIT_OUT_SIZE;
@@ -1342,7 +1374,6 @@ void
do_setupmapping(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
printf("setupmapping\n");
req_->f->op.setupmapping(req_,hdr_);
}
@@ -1351,7 +1382,6 @@ void
do_removemapping(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
printf("removemapping\n");
req_->f->op.removemapping(req_,hdr_);
}
@@ -1360,7 +1390,6 @@ void
do_syncfs(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
printf("syncfs\n");
req_->f->op.syncfs(req_,hdr_);
}
@@ -1369,10 +1398,33 @@ void
do_tmpfile(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
printf("tmpfile\n");
req_->f->op.tmpfile(req_,hdr_);
}
static
void
do_statx(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
req_->f->op.statx(req_,hdr_);
}
static
void
do_rename2(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
req_->f->op.rename2(req_,hdr_);
}
static
void
do_lseek(fuse_req_t req_,
struct fuse_in_header *hdr_)
{
req_->f->op.lseek(req_,hdr_);
}
static
int
send_notify_iov(struct fuse_ll *f,
@@ -1594,7 +1646,7 @@ fuse_lowlevel_notify_retrieve(struct fuse_chan *ch,
if(f->conn.proto_minor < 15)
return -ENOSYS;
rreq = malloc(sizeof(*rreq));
rreq = (fuse_retrieve_req*)malloc(sizeof(*rreq));
if(rreq == NULL)
return -ENOMEM;
@@ -1638,61 +1690,69 @@ fuse_req_ctx(fuse_req_t req)
return &req->ctx;
}
static struct {
void (*func)(fuse_req_t, struct fuse_in_header *);
const char *name;
} fuse_ll_ops[] =
#define FUSE_OPCODE_LEN (FUSE_STATX + 1)
typedef void (*fuse_ll_func)(fuse_req_t, struct fuse_in_header *);
const
fuse_ll_func
fuse_ll_funcs[FUSE_OPCODE_LEN] =
{
[FUSE_LOOKUP] = { do_lookup, "LOOKUP" },
[FUSE_FORGET] = { do_forget, "FORGET" },
[FUSE_GETATTR] = { do_getattr, "GETATTR" },
[FUSE_SETATTR] = { do_setattr, "SETATTR" },
[FUSE_READLINK] = { do_readlink, "READLINK" },
[FUSE_SYMLINK] = { do_symlink, "SYMLINK" },
[FUSE_MKNOD] = { do_mknod, "MKNOD" },
[FUSE_MKDIR] = { do_mkdir, "MKDIR" },
[FUSE_UNLINK] = { do_unlink, "UNLINK" },
[FUSE_RMDIR] = { do_rmdir, "RMDIR" },
[FUSE_RENAME] = { do_rename, "RENAME" },
[FUSE_LINK] = { do_link, "LINK" },
[FUSE_OPEN] = { do_open, "OPEN" },
[FUSE_READ] = { do_read, "READ" },
[FUSE_WRITE] = { do_write, "WRITE" },
[FUSE_STATFS] = { do_statfs, "STATFS" },
[FUSE_RELEASE] = { do_release, "RELEASE" },
[FUSE_FSYNC] = { do_fsync, "FSYNC" },
[FUSE_SETXATTR] = { do_setxattr, "SETXATTR" },
[FUSE_GETXATTR] = { do_getxattr, "GETXATTR" },
[FUSE_LISTXATTR] = { do_listxattr, "LISTXATTR" },
[FUSE_REMOVEXATTR] = { do_removexattr, "REMOVEXATTR" },
[FUSE_FLUSH] = { do_flush, "FLUSH" },
[FUSE_INIT] = { do_init, "INIT" },
[FUSE_OPENDIR] = { do_opendir, "OPENDIR" },
[FUSE_READDIR] = { do_readdir, "READDIR" },
[FUSE_READDIRPLUS] = { do_readdir_plus, "READDIR_PLUS" },
[FUSE_RELEASEDIR] = { do_releasedir, "RELEASEDIR" },
[FUSE_FSYNCDIR] = { do_fsyncdir, "FSYNCDIR" },
[FUSE_GETLK] = { do_getlk, "GETLK" },
[FUSE_SETLK] = { do_setlk, "SETLK" },
[FUSE_SETLKW] = { do_setlkw, "SETLKW" },
[FUSE_ACCESS] = { do_access, "ACCESS" },
[FUSE_CREATE] = { do_create, "CREATE" },
[FUSE_INTERRUPT] = { do_interrupt, "INTERRUPT" },
[FUSE_BMAP] = { do_bmap, "BMAP" },
[FUSE_IOCTL] = { do_ioctl, "IOCTL" },
[FUSE_POLL] = { do_poll, "POLL" },
[FUSE_FALLOCATE] = { do_fallocate, "FALLOCATE" },
[FUSE_DESTROY] = { do_destroy, "DESTROY" },
[FUSE_NOTIFY_REPLY] = { do_notify_reply, "NOTIFY_REPLY" },
[FUSE_BATCH_FORGET] = { do_batch_forget, "BATCH_FORGET" },
[FUSE_COPY_FILE_RANGE] = { do_copy_file_range, "COPY_FILE_RANGE" },
[FUSE_SETUPMAPPING] = { do_setupmapping, "SETUPMAPPING" },
[FUSE_REMOVEMAPPING] = { do_removemapping, "REMOVEMAPPING" },
[FUSE_SYNCFS] = { do_syncfs, "SYNCFS" },
[FUSE_TMPFILE] = { do_tmpfile, "TMPFILE" }
NULL,
do_lookup,
do_forget,
do_getattr,
do_setattr,
do_readlink,
do_symlink,
NULL,
do_mknod,
do_mkdir,
do_unlink,
do_rmdir,
do_rename,
do_link,
do_open,
do_read,
do_write,
do_statfs,
do_release,
NULL,
do_fsync,
do_setxattr,
do_getxattr,
do_listxattr,
do_removexattr,
do_flush,
do_init,
do_opendir,
do_readdir,
do_releasedir,
do_fsyncdir,
do_getlk,
do_setlk,
do_setlkw,
do_access,
do_create,
do_interrupt,
do_bmap,
do_destroy,
do_ioctl,
do_poll,
do_notify_reply,
do_batch_forget,
do_fallocate,
do_readdirplus,
do_rename2,
do_lseek,
do_copy_file_range,
do_setupmapping,
do_removemapping,
do_syncfs,
do_tmpfile,
do_statx
};
#define FUSE_MAXOP (sizeof(fuse_ll_ops) / sizeof(fuse_ll_ops[0]))
#define FUSE_MAXOPS (sizeof(fuse_ll_funcs) / sizeof(fuse_ll_funcs[0]))
enum {
KEY_HELP,
@@ -1786,7 +1846,7 @@ fuse_ll_destroy(void *data)
f->op.destroy(f->userdata);
}
llp = pthread_getspecific(f->pipe_key);
llp = (fuse_ll_pipe*)pthread_getspecific(f->pipe_key);
if(llp != NULL)
fuse_ll_pipe_free(llp);
pthread_key_delete(f->pipe_key);
@@ -1800,7 +1860,7 @@ static
void
fuse_ll_pipe_destructor(void *data)
{
struct fuse_ll_pipe *llp = data;
struct fuse_ll_pipe *llp = (fuse_ll_pipe*)data;
fuse_ll_pipe_free(llp);
}
@@ -1842,7 +1902,7 @@ fuse_ll_buf_receive_read(struct fuse_session *se_,
if(rv == -1)
return -errno;
if(rv < sizeof(struct fuse_in_header))
if(rv < (int)sizeof(struct fuse_in_header))
{
fprintf(stderr, "short read from fuse device\n");
return -EIO;
@@ -1862,8 +1922,6 @@ fuse_ll_buf_process_read(struct fuse_session *se_,
in = (struct fuse_in_header*)msgbuf_->mem;
// printf("%d\n",in->opcode);
req = fuse_ll_alloc_req(se_->f);
if(req == NULL)
return fuse_send_enomem(se_->f,se_->ch,in->unique);
@@ -1875,12 +1933,12 @@ fuse_ll_buf_process_read(struct fuse_session *se_,
req->ch = se_->ch;
err = ENOSYS;
if(in->opcode >= FUSE_MAXOP)
if(in->opcode >= FUSE_MAXOPS)
goto reply_err;
if(fuse_ll_ops[in->opcode].func == NULL)
if(fuse_ll_funcs[in->opcode] == NULL)
goto reply_err;
fuse_ll_ops[in->opcode].func(req, in);
fuse_ll_funcs[in->opcode](req, in);
return;
@@ -1913,12 +1971,12 @@ fuse_ll_buf_process_read_init(struct fuse_session *se_,
err = EIO;
if(in->opcode != FUSE_INIT)
goto reply_err;
if(fuse_ll_ops[in->opcode].func == NULL)
if(fuse_ll_funcs[FUSE_INIT] == NULL)
goto reply_err;
se_->process_buf = fuse_ll_buf_process_read;
fuse_ll_ops[in->opcode].func(req, in);
fuse_ll_funcs[in->opcode](req,in);
return;
@@ -1977,9 +2035,9 @@ fuse_lowlevel_new_common(struct fuse_args *args,
f->userdata = userdata;
se = fuse_session_new(f,
fuse_ll_buf_receive_read,
fuse_ll_buf_process_read_init,
fuse_ll_destroy);
(void*)fuse_ll_buf_receive_read,
(void*)fuse_ll_buf_process_read_init,
(void*)fuse_ll_destroy);
if(!se)
goto out_key_destroy;
+12
View File
@@ -1,3 +1,5 @@
#pragma once
#include "lock.h"
#include "lfmp.h"
@@ -23,8 +25,18 @@ struct node_s
uint8_t is_stat_cache_valid:1;
};
#ifdef __cplusplus
extern "C"
{
#endif
node_t *node_alloc();
void node_free(node_t*);
int node_gc1();
void node_gc();
lfmp_t *node_lfmp();
#ifdef __cplusplus
}
#endif
+19 -6
View File
@@ -106,16 +106,22 @@ If you don\[cq]t already know that you have a special use case then just
start with one of the following option sets.
.SS You need \f[C]mmap\f[R] (used by rtorrent and many sqlite3 base software)
.PP
\f[C]cache.files=partial,dropcacheonclose=true,category.create=mfs\f[R]
\f[C]cache.files=auto-full,dropcacheonclose=true,category.create=mfs\f[R]
.PP
or if you are on a Linux kernel >= 6.6.x mergerfs will enable a mode
that allows shared mmap when \f[C]cache.files=off\f[R].
To be sure of the best performance between \f[C]cache.files=off\f[R] and
\f[C]cache.files=auto-full\f[R] you\[cq]ll need to do your own
benchmarking but often \f[C]off\f[R] is faster.
.SS You don\[cq]t need \f[C]mmap\f[R]
.PP
\f[C]cache.files=off,dropcacheonclose=true,category.create=mfs\f[R]
.SS Command Line
.PP
\f[C]mergerfs -o cache.files=partial,dropcacheonclose=true,category.create=mfs /mnt/hdd0:/mnt/hdd1 /media\f[R]
\f[C]mergerfs -o cache.files=auto-full,dropcacheonclose=true,category.create=mfs /mnt/hdd0:/mnt/hdd1 /media\f[R]
.SS /etc/fstab
.PP
\f[C]/mnt/hdd0:/mnt/hdd1 /media mergerfs cache.files=partial,dropcacheonclose=true,category.create=mfs 0 0\f[R]
\f[C]/mnt/hdd0:/mnt/hdd1 /media mergerfs cache.files=auto-full,dropcacheonclose=true,category.create=mfs 0 0\f[R]
.SS systemd mount
.PP
https://github.com/trapexit/mergerfs/wiki/systemd
@@ -130,7 +136,7 @@ Type=simple
KillMode=none
ExecStart=/usr/bin/mergerfs \[rs]
-f \[rs]
-o cache.files=partial \[rs]
-o cache.files=auto-full \[rs]
-o dropcacheonclose=true \[rs]
-o category.create=mfs \[rs]
/mnt/hdd0:/mnt/hdd1 \[rs]
@@ -185,6 +191,13 @@ Recommended when
caching.
(default: false)
.IP \[bu] 2
\f[B]direct-io-allow-mmap=BOOL\f[R]: On newer kernels (>= 6.6) it is
possible to disable file page caching while still allowing for shared
mmap support.
mergerfs will enable this feature if available but an option is provided
to turn it off for testing and debugging purposes.
(default: true)
.IP \[bu] 2
\f[B]symlinkify=BOOL\f[R]: When enabled and a file is not writable and
its mtime or ctime is older than \f[B]symlinkify_timeout\f[R] files will
be reported as symlinks to the original files.
@@ -2396,8 +2409,8 @@ Take a look at the section on NFS in the #remote-filesystems for more
details.
.SS rtorrent fails with ENODEV (No such device)
.PP
Be sure to set \f[C]cache.files=partial|full|auto-full|per-processe\f[R]
or turn off \f[C]direct_io\f[R].
Be sure to set
\f[C]cache.files=partial|full|auto-full|per-processe\f[R].
rtorrent and some other applications use
mmap (http://linux.die.net/man/2/mmap) to read and write to files and
offer no fallback to traditional methods.
+16
View File
@@ -0,0 +1,16 @@
# mkdocs
## Getting started
```bash
python3 -m venv venv
source venv/bin/activate
pip3 install --no-cache-dir mkdocs mkdocs-material pymdown-extensions
mkdocs serve
```
## References
* https://www.mkdocs.org/
* https://squidfunk.github.io/mkdocs-material/
+80
View File
@@ -0,0 +1,80 @@
# Benchmarking
Filesystems are complicated. They do many things and many of those are
interconnected. Additionally, the OS, drivers, hardware, etc. can all
impact performance. Therefore, when benchmarking, it is **necessary**
that the test focuses as narrowly as possible.
For most throughput is the key benchmark. To test throughput `dd` is
useful but **must** be used with the correct settings in order to
ensure the filesystem or device is actually being tested. The OS can
and will cache data. Without forcing synchronous reads and writes
and/or disabling caching the values returned will not be
representative of the device's true performance.
When benchmarking through mergerfs ensure you only use 1 branch to
remove any possibility of the policies complicating the
situation. Benchmark the underlying filesystem first and then mount
mergerfs over it and test again. If you're experiencing speeds below
your expectation you will need to narrow down precisely which
component is leading to the slowdown. Preferably test the following in
the order listed (but not combined).
1. Enable `nullrw` mode with `nullrw=true`. This will effectively make
reads and writes no-ops. Removing the underlying device /
filesystem from the equation. This will give us the top theoretical
speeds.
2. Mount mergerfs over `tmpfs`. `tmpfs` is a RAM disk. Extremely high
speed and very low latency. This is a more realistic best case
scenario. Example: `mount -t tmpfs -o size=2G tmpfs /tmp/tmpfs`
3. Mount mergerfs over a local device. NVMe, SSD, HDD, etc. If you
have more than one I'd suggest testing each of them as drives
and/or controllers (their drivers) could impact performance.
4. Finally, if you intend to use mergerfs with a network filesystem,
either as the source of data or to combine with another through
mergerfs, test each of those alone as above.
Once you find the component which has the performance issue you can do
further testing with different options to see if they impact
performance. For reads and writes the most relevant would be:
`cache.files`, `async_read`. Less likely but relevant when using NFS
or with certain filesystems would be `security_capability`, `xattr`,
and `posix_acl`. If you find a specific system, device, filesystem,
controller, etc. that performs poorly contact trapexit so he may
investigate further.
Sometimes the problem is really the application accessing or writing
data through mergerfs. Some software use small buffer sizes which can
lead to more requests and therefore greater overhead. You can test
this out yourself by replacing `bs=1M` in the examples below with `ibs`
or `obs` and using a size of `512` instead of `1M`. In one example
test using `nullrw` the write speed dropped from 4.9GB/s to 69.7MB/s
when moving from `1M` to `512`. Similar results were had when testing
reads. Small writes overhead may be improved by leveraging a write
cache but in casual tests little gain was found. More tests will need
to be done before this feature would become available. If you have an
app that appears slow with mergerfs it could be due to this. Contact
trapexit so he may investigate further.
### write benchmark
```
$ dd if=/dev/zero of=/mnt/mergerfs/1GB.file bs=1M count=1024 oflag=nocache conv=fdatasync status=progress
```
### read benchmark
```
$ dd if=/mnt/mergerfs/1GB.file of=/dev/null bs=1M count=1024 iflag=nocache conv=fdatasync status=progress
```
### other benchmarks
If you are attempting to benchmark other behaviors you must ensure you
clear kernel caches before runs. In fact it would be a good deal to
run before the read and write benchmarks as well just in case.
```
sync
echo 3 | sudo tee /proc/sys/vm/drop_caches
```
+54
View File
@@ -0,0 +1,54 @@
# branches
The 'branches' argument is a colon (':') delimited list of paths to be
pooled together. It does not matter if the paths are on the same or
different filesystems nor does it matter the filesystem type (within
reason). Used and available space will not be duplicated for paths on
the same filesystem and any features which aren't supported by the
underlying filesystem (such as file attributes or extended attributes)
will return the appropriate errors.
Branches currently have two options which can be set. A type which
impacts whether or not the branch is included in a policy calculation
and a individual minfreespace value. The values are set by prepending
an `=` at the end of a branch designation and using commas as
delimiters. Example: `/mnt/drive=RW,1234`
### branch mode
- RW: (read/write) - Default behavior. Will be eligible in all policy
categories.
- RO: (read-only) - Will be excluded from `create` and `action`
policies. Same as a read-only mounted filesystem would be (though
faster to process).
- NC: (no-create) - Will be excluded from `create` policies. You can't
create on that branch but you can change or delete.
### minfreespace
Same purpose and syntax as the global option but specific to the
branch. If not set the global value is used.
### globbing
To make it easier to include multiple branches mergerfs supports
[globbing](http://linux.die.net/man/7/glob). **The globbing tokens
MUST be escaped when using via the shell else the shell itself will
apply the glob itself.**
```
# mergerfs /mnt/hdd\*:/mnt/ssd /media
```
The above line will use all mount points in /mnt prefixed with **hdd**
and **ssd**.
To have the pool mounted at boot or otherwise accessible from related
tools use `/etc/fstab`.
```
# <file system> <mount point> <type> <options> <dump> <pass>
/mnt/hdd*:/mnt/ssd /media mergerfs minfreespace=16G 0 0
```
**NOTE:** The globbing is done at mount or when updated using the runtime API. If a new directory is added matching the glob after the fact it will not be automatically included.
+187
View File
@@ -0,0 +1,187 @@
# caching
## cache.files
Controls how [page caching](https://en.wikipedia.org/wiki/Page_cache)
works for mergerfs itself. Not the underlying filesystems.
* `cache.files=off`: Disables page caching for mergerfs.
* `cache.files=partial`: Enables page caching. Files are cached
while open.
* `cache.files=full`: Enables page caching. Files are cached across
opens.
* `cache.files=auto-full`: Enables page caching. Files are cached
across opens if mtime and size are unchanged since previous open.
* `cache.files=per-process`: Enable page caching (equivalent to
`cache.files=partial`) only for processes whose 'comm' name matches
one of the values defined in cache.files.process-names. If the name
does not match the file open is equivalent to `cache.files=off`.
Generally, enabling the page cache actually *harms*
performance[^1]. In part because it can lead to buffer bloat due to
the kernel caching both the underlying filesystem's file content as
well as the file through mergerfs. However, if you want to confirm
performance differences it is recommended that you perform some
benchmark to confirm which option works best for your setup.
Why then would you want to enable page caching if it consumes ~2x the
RAM as normal and is on average slower? Because it is the only way to
support
[mmap](https://man7.org/linux/man-pages/man2/mmap.2.html). `mmap` is a
way for programs to treat a file as if it is a contiguous RAM buffer
which is regularly used by a number of programs such as those that
leverage **sqlite3**. Despite `mmap` not being supported by all
filesystems it is unfortunately common for software to not have an
option to use regular file IO instead of `mmap`.
The good thing is that in Linux v6.6[^2] and above FUSE can now
transparently enable page caching when mmap is requested. This means
it should be safe to set `cache.files=off`. However, on Linux v6.5 and
below you will need to configure `cache.files` as you need.
[^1]: This is not unique to mergerfs and affects all FUSE
filesystems. It is something that the FUSE community hopes to
investigate at some point but as of early 2025 there are a number
of major reworking going on with FUSE which needs to be finished
first.
[^2]: [https://kernelnewbies.org/Linux_6.6#FUSE](https://kernelnewbies.org/Linux_6.6#FUSE)
## cache.entry
* `cache.entry=UINT`: Sets the number of seconds to cache
entry queries. Defaults to `1`.
The kernel must ask mergerfs about the existence of files. The entry
cache caches that those details which limits the number of requests
sent to mergerfs.
The risk of setting this value, as with most any cache, is related to
[out-of-band](https://en.wikipedia.org/wiki/Out-of-band) changes. If
the filesystems are changed outside mergerfs there is a risk of files
which have been removed continuing to show as available. It will fail
gracefully if a phantom file is actioned on in some way so there is
little risk in setting the value much higher. Especially if there are
no out-of-band changes.
## cache.negative_entry
* `cache.negative_entry=UINT`: Sets the number of seconds to cache
negative entry queries. Defaults to `1`.
This is a cache for negative entry query responses. Such as when a
file which does not exist is referenced.
The risk of setting this value, as with most any cache, is related to
[out-of-band](https://en.wikipedia.org/wiki/Out-of-band) changes. If
the filesystems are changed outside mergerfs there is a risk of files
which have been added outside mergerfs not appearing correctly till
the cache entry times out if there had been a request for the same
name within mergerfs which didn't exist. This is mostly an
inconvenience.
## cache.attr
* `cache.attr=UINT`: Sets the number of seconds to cache file
attributes. Defaults to `1`.
This is a cache for file attributes and metadata such as that which is
collected by the
[stat](https://man7.org/linux/man-pages/man2/stat.2.html) system call
which is used when you run commands such as `find` or `ls -lh`.
As with other caches the risk of enabling the attribute cache is if
changes are made to the file out-of-band there could be
inconsistencies between the actual file and the cached details which
could result in different issues depending on how the data is used. If
the simultaneous writing of a file from inside and outside is unlikely
then you should be safe. That said any simultaneous, uncoordinated
manipulation of a file can lead to unexpected results.
## cache.statfs
* `cache.statfs=UINT`: Sets the number of seconds to cache `statfs`
calls used by policies. Defaults to `0`.
A number of policies require looking up the available space of the
branches being considered. This is accomplished by calling
[statfs](https://man7.org/linux/man-pages/man2/statfs.2.html). This
call however is a bit expensive so this cache reduces the overhead by
limiting how often the calls are actually made.
This will mean that if the available space of branches changed
somewhat rapidly there is a risk of `create` or `mkdir` calls made
within the timeout period ending up on the same branch. This however
should even itself out over time.
## cache.symlinks
* `cache.symlinks=BOOL`: Enable kernel caching of symlink
values. Defaults to `false`.
As of Linux v4.20 there is an ability to cache the value of symlinks
so that the kernel does not need to make a request to mergerfs every
single time a
[readlink](https://man7.org/linux/man-pages/man2/readlink.2.html)
request is made. While not a common usage pattern, if software very
regularly queries symlink values, the use of this cache could
significantly improve performance.
mergerfs will not error if the kernel used does not support symlink
caching.
As with other caches the main risk in enabling it is if you are
manipulating symlinks from both within and without the mergerfs
mount. Should the value be changed outside of mergerfs then it will
not be reflected in the mergerfs mount till the cached value is
invalidated.
## cache.readdir
* `cache.readdir=BOOL`: Enable kernel caching of readdir
results. Defaults to `false`.
As of Linux v4.20 it supports readdir caching. This can have a
significant impact on directory traversal. Especially when combined
with entry (`cache.entry`) and attribute (`cache.attr`) caching. If
the kernel doesn't support readdir caching setting the option to true
has no effect. This option is configurable at runtime via xattr
user.mergerfs.cache.readdir.
## cache.writeback
* `cache.writeback=BOOL`: Enable writeback cache. Defaults to `false`.
When `cache.files` is enabled the default is for it to perform
writethrough caching. This behavior won't help improve performance as
each write still goes one for one through the filesystem. By enabling
the FUSE writeback cache small writes *may* be aggregated by the
kernel and then sent to mergerfs as one larger request. This can
greatly improve the throughput for apps which write to files
inefficiently. The amount the kernel can aggregate is limited by the
size of a FUSE message. Read the fuse_msg_size section for more
details.
There is a side effect as a result of enabling writeback
caching. Underlying files won't ever be opened with O_APPEND or
O_WRONLY. The former because the kernel then manages append mode and
the latter because the kernel may request file data from mergerfs to
populate the write cache. The O_APPEND change means that if a file is
changed outside of mergerfs it could lead to corruption as the kernel
won't know the end of the file has changed. That said any time you use
caching you should keep from writing to the same file outside of
mergerfs at the same time.
Note that if an application is properly sizing writes then writeback
caching will have little or no effect. It will only help with writes
of sizes below the FUSE message size (128K on older kernels, 1M on
newer). Even then its effectiveness might not be great. Given the side
effects of enabling this feature it is recommended that its benefits
be proved out with benchmarks.
+21
View File
@@ -0,0 +1,21 @@
# Deprecated Options
These are old, deprecated options which may no longer have any
function or have been replaced.
* **direct_io**: Bypass page cache. Use `cache.files=off`
instead.
* **kernel_cache**: Do not invalidate data cache on file open. Use
`cache.files=full` instead.
* **auto_cache**: Invalidate data cache if file mtime or
size change. Use `cache.files=auto-full` instead. (default: false)
* **async_read**: Perform reads asynchronously. Use
`async_read=true` instead.
* **sync_read**: Perform reads synchronously. Use
`async_read=false` instead.
* **splice_read**: Does nothing.
* **splice_write**: Does nothing.
* **splice_move**: Does nothing.
* **allow_other**: mergerfs v2.35.0 and above sets this FUSE option
automatically if running as root.
* **use_ino**: Effectively replaced with `inodecalc`.
+14
View File
@@ -0,0 +1,14 @@
# export-support
* `export-support=true|false`
* Defaults to `true`.
In theory, this flag should not be exposed to the end user. It is a
low-level FUSE flag which indicates whether or not the kernel can send
certain kinds of messages to it for the purposes of using it with
NFS. mergerfs does support these messages but due to bugs and quirks
found in the kernel and mergerfs this option is provided just in case
it is needed for debugging.
Given that this flag is set when the FUSE connection is first
initiated it is not possible to change during run time.
+21
View File
@@ -0,0 +1,21 @@
# flush-on-close
By default, FUSE would issue a flush before the release of a file
descriptor. This was considered a bit aggressive and a feature added
to give the FUSE server the ability to choose when that happens.
* `flush-on-close=always`
* `flush-on-close=never`
* `flush-on-close=opened-for-write`
* Defaults to `opened-for-write`.
For now it defaults to `opened-for-write` which is less aggressive
than the behavior before this feature was added. It should not be a
problem because the flush is really only relevant when a file is
written to. Given flush is irrelevant for many filesystems in the
future a branch specific flag may be added so only files opened on a
specific branch would be flushed on close.
## References
* [https://lkml.kernel.org/linux-fsdevel/20211024132607.1636952-1-amir73il@gmail.com/T/](https://lkml.kernel.org/linux-fsdevel/20211024132607.1636952-1-amir73il@gmail.com/T/)
+23
View File
@@ -0,0 +1,23 @@
# follow-symlinks
This feature, when enabled, will cause symlinks to be interpreted by
mergerfs as their target.
When there is a getattr/stat request for a file mergerfs will check if
the file is a symlink and depending on the `follow-symlinks` setting
will replace the information about the symlink with that of that which
it points to.
When unlink'ing or rmdir'ing the followed symlink it will remove the
symlink itself and not that which it points to.
* `follow-symlinks=never`: Behave as normal. Symlinks are treated as such.
* `follow-symlinks=directory`: Resolve symlinks only which point to directories.
* `follow-symlinks=regular`: Resolve symlinks only which point to regular files.
* `follow-symlinks=all`: Resolve all symlinks to that which they point
to. Symlinks which do not point to anything are left as is.
* Defaults to `never`.
**WARNING:** This feature should be considered experimental. There
might be edge cases yet found. If you find any odd behaviors please
file a ticket on [github](https://github.com/trapexit/mergerfs/issues/new?assignees=&labels=bug%2C+investigating&projects=&template=bug_report.md&title=).
+17
View File
@@ -0,0 +1,17 @@
# func.readdir
examples: `func.readdir=seq`, `func.readdir=cor:4`
`readdir` has policies to control how it reads directory content.
| Policy | Description |
| ------ | ----------- |
| seq | "sequential" : Iterate sequentially over branches in the order defined in `branches`. This is the default and traditional behavior found prior to the readdir policy introduction. This will be increasingly slower as more branches are added to the pool. Especially if needing to wait for drives to spin up or network filesystems to respond. |
| cosr | "concurrent open, sequential read" : Concurrently open branch directories using a thread pool and process them in the order defined in `branches`. This keeps memory and CPU usage low while also reducing the time spent waiting on branches to respond. Number of threads defaults to the number of logical cores. Can be overwritten via the syntax `func.readdir=cosr:N` where `N` is the number of threads. |
| cor | "concurrent open and read" : Concurrently open branch directories and immediately start reading their contents using a thread pool. This will result in slightly higher memory and CPU usage but reduced latency. Particularly when using higher latency / slower speed network filesystem branches. Unlike `seq` and `cosr` the order of files could change due the async nature of the thread pool. This should not be a problem since the order of files listed in not guaranteed. Number of threads defaults to the number of logical cores. Can be overwritten via the syntax `func.readdir=cor:N` where `N` is the number of threads. |
Keep in mind that `readdir` mostly just provides a list of file names
in a directory and possibly some basic metadata about said files. To
know details about the files, as one would see from commands like
`find` or `ls`, it is required to call `stat` on the file which is
controlled by `fuse.getattr`.
@@ -0,0 +1,139 @@
# functions, categories and policies
The POSIX filesystem API is made up of a number of
functions. **creat**, **stat**, **chown**, etc. For ease of
configuration in mergerfs, most of the core functions are grouped into
3 categories: **action**, **create**, and **search**. These functions
and categories can be assigned a policy which dictates which branch is
chosen when performing that function.
Some functions, listed in the category `N/A` below, can not be
assigned the normal policies because they are directly related to a
file which has already been opened.
When using policies which are based on a branch's available space the
base path provided is used. Not the full path to the file in
question. Meaning that mounts in the branch won't be considered in the
space calculations. The reason is that it doesn't really work for
non-path preserving policies and can lead to non-obvious behaviors.
NOTE: While any policy can be assigned to a function or category,
some may not be very useful in practice. For instance: **rand**
(random) may be useful for file creation (create) but could lead to
very odd behavior if used for `chmod` if there were more than one copy
of the file.
## Functions and their Category classifications
| Category | Functions |
| -------- | --------- |
| action | chmod, chown, link, removexattr, rename, rmdir, setxattr, truncate, unlink, utimens |
| create | create, mkdir, mknod, symlink |
| search | access, getattr, getxattr, ioctl (directories), listxattr, open, readlink |
| N/A | fchmod, fchown, futimens, ftruncate, fallocate, fgetattr, fsync, ioctl (files), read, readdir, release, statfs, write, copy_file_range |
In cases where something may be searched for (such as a path to clone)
**getattr** will usually be used.
## Policies
A policy is the algorithm used to choose a branch or branches for a
function to work on or generally how the function behaves.
Any function in the `create` category will clone the relative path if
needed. Some other functions (`rename`,`link`,`ioctl`) have special
requirements or behaviors which you can read more about below.
## Filtering
Most policies basically search branches and create a list of files / paths
for functions to work on. The policy is responsible for filtering and
sorting the branches. Filters include **minfreespace**, whether or not
a branch is mounted read-only, and the branch tagging
(RO,NC,RW). These filters are applied across most policies.
- No **search** function policies filter.
- All **action** function policies filter out branches which are
mounted **read-only** or tagged as **RO (read-only)**.
- All **create** function policies filter out branches which are
mounted **read-only**, tagged **RO (read-only)** or **NC (no
create)**, or has available space less than `minfreespace`.
Policies may have their own additional filtering such as those that
require existing paths to be present.
If all branches are filtered an error will be returned. Typically
**EROFS** (read-only filesystem) or **ENOSPC** (no space left on
device) depending on the most recent reason for filtering a
branch. **ENOENT** will be returned if no eligible branch is found.
If **create**, **mkdir**, **mknod**, or **symlink** fail with `EROFS`
or other fundamental errors then mergerfs will mark any branch found
to be read-only as such (IE will set the mode `RO`) and will rerun the
policy and try again. This is mostly for `ext4` filesystems that can
suddenly become read-only when it encounters an error.
## Path Preservation
Policies, as described below, are of two basic classifications. `path
preserving` and `non-path preserving`.
All policies which start with `ep` (**epff**, **eplfs**, **eplus**,
**epmfs**, **eprand**) are `path preserving`. `ep` stands for
`existing path`.
A path preserving policy will only consider branches where the relative
path being accessed already exists.
When using non-path preserving policies paths will be cloned to target
branches as necessary.
With the `msp` or `most shared path` policies they are defined as
`path preserving` for the purpose of controlling `link` and `rename`'s
behaviors since `ignorepponrename` is available to disable that
behavior.
## Policy descriptions
A policy's behavior differs, as mentioned above, based on the function
it is used with. Sometimes it really might not make sense to even
offer certain policies because they are literally the same as others
but it makes things a bit more uniform.
| Policy | Description |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| all | Search: For **mkdir**, **mknod**, and **symlink** it will apply to all branches. **create** works like **ff**. |
| epall (existing path, all) | For **mkdir**, **mknod**, and **symlink** it will apply to all found. **create** works like **epff** (but more expensive because it doesn't stop after finding a valid branch). |
| epff (existing path, first found) | Given the order of the branches, as defined at mount time or configured at runtime, act on the first one found where the relative path exists. |
| eplfs (existing path, least free space) | Of all the branches on which the relative path exists choose the branch with the least free space. |
| eplus (existing path, least used space) | Of all the branches on which the relative path exists choose the branch with the least used space. |
| epmfs (existing path, most free space) | Of all the branches on which the relative path exists choose the branch with the most free space. |
| eppfrd (existing path, percentage free random distribution) | Like **pfrd** but limited to existing paths. |
| eprand (existing path, random) | Calls **epall** and then randomizes. Returns 1. |
| ff (first found) | Given the order of the branches, as defined at mount time or configured at runtime, act on the first one found. |
| lfs (least free space) | Pick the branch with the least available free space. |
| lus (least used space) | Pick the branch with the least used space. |
| mfs (most free space) | Pick the branch with the most available free space. |
| msplfs (most shared path, least free space) | Like **eplfs** but if it fails to find a branch it will try again with the parent directory. Continues this pattern till finding one. |
| msplus (most shared path, least used space) | Like **eplus** but if it fails to find a branch it will try again with the parent directory. Continues this pattern till finding one. |
| mspmfs (most shared path, most free space) | Like **epmfs** but if it fails to find a branch it will try again with the parent directory. Continues this pattern till finding one. |
| msppfrd (most shared path, percentage free random distribution) | Like **eppfrd** but if it fails to find a branch it will try again with the parent directory. Continues this pattern till finding one. |
| newest | Pick the file / directory with the largest mtime. |
| pfrd (percentage free random distribution) | Chooses a branch at random with the likelihood of selection based on a branch's available space relative to the total. |
| rand (random) | Calls **all** and then randomizes. Returns 1 branch. |
**NOTE:** If you are using an underlying filesystem that reserves
blocks such as ext2, ext3, or ext4 be aware that mergerfs respects the
reservation by using `f_bavail` (number of free blocks for
unprivileged users) rather than `f_bfree` (number of free blocks) in
policy calculations. **df** does NOT use `f_bavail`, it uses
`f_bfree`, so direct comparisons between **df** output and mergerfs'
policies is not appropriate.
## Defaults
| Category | Policy |
| -------- | ------ |
| action | epall |
| create | epmfs |
| search | ff |
+29
View File
@@ -0,0 +1,29 @@
# fuse_msg_size
* `fuse_msg_size=UINT`
* Defaults to `256`
FUSE applications communicate with the kernel over a special character
device: `/dev/fuse`. A large portion of the overhead associated with
FUSE is the cost of going back and forth between user space and kernel
space over that device. Generally speaking, the fewer trips needed the
better the performance will be. Reducing the number of trips can be
done a number of ways. Kernel level caching and increasing message
sizes being two significant ones. When it comes to reads and writes if
the message size is doubled the number of trips are approximately
halved.
In Linux v4.20 a new feature was added allowing the negotiation of the
max message size. Since the size is in multiples of
[pages](https://en.wikipedia.org/wiki/Page_(computer_memory)) the
feature is called `max_pages`. There is a maximum `max_pages` value of
256 (1MiB) and minimum of 1 (4KiB). The default used by Linux >=4.20,
and hardcoded value used before 4.20, is 32 (128KiB). In mergerfs it's
referred to as fuse_msg_size to make it clear what it impacts and
provide some abstraction.
Since there should be no downsides to increasing `fuse_msg_size`,
outside a minor increase in RAM usage due to larger message buffers,
mergerfs defaults the value to 256. On kernels before v4.20 the value
has no effect. The reason the value is configurable is to enable
experimentation and benchmarking.
+75
View File
@@ -0,0 +1,75 @@
# inodecalc
Inodes (`st_ino`) are unique identifiers within a filesystem. Each
mounted filesystem has device ID (st_dev) as well and together they
can uniquely identify a file on the whole of the system. Entries on
the same device with the same inode are in fact references to the same
underlying file. It is a many to one relationship between names and an
inode. Directories, however, do not have multiple links on most
systems due to the complexity they add.
FUSE allows the server (mergerfs) to set inode values but not device
IDs. Creating an inode value is somewhat complex in mergerfs' case as
files aren't really in its control. If a policy changes what directory
or file is to be selected or something changes out of band it becomes
unclear what value should be used. Most software does not to care what
the values are but those that do often break if a value changes
unexpectedly. The tool find will abort a directory walk if it sees a
directory inode change. NFS can return stale handle errors if the
inode changes out of band. File dedup tools will usually leverage
device ids and inodes as a shortcut in searching for duplicate files
and would resort to full file comparisons should it find different
inode values.
mergerfs offers multiple ways to calculate the inode in hopes of
covering different usecases.
* `passthrough`: Passes through the underlying inode value. Mostly
intended for testing as using this does not address any of the
problems mentioned above and could confuse file deduplication
software as inodes from different filesystems can be the same.
* `path-hash`: Hashes the relative path of the entry in question. The
underlying file's values are completely ignored. This means the
inode value will always be the same for that file path. This is
useful when using NFS and you make changes out of band such as copy
data between branches. This also means that entries that do point to
the same file will not be recognizable via inodes. That does not
mean hard links don't work. They will.
* `path-hash32`: 32bit version of path-hash.
* `devino-hash`: Hashes the device id and inode of the underlying
entry. This won't prevent issues with NFS should the policy pick a
different file or files move out of band but will present the same
inode for underlying files that do too.
* `devino-hash32`: 32bit version of devino-hash.
* `hybrid-hash`: Performs path-hash on directories and devino-hash on
other file types. Since directories can't have hard links the static
value won't make a difference and the files will get values useful
for finding duplicates. Probably the best to use if not using
NFS. As such it is the default.
* `hybrid-hash32`: 32bit version of hybrid-hash.
32bit versions are provided as there is some software which does not
handle 64bit inodes well.
While there is a risk of hash collision in tests of a couple of
million entries there were zero collisions. Unlike a typical
filesystem FUSE filesystems can reuse inodes and not refer to the same
entry. The internal identifier used to reference a file in FUSE is
different from the inode value presented. The former is the nodeid and
is actually a tuple of 2 64bit values: nodeid and generation. This
tuple is not client facing. The inode that is presented to the client
is passed through the kernel uninterpreted.
From FUSE docs for `use_ino`:
> Honor the st_ino field in the functions getattr() and
> fill_dir(). This value is used to fill in the st_ino field
> in the stat(2), lstat(2), fstat(2) functions and the d_ino
> field in the readdir(2) function. The filesystem does not
> have to guarantee uniqueness, however some applications
> rely on this value being unique for the whole filesystem.
> Note that this does *not* affect the inode that libfuse
> and the kernel use internally (also called the "nodeid").
**NOTE:** As of version 2.35.0 the use_ino option has been
removed. mergerfs should always be managing inode values.
+17
View File
@@ -0,0 +1,17 @@
# link-exdev
If using path preservation and a `link` fails with `EXDEV` make a call
to `symlink` where the target is the `oldlink` and the `linkpath` is
the newpath. The target value is determined by the value of
`link-exdev`.
* `link-exdev=passthrough`: Return EXDEV as normal.
* `link-exdev=rel-symlink`: A relative path from the newpath.
* `link-exdev=abs-base-symlink`: An absolute value using the
underlying branch.
* `link-exdev=abs-pool-symlink`: An absolute value using the mergerfs
mount point.
* Defaults to `passthrough`.
**NOTE:** It is possible that some applications check the file they
link. In those cases, it is possible it will error or complain.
+13
View File
@@ -0,0 +1,13 @@
# link_cow
* `link_cow=true|false`
* Defaults to `false`
This feature offers similar functionality to what
[cow-shell](https://manpages.ubuntu.com/manpages/noble/man1/cow-shell.1.html)
offers.
When enabled if mergerfs is asked to open a file to write and the link
count on the file is greater than 1 it will copy the file to a
temporary new file and then rename it over the original. This will
atomically "break" the link. After that it will open the new file.
+26
View File
@@ -0,0 +1,26 @@
# nfsopenhack
* `nfsopenhack=off`: No hack applied.
* `nfsopenhack=git`: Apply hack if path includes `/.git/`.
* `nfsopenhack=all`: Apply hack on all empty read-only files opened
for writing.
* Defaults to `off`.
NFS is not fully POSIX compliant and historically certain behaviors,
such as opening files with `O_EXCL`, are not or not well
supported. When mergerfs (or any FUSE filesystem) is exported over NFS
some of these issues come up due to how NFS and FUSE interact.
This hack addresses the issue where the creation of a file with a
read-only mode but with a read/write or write only flag. Normally this
is perfectly valid but NFS chops the one open call into multiple
calls. Exactly how it is translated depends on the configuration and
versions of the NFS server and clients but it results in a permission
error because a normal user is not allowed to open a read-only file as
writable.
Even though it's a more niche situation this hack breaks normal
security and behavior and as such is `off` by default. If set to `git`
it will only perform the hack when the path in question includes
`/.git/`. `all` will result in it applying anytime a read-only file
which is empty is opened for writing.
+20
View File
@@ -0,0 +1,20 @@
# nullrw
* `nullrw=true|false`
* Defaults to `false`.
Due to how FUSE works there is an overhead to all requests made to a
FUSE filesystem that wouldn't exist for an in kernel one. Meaning that
even a simple passthrough will have some slowdown. However, generally
the overhead is minimal in comparison to the cost of the underlying
I/O. By disabling the underlying I/O we can test the theoretical
performance boundaries.
By enabling `nullrw` mergerfs will work as it always does **except**
that all reads and writes will be no-ops. A write will succeed (the
size of the write will be returned as if it were successful) but
mergerfs does nothing with the data it was given. Similarly a read
will return the size requested but won't touch the buffer.
See the [benchmarking](../benchmarking.md) section for suggestions on
how to test.
+185
View File
@@ -0,0 +1,185 @@
# Options
These options are the same regardless of whether you use them with the
`mergerfs` commandline program, in fstab, or in a config file.
### types
- BOOL = 'true' | 'false'
- INT = [MIN_INT,MAX_INT]
- UINT = [0,MAX_INT]
- SIZE = 'NNM'; NN = INT, M = 'K' | 'M' | 'G' | 'T'
- STR = string (may refer to an enumerated value, see details of
argument)
- FUNC = filesystem function
- CATEGORY = function category
- POLICY = mergerfs function policy
### mount options
- **config**: Path to a config file. Same arguments as below in
key=val / ini style format.
- **branches**: Colon delimited list of branches.
- **minfreespace=SIZE**: The minimum space value used for creation
policies. Can be overridden by branch specific option. Understands
'K', 'M', and 'G' to represent kilobyte, megabyte, and gigabyte
respectively. (default: 4G)
- **moveonenospc=BOOL|POLICY**: When enabled if a **write** fails with
**ENOSPC** (no space left on device) or **EDQUOT** (disk quota
exceeded) the policy selected will run to find a new location for
the file. An attempt to move the file to that branch will occur
(keeping all metadata possible) and if successful the original is
unlinked and the write retried. (default: false, true = mfs)
- **inodecalc=passthrough|path-hash|devino-hash|hybrid-hash**: Selects
the inode calculation algorithm. (default: hybrid-hash)
- **dropcacheonclose=BOOL**: When a file is requested to be closed
call `posix_fadvise` on it first to instruct the kernel that we no
longer need the data and it can drop its cache. Recommended when
**cache.files=partial|full|auto-full|per-process** to limit double
caching. (default: false)
- **direct-io-allow-mmap=BOOL**: On newer kernels (>= 6.6) it is
possible to disable file page caching while still allowing for
shared mmap support. mergerfs will enable this feature if available
but an option is provided to turn it off for testing and debugging
purposes. (default: true)
- **symlinkify=BOOL**: When enabled and a file is not writable and its
mtime or ctime is older than **symlinkify_timeout** files will be
reported as symlinks to the original files. Please read more below
before using. (default: false)
- **symlinkify_timeout=UINT**: Time to wait, in seconds, to activate
the **symlinkify** behavior. (default: 3600)
- **nullrw=BOOL**: Turns reads and writes into no-ops. The request
will succeed but do nothing. Useful for benchmarking
mergerfs. (default: false)
- **lazy-umount-mountpoint=BOOL**: mergerfs will attempt to "lazy
umount" the mountpoint before mounting itself. Useful when
performing live upgrades of mergerfs. May not work on
FreeBSD. (default: false)
- **ignorepponrename=BOOL**: Ignore path preserving on
rename. Typically rename and link act differently depending on the
policy of `create` (read below). Enabling this will cause rename and
link to always use the non-path preserving behavior. This means
files, when renamed or linked, will stay on the same
filesystem. (default: false)
- **export-support=BOOL**: Sets a low-level FUSE feature intended to
indicate the filesystem can support being exported via
NFS. (default: true)
- **security_capability=BOOL**: If false return ENOATTR when xattr
security.capability is queried. (default: true)
- **xattr=passthrough|noattr|nosys**: Runtime control of
xattrs. Default is to passthrough xattr requests. 'noattr' will
short circuit as if nothing exists. 'nosys' will respond with ENOSYS
as if xattrs are not supported or disabled. (default: passthrough)
- **link_cow=BOOL**: When enabled if a regular file is opened which
has a link count > 1 it will copy the file to a temporary file and
rename over the original. Breaking the link and providing a basic
copy-on-write function similar to cow-shell. (default: false)
- **statfs=base|full**: Controls how statfs works. 'base' means it
will always use all branches in statfs calculations. 'full' is in
effect path preserving and only includes branches where the path
exists. (default: base)
- **statfs_ignore=none|ro|nc**: 'ro' will cause statfs calculations to
ignore available space for branches mounted or tagged as 'read-only'
or 'no create'. 'nc' will ignore available space for branches tagged
as 'no create'. (default: none)
- **nfsopenhack=off|git|all**: A workaround for exporting mergerfs
over NFS where there are issues with creating files for write while
setting the mode to read-only. (default: off)
- **branches-mount-timeout=UINT**: Number of seconds to wait at
startup for branches to be a mount other than the mountpoint's
filesystem. (default: 0)
- **follow-symlinks=never|directory|regular|all**: Turns symlinks into
what they point to. (default: never)
- **link-exdev=passthrough|rel-symlink|abs-base-symlink|abs-pool-symlink**:
When a link fails with EXDEV optionally create a symlink to the file
instead.
- **rename-exdev=passthrough|rel-symlink|abs-symlink**: When a rename
fails with EXDEV optionally move the file to a special directory and
symlink to it.
- **readahead=UINT**: Set readahead (in kilobytes) for mergerfs and
branches if greater than 0. (default: 0)
- **posix_acl=BOOL**: Enable POSIX ACL support (if supported by kernel
and underlying filesystem). (default: false)
- **async_read=BOOL**: Perform reads asynchronously. If disabled or
unavailable the kernel will ensure there is at most one pending read
request per file handle and will attempt to order requests by
offset. (default: true)
- **fuse_msg_size=UINT**: Set the max number of pages per FUSE
message. Only available on Linux >= 4.20 and ignored
otherwise. (min: 1; max: 256; default: 256)
- **threads=INT**: Number of threads to use. When used alone
(`process-thread-count=-1`) it sets the number of threads reading
and processing FUSE messages. When used together it sets the number
of threads reading from FUSE. When set to zero it will attempt to
discover and use the number of logical cores. If the thread count is
set negative it will look up the number of cores then divide by the
absolute value. ie. threads=-2 on an 8 core machine will result in 8
/ 2 = 4 threads. There will always be at least 1 thread. If set to
-1 in combination with `process-thread-count` then it will try to
pick reasonable values based on CPU thread count. NOTE: higher
number of threads increases parallelism but usually decreases
throughput. (default: 0)
- **read-thread-count=INT**: Alias for `threads`.
- **process-thread-count=INT**: Enables separate thread pool to
asynchronously process FUSE requests. In this mode
`read-thread-count` refers to the number of threads reading FUSE
messages which are dispatched to process threads. -1 means disabled
otherwise acts like `read-thread-count`. (default: -1)
- **process-thread-queue-depth=UINT**: Sets the number of requests any
single process thread can have queued up at one time. Meaning the
total memory usage of the queues is queue depth multiplied by the
number of process threads plus read thread count. 0 sets the depth
to the same as the process thread count. (default: 0)
- **pin-threads=STR**: Selects a strategy to pin threads to CPUs
(default: unset)
- **flush-on-close=never|always|opened-for-write**: Flush data cache
on file close. Mostly for when writeback is enabled or merging
network filesystems. (default: opened-for-write)
- **scheduling-priority=INT**: Set mergerfs' scheduling
priority. Valid values range from -20 to 19. See `setpriority` man
page for more details. (default: -10)
- **fsname=STR**: Sets the name of the filesystem as seen in
**mount**, **df**, etc. Defaults to a list of the source paths
concatenated together with the longest common prefix removed.
- **func.FUNC=POLICY**: Sets the specific FUSE function's policy. See
below for the list of value types. Example: **func.getattr=newest**
- **func.readdir=seq|cosr|cor|cosr:INT|cor:INT**: Sets `readdir`
policy. INT value sets the number of threads to use for
concurrency. (default: seq)
- **category.action=POLICY**: Sets policy of all FUSE functions in the
action category. (default: epall)
- **category.create=POLICY**: Sets policy of all FUSE functions in the
create category. (default: epmfs)
- **category.search=POLICY**: Sets policy of all FUSE functions in the
search category. (default: ff)
- **cache.statfs=UINT**: 'statfs' cache timeout in seconds. (default: 0)
- **cache.attr=UINT**: File attribute cache timeout in
seconds. (default: 1)
- **cache.entry=UINT**: File name lookup cache timeout in
seconds. (default: 1)
- **cache.negative_entry=UINT**: Negative file name lookup cache
timeout in seconds. (default: 0)
- **cache.files=libfuse|off|partial|full|auto-full|per-process**: File
page caching mode (default: libfuse)
- **cache.files.process-names=LIST**: A pipe | delimited list of
process [comm](https://man7.org/linux/man-pages/man5/proc.5.html)
names to enable page caching for when
`cache.files=per-process`. (default: "rtorrent|qbittorrent-nox")
- **cache.writeback=BOOL**: Enable kernel writeback caching (default:
false)
- **cache.symlinks=BOOL**: Cache symlinks (if supported by kernel)
(default: false)
- **cache.readdir=BOOL**: Cache readdir (if supported by kernel)
(default: false)
- **parallel-direct-writes=BOOL**: Allow the kernel to dispatch
multiple, parallel (non-extending) write requests for files opened
with `cache.files=per-process` (if the process is not in `process-names`)
or `cache.files=off`. (This requires kernel support, and was added in v6.2)
**NOTE:** Options are evaluated in the order listed so if the options
are **func.rmdir=rand,category.action=ff** the **action** category
setting will override the **rmdir** setting.
**NOTE:** Always look at the documentation for the version of mergerfs
you're using. Not all features are available in older releases.
+23
View File
@@ -0,0 +1,23 @@
# pin-threads
Simple strategies for pinning read and/or process threads. If process
threads are not enabled then the strategy simply works on the read
threads. Invalid values are ignored.
* `pin-threads=R1L`: All read threads pinned to a single logical CPU.
* `pin-threads=R1P`: All read threads pinned to a single physical CPU.
* `pin-threads=RP1L`: All read and process threads pinned to a single logical CPU.
* `pin-threads=RP1P`: All read and process threads pinned to a single physical CPU.
* `pin-threads=R1LP1L`: All read threads pinned to a single logical
CPU, all process threads pinned to a (if possible) different logical
CPU.
* `pin-threads=R1PP1P`: All read threads pinned to a single physical
CPU, all process threads pinned to a (if possible) different logical
CPU.
* `pin-threads=RPSL`: All read and process threads are spread across
all logical CPUs.
* `pin-threads=RPSP`: All read and process threads are spread across
all physical CPUs.
* `pin-threads=R1PPSP`: All read threads are pinned to a single
physical CPU while process threads are spread across all other
physical CPUs.
+38
View File
@@ -0,0 +1,38 @@
# readahead
Sets the mergerfs and underlying filesystem `readahead` values. The
value unit is in kibibytes.
* `readahead=1024`
While the max size of messages sent between the kernel and mergerfs is
configurable via the [fuse_msg_size](fuse_msg_size.md) option that
doesn't mean that is the size used by the kernel for read and
writes.
Linux has a max read/write size of 2GB. Since the max FUSE message
size is just over 1MB the kernel will break up read and write requests
with buffers larger than that 1MB.
When page caching is disabled (`cache.files=off`), besides the kernel
breaking up requests with larger buffers, requests are effectively one
for one to mergerfs. A read or write request for X bytes is made to
the kernel and a request for X bytes is made to mergerfs. No
[readahead](https://en.wikipedia.org/wiki/Readahead) behavior will
occur because there is no page cache available for it to store that
data. In FUSE this is referred to as "direct IO". Note that "direct
IO" is not the same as `O_DIRECT`.
When page caching is enabled the kernel can and will utilize
`readahead`. However, there are two values which impact the size of
the `readahead` requests. The filesystem's `readahead` value and the
FUSE `max_readahead` value. Whichever is lowest is used. The default
`max_readahead` in mergerfs is maxed out meaning only the filesystem
`readahead` value is relevant.
Preferably this value would be set by the user externally since it is
a generic feature but there is no standard way to do so mergerfs added
this feature to make it easier to set.
There is currently no way to set separate values for different
branches through mergerfs.
+21
View File
@@ -0,0 +1,21 @@
# rename-exdev
If using path preservation and a `rename` fails with `EXDEV`:
1. Move file from `/branch/a/b/c` to `/branch/.mergerfs_rename_exdev/a/b/c`.
2. symlink the rename's `newpath` to the moved file.
The `target` value is determined by the value of `rename-exdev`.
* `rename-exdev=passthrough`: Return `EXDEV` as normal.
* `rename-exdev=rel-symlink`: A relative path from the `newpath`.
* `rename-exdev=abs-symlink`: An absolute value using the mergerfs
mount point.
* Defaults to `passthrough`.
**NOTE:** It is possible that some applications check the file they
rename. In those cases it is possible it will error or complain.
**NOTE:** The reason `abs-symlink` is not split into two like
`link-exdev` is due to the complexities in managing absolute base
symlinks when multiple `oldpaths` exist.
+59
View File
@@ -0,0 +1,59 @@
# rename and link
**NOTE:** If you're receiving errors from software when files are
moved / renamed / linked then you should consider changing the create
policy to one which is **not** path preserving, enabling
`ignorepponrename`, or contacting the author of the offending software
and requesting that `EXDEV` (cross device / improper link) be properly
handled.
`rename` and `link` are arguably the most complicated functions to
create in a union filesystem. `rename` only works within a single
filesystem or device. If a rename can't be done due to the source and
destination paths existing on different mount points it will return
**-1** with **errno = EXDEV** (cross device / improper link). So if a
`rename`'s source and target are on different filesystems within the
pool it creates an issue.
Originally mergerfs would return EXDEV whenever a rename was requested
which was cross directory in any way. This made the code simple and
was technically compliant with POSIX requirements. However, many
applications fail to handle EXDEV at all and treat it as a normal
error or otherwise handle it poorly. Such apps include: gvfsd-fuse
v1.20.3 and prior, Finder / CIFS/SMB client in Apple OSX 10.9+,
NZBGet, Samba's recycling bin feature.
As a result a compromise was made in order to get most software to
work while still obeying mergerfs' policies. Below is the basic logic.
* If using a **create** policy which tries to preserve directory paths (epff,eplfs,eplus,epmfs)
* Using the **rename** policy get the list of files to rename
* For each file attempt rename:
* If failure with ENOENT (no such file or directory) run **create** policy
* If create policy returns the same branch as currently evaluating then clone the path
* Re-attempt rename
* If **any** of the renames succeed the higher level rename is considered a success
* If **no** renames succeed the first error encountered will be returned
* On success:
* Remove the target from all branches with no source file
* Remove the source from all branches which failed to rename
* If using a **create** policy which does **not** try to preserve directory paths
* Using the **rename** policy get the list of files to rename
* Using the **getattr** policy get the target path
* For each file attempt rename:
* If the source branch != target branch:
* Clone target path from target branch to source branch
* Rename
* If **any** of the renames succeed the higher level rename is considered a success
* If **no** renames succeed the first error encountered will be returned
* On success:
* Remove the target from all branches with no source file
* Remove the source from all branches which failed to rename
The removals are subject to normal entitlement checks. If the unlink
fails it will fail silently.
The above behavior will help minimize the likelihood of EXDEV being
returned but it will still be possible.
**link** uses the same strategy but without the removals.
+26
View File
@@ -0,0 +1,26 @@
# statfs / statvfs
* `statfs=base`: Aggregate details from all branches using their base directory.
* `statfs=full`: Aggregate details using the full path of the file
requested. Limiting it to only branches where the file exists.
* Defaults to `base`.
[statvfs](http://linux.die.net/man/2/statvfs) normalizes the source
filesystems based on the fragment size and sums the number of adjusted
blocks and inodes. This means you will see the combined space of all
sources. Total, used, and free. The sources however are dedupped based
on the filesystem so multiple sources on the same drive will not result in
double counting its space. Other filesystems mounted further down the tree
of the branch will not be included when checking the mount's stats.
## statfs_ignore
Modifies how `statfs` works. Will cause it to ignore branches of a
certain mode.
* `statfs_ignore=none`: Include all branches.
* `statfs_ignore=ro`: Ignore available space for branches mounted as
read-only or have a mode `RO` or `NC`.
* `statfs_ignore=nc`: Ignore available space for branches with a mode
of `NC`.
* Defaults to `none`.
+23
View File
@@ -0,0 +1,23 @@
# symlinkify
* `symlinkify=true|false`
* Defaults to `false`.
Due to the levels of indirection introduced by mergerfs and the
underlying technology FUSE there can be varying levels of performance
degradation. This feature will turn non-directories which are not
writable into symlinks to the original file found by the `readlink`
policy after the mtime and ctime are older than the timeout.
**WARNING:** The current implementation has a known issue in which if
the file is open and being used when the file is converted to a
symlink then the application which has that file open will receive an
error when using it. This is unlikely to occur in practice but is
something to keep in mind.
**WARNING:** Some backup solutions, such as CrashPlan, do not backup
the target of a symlink. If using this feature it will be necessary to
point any backup software to the original filesystems or configure the
software to follow symlinks if such an option is
available. Alternatively, create two mounts. One for backup and one
for general consumption.
+53
View File
@@ -0,0 +1,53 @@
# threads
There are multiple thread pools used in mergerfs to provide
parallel behaviors.
## read-thread-count
The number of threads used to read (and possibly process) messages
from the kernel.
* `read-thread-count=0`: Create a thread pool sized to the number of
logical CPUs.
* `read-thread-count=N` where `N>0`: Create a thread pool of `N` threads.
* `read-thread-count=N` where `N<0`: Create a thread pool of `CPUCount /
-N` threads.
* `read-thread-count=-1` where `process-thread-count=-1`: Creates `2`
read threads and `max(2,CPUCount-2)` process threads.
* Defaults to `0`.
When `process-thread-count=-1` (the default) this option sets the
number of threads which read and then process requests from the
kernel.
When `process-thread-count` is set to anything else mergerfs will
create two thread pools. A "read" thread pool which just reads from
the kernel and hands off requests to the "process" thread pool.
Generally, only 1 or 2 "read" threads are necessary.
## process-thread-count
When enabled this sets the number of threads in the message processing pool.
* `process-thread-count=-1`: Process thread pool is disabled.
* `process-thread-count=0`: Create a thread pool sized to the number
of logical CPUs.
* `process-thread-count=N` where `N>0`: Create a thread pool of `N` threads.
* `process-thread-count=N` where `N<-1`: Create a thread pool of `CPUCount /
-N` threads.
* Defaults to `-1`.
## process-thread-queue-depth
* `process-thread-queue-depth=N` where `N>0`: Sets the number of outstanding
requests that a process thread can have to N. If requests come in
faster than can be processed and the max queue depth hit then
queuing the request will block in order to limit memory growth.
* `process-thread-queue-depth=0`: Sets the queue depth to the thread
pool count.
* Defaults to `0`.
+27
View File
@@ -0,0 +1,27 @@
# xattr
* `xattr=passthrough`: Passes through all requests to underlying file.
* `xattr=noattr`: mergerfs receives the request but returns `NOATTR`.
* `xattr=nosys`: Tells the kernel to reject all `xattr` requests.
* Defaults to `passthrough`.
Runtime extended attribute support can be managed via the `xattr`
option. By default it will passthrough any xattr calls. Given xattr
support is rarely used and can have significant performance
implications mergerfs allows it to be disabled at runtime. The
performance problems mostly comes when file caching is enabled. The
kernel will send a `getxattr` for `security.capability` *before every
single write*. It doesn't cache the responses to any `getxattr`. This
might be addressed in the future but for now mergerfs can really only
offer the following workarounds.
`noattr` will cause mergerfs to short circuit all xattr calls and
return ENOATTR where appropriate. mergerfs still gets all the requests
but they will not be forwarded on to the underlying filesystems. The
runtime control will still function in this mode.
`nosys` will cause mergerfs to return `ENOSYS` for any xattr call. The
difference with `noattr` is that the kernel will cache this fact and
itself short circuit future calls. This is more efficient than
`noattr` but will cause mergerfs' runtime control via the hidden file
to stop working.
+52
View File
@@ -0,0 +1,52 @@
# Error Handling and Logging
## Error Handling
POSIX filesystem functions offer a single return code meaning that
there is some complication regarding the handling of multiple branches
as mergerfs does. It tries to handle errors in a way that would
generally return meaningful values for that particular function.
### chmod, chown, removexattr, setxattr, truncate, utimens
1. if no error: return 0 (success)
2. if no successes: return first error
3. if one of the files acted on was the same as the related search function: return its value
4. return 0 (success)
While doing this increases the complexity and cost of error handling,
particularly step 3, this provides probably the most reasonable return
value.
### unlink, rmdir
1. if no errors: return 0 (success)
2. return first error
Older versions of mergerfs would return success if any success occurred
but for unlink and rmdir there are downstream assumptions that, while
not impossible to occur, can confuse some software.
### others
For search functions, there is always a single thing acted on and as
such whatever return value that comes from the single function call is
returned.
For create functions `mkdir`, `mknod`, and `symlink` which don't
return a file descriptor and therefore can have `all` or `epall`
policies it will return success if any of the calls succeed and an
error otherwise.
## Logging
Filesystems, and therefore mergerfs, are doing lots of small actions
at high speed. It simply isn't reasonable to log all the actions of
the system. That said: certain details are logged at startup and when
performing mainance tasks. These are logged via `syslog` and on
`systemd` based systems can be viewed by running
```
journalctl -t mergerfs
```
@@ -0,0 +1,90 @@
# Compatibility and Integration
## Can I use mergerfs without SnapRAID? SnapRAID without mergerfs?
Yes. They are completely unrelated pieces of software that just happen
to work well together.
## Does mergerfs support CoW / copy-on-write / writes to read-only filesystems?
Not in the sense of a filesystem like BTRFS or ZFS nor in the
overlayfs or aufs sense. It does offer a
[cow-shell](http://manpages.ubuntu.com/manpages/bionic/man1/cow-shell.1.html)
like hard link breaking (copy to temp file then rename over original)
which can be useful when wanting to save space by hardlinking
duplicate files but wish to treat each name as if it were a unique and
separate file.
If you want to write to a read-only filesystem you should look at
overlayfs. You can always include the overlayfs mount into a mergerfs
pool.
## Can mergerfs run via Docker, Podman, Kubernetes, etc.
Yes. With Docker you'll need to include `--cap-add=SYS_ADMIN
--device=/dev/fuse --security-opt=apparmor:unconfined` or similar with
other container runtimes. You should also be running it as root or
given sufficient caps to allow mergerfs to change user and group
identity as well as have root like filesystem permissions. This
ability is critical to how mergerfs works.
Also, as mentioned by [hotio](https://hotio.dev/containers/mergerfs),
with Docker you should probably be mounting with `bind-propagation`
set to `slave`.
## How does mergerfs interact with user namespaces?
FUSE does not have any special integration with Linux user namespaces
used by container runtime platforms like Docker, Podman, etc. The
uid/gid values passed to mergerfs will be the host level values rather
than that seen inside the container. Meaning `root` in a container
with user namespaces configured will not be `root` to mergerfs. Same
with any other uid/gid. Meaning your permissions on your branches must
work with the translated values from the id mapping.
It is generally recommended to not use user namespacing / id mapping
given the complication it introduces.
## Can mergerfs be used with NFS root squash?
If mergerfs is pooling a NFS mount then root squash should be disabled
as mergerfs needs to be able to have elevated privilages to do what it
does.
If you are exporting mergerfs over NFS then it is not really necessary.
See the [section on remote filesystems.](../remote_filesystems.md)
## Does inotify and fanotify work?
Yes. You can test by using
[inotifywait](https://man7.org/linux/man-pages/man1/inotifywait.1.html) or
[inotifywatch](https://man7.org/linux/man-pages/man1/inotifywatch.1.html).
However, you can not get notifications for events that occur outside
of the mergerfs mount. For instance if you are doing
[out-of-band](usage_and_functionality.md#can-filesystems-be-removed-from-the-pool-without-affecting-them)
changes it is not possible to get those events forwarded through
mergerfs. FUSE offers no mechanism to publish events and even if it
did it would require somewhat expensive
[inotify](https://man7.org/linux/man-pages/man7/inotify.7.html) or
[fanotify](https://man7.org/linux/man-pages/man7/fanotify.7.html)
watches on all branches.
Most software which has the ability to actively monitor a filesystem
(such as Plex, Emby, Jellyfin, Airsonic, etc.) are using `inotify` or
`fanotify`.
If you must add content out-of-band the only way to get real-time
updates (via inotify or fanotify) is to add the underlying branches to
the software rather than using the mergerfs mount. An alternative is
to enable regular library scanning. Plex, for instance, has "Scan my
library periodically". Additionally, if you are using software such as
Radarr, Sonarr, or Lidarr you can configure it to trigger library
updates in a number of services. This can be found under `Settings >
Connect`.
@@ -0,0 +1,106 @@
# Configuration and Policies
## What settings should I use?
Depends on what features you want. Generally, there are no "good",
"bad", "inefficient", or "optimal" settings. Options are almost
exclusively functional. Meaning they change the behavior of the
software. It is best to read over the available options and choose
what fits your use case. If something is not clear from the
documentation please reach out and the documentation will be improved.
The settings described in the [Quick Start](../quickstart.md) are
sufficient for most users.
Filesystems are complex and use cases numerous. There simply is no way
to provide a singular setup that works for all situations. Since
mergerfs [does not impact](usage_and_functionality.md) the underlying
filesystems and can be added or removed without any impact it is
extremely easy to test and experiment with different settings.
## How can I ensure files are collocated on the same branch?
Many people like the idea of ensuring related files, such as all the
files to a TV show season or songs in an album, are stored on the same
storage device. However, most people have no actual need for this
behavior.
1. If you backup your data it is extremely likely your backup solution
can restore only those files you are missing.
2. Software such as **Sonarr** can manage the downloading and post
processing of bespoke episodes which may be missing in a
season. Either by downloading the episode individually if available
or by downloading a full season.
3. There is no benefit to keeping files collocated with regard to
drive spinup, caching, or other secondary concern.
The main use case for wanting collocation is where the branch is going
to be removed from the pool and you wish to have all data from some
logical set on that device. Such as you intend to take a drive out of
the pool to take on a trip and want a whole show on the
drive. However, even in these situations you typically end up needing
to curate the files anyway because it has show A but not show B.
All that said you can accomplish collocation to varying degrees using
the following methods:
1. Use
[mergerfs.consolidate](https://github.com/trapexit/mergerfs-tools/blob/master/src/mergerfs.consolidate)
when consolidation is needed.
2. Use a `msp` create policy.
3. Use `epmfs` or other `ep` create policy and manually create paths
on the branches directly.
4. Use a `ep` `create` policy and `rand` for `mkdir`.
## How can I balance files across the pool?
Similar to collocation there is generally little reason to balance
files.
1. Since prediction of a filesystem's death or loss of data is near
impossible there is little reason to balance in hopes of limiting
data loss.
2. While performance could be impacted by having too much reading or
writing happen to singular underlying filesystems balancing won't
help unless you have the ability to manage the access patterns to
the pool.
3. Over time most configurations will lead to a random distribution of
files across the branches which is effectively "balancing."
If you wish to move files around or balance the pool you can:
1. Use `rand` or `pfrd` create policies and just use your system as
normal.
2. Write simple scripts using rsync or similar to move files around as
you wish.
3. Use
[mergerfs.balance](https://github.com/trapexit/mergerfs-tools/blob/master/src/mergerfs.balance). Keep
in mind that this tool is really just an example of how to
accomplish such a task.
## Why are all my files ending up on 1 filesystem?!
Did you start with empty filesystems? Did you explicitly configure a
`category.create` policy? Are you using an `existing path` / `path
preserving` policy?
The default create policy is `epmfs`. That is a path preserving
algorithm. With such a policy for `mkdir` and `create` with a set of
empty filesystems it will select only 1 filesystem when the first
directory is created. Anything, files or directories, created in that
directory will be placed on the same branch because it is preserving
paths.
This may catch new users off guard but this policy is the safest
policy to start with as it will not change the general layout of the
underlying filesystems. If you do not care about path preservation
(most shouldn't) and wish your files to be spread across all your
filesystems change to `rand`, `pfrd`, `mfs` or similar
[policy](../config/functions_categories_and_policies.md). If you do
want path preservation you'll need to perform the manual act of
creating paths on the filesystems you want the data to land on before
writing said data.
+79
View File
@@ -0,0 +1,79 @@
# Limiting drive spinup
## How can I setup my system to limit drive spinup?
TL;DR: You really can't. Not through mergerfs alone. In fact mergerfs
makes an attempt to do so more complicated.
mergerfs is a proxy. Despite having some caching behaviors it is not
designed to cache much more than metadata. It proxies calls between
client software and underlying filesystems. If a client makes a
request such as `open`, `readdir`, `stat`, etc. it must translate that
into something that makes sense across multiple filesystems. For
`readdir` that means running the call against all branches and
aggregating the output. For `open` that means finding the file to open
and doing so. The only way to find the file to open is to scan across
all branches and sort the results and pick one. There is no practical
way to do otherwise. Especially given so many mergerfs users expect
out-of-band changes to "just work."
The best way to limit spinup of drives is to limit their usage at the
client level. Meaning keeping software from interacting with the
filesystem (and therefore the drive) all together.
### What if you assume no out-of-band changes and cache everything?
This would require a significant rewrite of mergerfs. Everything is
done on the fly right now and all those calls to underlying
filesystems can cause a spinup. To work around that a database of some
sort would have to be used to store ALL metadata about the underlying
filesystems and on startup everything scanned and stored. From then on
it would have to carefully update all the same data the filesystems
do. It couldn't be kept in RAM because it would take up too much space
so it'd have to be on a SSD or other storage device. If anything
changed out of band it would break things in weird ways. It could
rescan on occasion but that would require spinning up
everything. Filesystem watches could be used to get updates when the
filesystem changes but that would allow for race conditions and
might keep the drives from spinning down. Something as "simple" as
keeping the current available free space on each filesystem isn't as
easy as one might think given reflinks, snapshots, and other block
level dedup technologies as well as the space used includes not just
raw file usage.
Even if all metadata (including xattrs) is cached some software will
open files (media like videos and audio) to check their
metadata. Granted a Plex or Jellyfin scan which may do that is
different from a random directory listing but is still something to
consider. Those "deep" scans can't be kept from waking drives.
### What if you only query already active drives?
Let's assume that is plausible (it isn't because some drives actually
will spin up if you ask if they are spun down... yes... really) you
would have to either cache all the metadata on the filesystem or treat
it like the filesystem doesn't exist. The former has all the problems
mentioned prior and the latter would break a lot of things.
### Is there anything that can be done where mergerfs is involved?
Yes, but whether it works for you depends on your tolerance for the
complexity.
1. Cleanly separate writing, storing, and consuming the data.
1. Use a SSD or dedicated and limited pool of drives for downloads / torrents.
2. When downloaded move the files to the primary storage pool.
3. When setting up software like Plex, Jellyfin, etc. point to the
underlying filesystems. Not mergerfs.
2. Add a bunch of bcache, lvmcache, dm-cache, or similar block level
cache to your setup. After a bit of use, assuming sufficient
storage space, you can limit the likelihood of the underlying
spinning disks from needing to be hit.
Remember too that while it may be a tradeoff you are willing to live
with there is decent evidence that spinning down drives puts increased
wear on them and can lead to their death earlier than otherwise.
@@ -0,0 +1,49 @@
# Recommendations and Warnings
## What should mergerfs NOT be used for?
- databases: Even if the database stored data in separate files
(mergerfs wouldn't offer much otherwise) the higher latency of the
indirection will really harm performance. If it is a lightly used
sqlite3 database then it should be fine.
- VM images: For the same reasons as databases. VM images are accessed
very aggressively and mergerfs will introduce a lot of extra latency.
- As replacement for RAID: mergerfs is just for pooling branches. If
you need that kind of device performance aggregation or high
availability you should stick with RAID. However, it is fine to put
a filesystem which is on a RAID setup in mergerfs.
## It's mentioned that there are some security issues with mhddfs. What are they? How does mergerfs address them?
[mhddfs](https://github.com/trapexit/mhddfs) manages running as
`root` by calling
[getuid()](https://github.com/trapexit/mhddfs/blob/cae96e6251dd91e2bdc24800b4a18a74044f6672/src/main.c#L319)
and if it returns `0` then it will
[chown](http://linux.die.net/man/1/chown) the file. Not only is that a
race condition but it doesn't handle other situations. Rather than
attempting to simulate POSIX ACL behavior the proper way to manage
this is to use [seteuid](http://linux.die.net/man/2/seteuid) and
[setegid](http://linux.die.net/man/2/setegid), in effect, becoming the
user making the original call, and perform the action as them. This is
what mergerfs does and why mergerfs should always run as root.
In Linux setreuid syscalls apply only to the thread. glibc hides this
away by using realtime signals to inform all threads to change
credentials. Taking after Samba, mergerfs uses
`syscall(SYS_setreuid,...)` to set the callers credentials for that
thread only. Jumping back to `root` as necessary should escalated
privileges be needed (for instance: to clone paths between
filesystems).
For non-Linux systems, mergerfs uses a read-write lock and changes
credentials only when necessary. If multiple threads are to be user X
then only the first one will need to change the processes
credentials. So long as the other threads need to be user X they will
take a readlock allowing multiple threads to share the
credentials. Once a request comes in to run as user Y that thread will
attempt a write lock and change to Y's credentials when it can. If the
ability to give writers priority is supported then that flag will be
used so threads trying to change credentials don't starve. This isn't
the best solution but should work reasonably well assuming there are
few users.
@@ -0,0 +1,41 @@
# Reliability and Scalability
## Is mergerfs "production ready?"
Yes.
mergerfs has been around for over a decade and used by many users on
their systems. Typically running 24/7 with constant load.
At least a few companies are believed to use mergerfs in production
environments. A number of [NAS focused operating
systems](../related_projects.md) includes mergerfs as a solution for
pooling filesystems.
Most serious issues (crashes or data corruption) have been due to
[kernel bugs](../known_issues_bugs.md#fuse-and-linux-kernel). All of
which are fixed in stable releases.
## How well does mergerfs scale?
Users have reported running mergerfs on everything from OpenWRT
routers and Raspberry Pi SBCs to multi-socket Xeon enterprise servers.
Users have pooled everything from USB thumb drives to enterprise NVME
SSDs to remote filesystems and rclone mounts.
The cost of many calls can be `O(n)` meaning adding more branches to
the pool will increase the cost of certain functions, such as reading
directories or finding files to open, but there are a number of caches
and strategies in place to limit overhead where possible.
## Are there any limits?
There is no maximum capacity beyond what is imposed by the operating
system itself. Any limit is practical rather than technical. As
explained in the question about scale mergerfs is mostly limited by
the tolerated cost of aggregating branches and the cost associated
with interacting with them. If you pool slow network filesystem then
that will naturally impact performance more than low latency SSDs.
@@ -0,0 +1,239 @@
# Technical Behavior and Limitations
## Do hardlinks work?
Yes. See also the option `inodecalc` for how inode values are
calculated.
What mergerfs does not do is fake hard links across branches. Read
the section "rename & link" for how it works.
Remember that hardlinks will NOT work across devices. That includes
between the original filesystem and a mergerfs pool, between two
separate pools of the same underlying filesystems, or bind mounts of
paths within the mergerfs pool. The latter is common when using Docker
or Podman. Multiple volumes (bind mounts) to the same underlying
filesystem are considered different devices. There is no way to link
between them. You should mount in the highest directory in the
mergerfs pool that includes all the paths you need if you want links
to work.
## How does mergerfs handle moving and copying of files?
This is a _very_ common mistaken assumption regarding how filesystems
work. There is no such thing as "move" or "copy." These concepts are
high level behaviors made up of numerous independent steps and _not_
individual filesystem functions.
A "move" can include a "copy" so lets describe copy first.
When an application copies a file from source to destination it can do
so in a number of ways but the basics are the following.
1. `open` the source file.
2. `create` the destination file.
3. `read` a chunk of data from source and `write` to
destination. Continue till it runs out of data to copy.
4. Copy file metadata (`stat`) such as ownership (`chown`),
permissions (`chmod`), timestamps (`utimes`), extended attributes
(`getxattr`, `setxattr`), etc.
5. `close` source and destination files.
"move" is typically a `rename(src,dst)` and if that errors with
`EXDEV` (meaning the source and destination are on different
filesystems) the application will "copy" the file as described above
and then it removes (`unlink`) the source.
The `rename(src,dst)`, `open(src)`, `create(dst)`, data copying,
metadata copying, `unlink(src)`, etc. are entirely distinct and
separate events. There is really no practical way to know that what is
ultimately occurring is the "copying" of a file or what the source
file would be. Since the source is not known there is no way to know
how large a created file is destined to become. This is why it is
impossible for mergerfs to choose the branch for a `create` based on
file size. The only context provided when a file is created, besides
the name, is the permissions, if it is to be read and/or written, and
some low level settings for the operating system.
All of this means that mergerfs can not make decisions when a file is
created based on file size or the source of the data. That information
is simply not available. At best mergerfs could respond to files
reaching a certain size when writing data or when a file is closed.
Related: if a user wished to have mergerfs perform certain activities
based on the name of a file it is common and even best practice for a
program to write to a temporary file first and then rename to its
final destination. That temporary file name will typically be random
and have no indication of the type of file being written.
## Does FICLONE or FICLONERANGE work?
Unfortunately not. FUSE, the technology mergerfs is based on, does not
support the `clone_file_range` feature needed for it to work. mergerfs
won't even know such a request is made. The kernel will simply return
an error back to the application making the request.
Should FUSE gain the ability mergerfs will be updated to support it.
## Why do I get an "out of space" / "no space left on device" / ENOSPC error even though there appears to be lots of space available?
First make sure you've read the sections above about policies, path
preservation, branch filtering, and the options **minfreespace**,
**moveonenospc**, **statfs**, and **statfs_ignore**.
mergerfs is simply presenting a union of the content within multiple
branches. The reported free space is an aggregate of space available
within the pool (behavior modified by **statfs** and
**statfs_ignore**). It does not represent a contiguous space. In the
same way that read-only filesystems, those with quotas, or reserved
space report the full theoretical space available.
Due to path preservation, branch tagging, read-only status, and
**minfreespace** settings it is perfectly valid that `ENOSPC` / "out
of space" / "no space left on device" be returned. It is doing what
was asked of it: filtering possible branches due to those
settings. Only one error can be returned and if one of the reasons for
filtering a branch was **minfreespace** then it will be returned as
such. **moveonenospc** is only relevant to writing a file which is too
large for the filesystem it's currently on.
It is also possible that the filesystem selected has run out of
inodes. Use `df -i` to list the total and available inodes per
filesystem.
If you don't care about path preservation then simply change the
`create` policy to one which isn't. `mfs` is probably what most are
looking for. The reason it's not default is because it was originally
set to `epmfs` and changing it now would change people's setup. Such a
setting change will likely occur in mergerfs 3.
## Why does the total available space in mergerfs not equal outside?
Are you using ext2/3/4? With reserve for root? mergerfs uses available
space for statfs calculations. If you've reserved space for root then
it won't show up.
You can remove the reserve by running: `tune2fs -m 0 <device>`
## I notice massive slowdowns of writes when enabling cache.files.
When file caching is enabled in any form (`cache.files!=off`) it will
issue `getxattr` requests for `security.capability` prior to _every
single write_. This will usually result in performance degradation,
especially when using a network filesystem (such as NFS or SMB.)
Unfortunately at this moment, the kernel is not caching the response.
To work around this situation mergerfs offers a few solutions.
1. Set `security_capability=false`. It will short circuit any call and
return `ENOATTR`. This still means though that mergerfs will
receive the request before every write but at least it doesn't get
passed through to the underlying filesystem.
2. Set `xattr=noattr`. Same as above but applies to _all_ calls to
getxattr. Not just `security.capability`. This will not be cached
by the kernel either but mergerfs' runtime config system will still
function.
3. Set `xattr=nosys`. Results in mergerfs returning `ENOSYS` which
_will_ be cached by the kernel. No future xattr calls will be
forwarded to mergerfs. The downside is that also means the xattr
based config and query functionality won't work either.
4. Disable file caching. If you aren't using applications which use
`mmap` it's probably simpler to just disable it altogether. The
kernel won't send the requests when caching is disabled.
## Why can't I see my files / directories?
It's almost always a permissions issue. Unlike mhddfs and
unionfs-fuse, which runs as root and attempts to access content as
such, mergerfs always changes its credentials to that of the
caller. This means that if the user does not have access to a file or
directory than neither will mergerfs. However, because mergerfs is
creating a union of paths it may be able to read some files and
directories on one filesystem but not another resulting in an
incomplete set.
Whenever you run into a split permission issue (seeing some but not
all files) try using
[mergerfs.fsck](https://github.com/trapexit/mergerfs-tools) tool to
check for and fix the mismatch. If you aren't seeing anything at all
be sure that the basic permissions are correct. The user and group
values are correct and that directories have their executable bit
set. A common mistake by users new to Linux is to `chmod -R 644` when
they should have `chmod -R u=rwX,go=rX`.
If using a network filesystem such as NFS or SMB (Samba) be sure to
pay close attention to anything regarding permissioning and
users. Root squashing and user translation for instance has bitten a
few mergerfs users. Some of these also affect the use of mergerfs from
container platforms such as Docker.
## Why use FUSE? Why not a kernel based solution?
As with any solution to a problem, there are advantages and
disadvantages to each one.
A FUSE based solution has all the downsides of FUSE:
- Higher IO latency due to the trips in and out of kernel space
- Higher general overhead due to trips in and out of kernel space
- Double caching when using page caching
- Misc limitations due to FUSE's design
But FUSE also has a lot of upsides:
- Easier to offer a cross platform solution
- Easier forward and backward compatibility
- Easier updates for users
- Easier and faster release cadence
- Allows more flexibility in design and features
- Overall easier to write, secure, and maintain
- Much lower barrier to entry (getting code into the kernel takes a
lot of time and effort initially)
## Is my OS's libfuse needed for mergerfs to work?
No. Normally `mount.fuse` is needed to get mergerfs (or any FUSE
filesystem to mount using the `mount` command but in vendoring the
libfuse library the `mount.fuse` app has been renamed to
`mount.mergerfs` meaning the filesystem type in `fstab` can simply be
`mergerfs`. That said there should be no harm in having it installed
and continuing to using `fuse.mergerfs` as the type in `/etc/fstab`.
If `mergerfs` doesn't work as a type it could be due to how the
`mount.mergerfs` tool was installed. Must be in `/sbin/` with proper
permissions.
## Why was splice support removed?
After a lot of testing over the years, splicing always appeared to
at best, provide equivalent performance, and in some cases, worse
performance. Splice is not supported on other platforms forcing a
traditional read/write fallback to be provided. The splice code was
removed to simplify the codebase.
## How does mergerfs handle credentials?
mergerfs is a multithreaded application in order to handle requests
from the kernel concurrently. Each FUSE message has a header with
certain details about the request include the process ID (pid) of the
requestion application, the process' effective user id (uid), and
group id (gid). To ensure proper POSIX filesystem behavior and
security mergerfs must change its identity to match that of the
requester when performing the core filesystem function on the
underlying filesystem. On most Unix/POSIX based system a process and
all its threads are under the same uid and gid. However, on Linux each
thread may have its own credentials. This allows mergerfs to be
multithreaded and for each thread to change to the credentials
(seteuid,setegid) as required by the incoming message it is
handling. However, on FreeBSD this is not possible at the moment
(though there has been
[discussions](https://wiki.freebsd.org/Per-Thread%20Credentials) and
as such must change the credentials of the whole application when
actioning messages. mergerfs does optimize this behavior by only
changing credentials and locking the thread to do so if the process is
currently not the same as what is necessary by the incoming request.
@@ -0,0 +1,84 @@
# Usage and Functionality
## Can mergerfs be used with filesystems which already have data?
Yes. mergerfs is really just a proxy and does **NOT** interfere with
the normal form or function of the filesystems, mounts, or paths it
manages. It literally is interacting with your filesystems as any
other application does. It can not do anything that any other random
piece of software can't do.
mergerfs is **not** a traditional filesystem that takes control over
the underlying disk or block device. mergerfs is **not** RAID. It does
**not** manipulate the data that passes through it. It does **not**
shard data across filesystems. It only shards some **behavior** and
aggregates others.
## Can filesystems be removed from the pool without affecting them?
Yes. See previous question's answer.
## Can mergerfs be removed without affecting the data?
Yes. See the previous question's answer.
## Can filesystems be moved to another pool?
Yes. See the previous question's answer.
## Can filesystems be part of multiple pools?
Yes.
## How do I migrate data into or out of the pool when adding/removing filesystems?
There is no need to do so. See the previous questions.
## How do I remove a filesystem but keep the data in the pool?
Nothing special needs to be done. Remove the branch from mergerfs'
config and copy (rsync) the data from the removed filesystem into the
pool. The same as if it were you transferring data from one filesystem
to another.
If you wish to continue using the pool with all data available while
performing the transfer simply create a temporary pool without the
branch in question and then copy the data from the branch to the
temporary pool. It would probably be a good idea to set the branch
mode to `RO` prior to doing this to ensure no new content is written
to the filesystem while performing the copy. However, it is typically
good practice to run rsync or rclone again after the first copy
finishes to ensure nothing is left behind.
NOTE: Above recommends to "copy" rather than "move" because you want
to ensure that your data is transferred before wiping the drive or
filesystem.
## Can filesystems still be used directly? Outside of mergerfs while pooled?
Yes, [out-of-band](https://en.wikipedia.org/wiki/Out-of-band)
interaction is generally fine. Remember that mergerfs is a userland
application so any interaction with the underlying filesystem is the
same as multiple normal applications interacting. However, it is not
recommended to write to the same file from within the pool and from
without at the same time. Especially if using page caching
(`cache.files!=off`) or writeback caching
(`cache.writeback=true`). That said this risk is really not different
from the risk of two applications writing to the same file under
normal conditions.
Keep in mind that if out-of-band changes are made while also
leveraging any caching of the filesystem layout such as with
`cache.entry`, `cache.negative_entry`, `cache.attr`, `cache.symlinks`,
or `cache.readdir` you may experience temporary inconsistency till the
cache expires. mergerfs is not actively watching all branches for
changes and the kernel will have no way to know anything changed so as
to clear or ignore the cache. This is the same issue you can have with
[remote filesystems](../remote_filesystems.md).
+79
View File
@@ -0,0 +1,79 @@
# mergerfs - a featureful union filesystem
**mergerfs** is a
[FUSE](https://en.wikipedia.org/wiki/Filesystem_in_Userspace) based
[union filesystem](https://en.wikipedia.org/wiki/Union_mount) geared
towards simplifying storage and management of files across numerous
commodity storage devices. It is similar to **mhddfs**, **unionfs**,
and **aufs**.
## Features
* Logically combine numerous filesystems/paths into a single
mount point
* Combine paths of the same or different filesystems
* Ability to add or remove filesystems/paths without impacting the
rest of the data
* Unaffected by individual filesystem failure
* Configurable file selection and creation placement
* Works with filesystems of any size
* Works with filesystems of almost any type
* Ignore read-only filesystems when creating files
* Hard link copy-on-write / CoW
* Runtime configurable
* Support for extended attributes (xattrs)
* Support for file attributes (chattr)
* Support for POSIX ACLs
## Non-features
* Read/write overlay on top of read-only filesystem like OverlayFS
* File whiteout
* RAID like parity calculation
* Redundancy
* Splitting of files across branches
## How it works
mergerfs logically merges multiple filesystem paths together. It acts
as a proxy to the underlying filesystem paths. Combining the behaviors
of some functions and being a selector for others.
When the contents of a directory are requested mergerfs combines the
list of files from each directory, deduplicating entries, and returns
that list.
When a file or directory is created a policy is first run to determine
which branch will be selected for the creation.
For functions which change attributes or remove the file the behavior
may be applied to all instances found.
Read more about [policies
here](config/functions_categories_and_policies.md).
### Visualization
```
A + B = C
/disk1 /disk2 /merged
| | |
+-- /dir1 +-- /dir1 +-- /dir1
| | | | | |
| +-- file1 | +-- file2 | +-- file1
| | +-- file3 | +-- file2
+-- /dir2 | | +-- file3
| | +-- /dir3 |
| +-- file4 | +-- /dir2
| +-- file5 | |
+-- file6 | +-- file4
|
+-- /dir3
| |
| +-- file5
|
+-- file6
```
+271
View File
@@ -0,0 +1,271 @@
# Known Issues and Bugs
## mergerfs
### Supplemental user groups
Due to the overhead of
[getgroups/setgroups](http://linux.die.net/man/2/setgroups) mergerfs
utilizes a cache. This cache is opportunistic and per thread. Each
thread will query the supplemental groups for a user when that
particular thread needs to change credentials and will keep that data
for the lifetime of the thread. This means that if a user is added to
a group it may not be picked up without the restart of
mergerfs. In the future this may be improved to allow a periodic or
manual clearing of the cache.
While not a bug some users have found when using containers that
supplemental groups defined inside the container don't work as
expected. Since mergerfs lives outside the container it is querying
the host's group database. Effectively containers have their own user
and group definitions unless setup otherwise just as different systems
would.
Users should mount in the host group file into the containers or use a
standard shared user & groups technology like NIS or LDAP.
### directory mtime is not being updated
Remember that the default policy for `getattr` is `ff`. The
information for the first directory found will be returned. If it
wasn't the directory which had been updated then it will appear
outdated.
The reason this is the default is because any other policy would be
more expensive and for many applications it is unnecessary. To always
return the directory with the most recent mtime or a faked value based
on all found would require a scan of all filesystems.
If you always want the directory information from the one with the
most recent mtime then use the `newest` policy for `getattr`.
### 'mv /mnt/pool/foo /mnt/disk1/foo' removes 'foo'
This is not a bug.
Run in verbose mode to better understand what's happening:
```
$ mv -v /mnt/pool/foo /mnt/disk1/foo
copied '/mnt/pool/foo' -> '/mnt/disk1/foo'
removed '/mnt/pool/foo'
$ ls /mnt/pool/foo
ls: cannot access '/mnt/pool/foo': No such file or directory
```
`mv`, when working across devices, is copying the source to target and
then removing the source. Since the source **is** the target in this
case, depending on the unlink policy, it will remove the just copied
file and other files across the branches.
If you want to move files to one filesystem just copy them there and
use mergerfs.dedup to clean up the old paths or manually remove them
from the branches directly.
### cached memory appears greater than it should be
Use `cache.files=off` and/or `dropcacheonclose=true`. See the section
on [page caching](config/cache.md).
### NFS clients returning ESTALE / Stale file handle
NFS generally does not like out of band changes. Take a look at the
section on NFS in the [remote-filesystems](remote_filesystems.md) for
more details.
### rtorrent fails with ENODEV (No such device)
Be sure to set
[cache.files=partial|full|auto-full|per-process](config/cache.md)
or use Linux kernel v6.6 or above. rtorrent and some other
applications use [mmap](http://linux.die.net/man/2/mmap) to read and
write to files and offer no fallback to traditional methods.
### Plex / Jellyfin doesn't work with mergerfs
It does. If you're trying to put the software's config / metadata /
database on mergerfs you can't set
[cache.files=off](config/cache.md) (unless you use Linux v6.6 or
above) because Plex is using **sqlite3** with **mmap** enabled.
That said it is recommended that config and runtime files be stored on
SSDs on a regular filesystem for performance reasons and if you are
using HDDs in your pool to help limit spinup.
Other software that leverages **sqlite3** which require **mmap**
includes Radarr, Sonarr, Lidarr.
It is recommended that you reach out to the developers of the software
you're having troubles with and asking them to add a fallback to
regular file IO when **mmap** is unavailable. It is not only more
compatible and resilient but also can be more performant in certain
situations.
If the issue is that quick scanning doesn't seem to pick up media then
be sure to set `func.getattr=newest`, though generally, a full scan
will pick up all media anyway.
### When a program tries to move or rename a file it fails
Please read the docs regarding [rename and
link](config/rename_and_link.md).
The problem is that many applications do not properly handle `EXDEV`
errors which `rename` and `link` may return even though they are
perfectly valid situations which do not indicate actual device,
filesystem, or OS errors. The error will only be returned by mergerfs
if using a path preserving policy as described in the policy section
above. If you do not care about path preservation simply change the
mergerfs policy to the non-path preserving version. For example: `-o
category.create=mfs` Ideally the offending software would be fixed and
it is recommended that if you run into this problem you contact the
software's author and request proper handling of `EXDEV` errors.
### my 32bit software has problems
Some software have problems with 64bit inode values. The symptoms can
include EOVERFLOW errors when trying to list files. You can address
this by setting `inodecalc` to one of the 32bit based algos as
described in the relevant section.
### Moving files and directories fails with Samba
Workaround: Copy the file/directory and then remove the original
rather than move.
This isn't an issue with Samba but some SMB clients. GVFS-fuse v1.20.3
and prior (found in Ubuntu 14.04 among others) failed to handle
certain error codes correctly. Particularly `STATUS_NOT_SAME_DEVICE`
which comes from the `EXDEV` that is returned by `rename` when the
call is crossing mount points. When a program gets an `EXDEV` it needs
to explicitly take an alternate action to accomplish its goal. In the
case of `mv` or similar it tries `rename` and on `EXDEV` falls back to
a copying the file to the destination and deleting the source. In
these older versions of GVFS-fuse if it received `EXDEV` it would
translate that into `EIO`. This would cause `mv` or most any
application attempting to move files around on that SMB share to fail
with a generic IO error.
[GVFS-fuse v1.22.0](https://bugzilla.gnome.org/show_bug.cgi?id=734568)
and above fixed this issue but a large number of systems use the older
release. On Ubuntu, the version can be checked by issuing `apt-cache
showpkg gvfs-fuse`. Most distros released in 2015 seem to have the
updated release and will work fine but older systems may
not. Upgrading gvfs-fuse or the distro in general will address the
problem.
In Apple's MacOSX 10.9 they replaced Samba (client and server) with
their own product. It appears their new client does not handle
`EXDEV` either and responds similarly to older releases of gvfs on
Linux.
### Trashing files occasionally fails
This is the same issue as with Samba. `rename` returns `EXDEV` (in our
case that will really only happen with path preserving policies like
`epmfs`) and the software doesn't handle the situation well. This is
unfortunately a common failure of software which moves files
around. The standard indicates that an implementation **MAY** choose
to support non-user home directory trashing of files (which is a
**MUST**). The implementation **MAY** also support "top directory
trashes" which many probably do.
To create a `$topdir/.Trash` directory as defined in the standard use
the [mergerfs-tools](https://github.com/trapexit/mergerfs-tools) tool
`mergerfs.mktrash`.
## FUSE and Linux kernel
There have been a number of kernel issues / bugs over the years which
mergerfs has run into. Here is a list of them for reference and
posterity.
### NFS and EIO errors
[https://lore.kernel.org/linux-fsdevel/20240228160213.1988854-1-mszeredi@redhat.com/T/](https://lore.kernel.org/linux-fsdevel/20240228160213.1988854-1-mszeredi@redhat.com/T/)
Over the years some users have reported that while exporting mergerfs
via NFS, after significant filesystem activity, not only will the NFS
client start returning ESTALE and EIO errors but mergerfs itself would
start returning EIO errors. The problem was that no one could
reliability reproduce the issue. After a string of reports in late
2023 and early 2024 more investigation was done.
In Linux 5.14 new validation was put into FUSE which caught a few
invalid situations and would tag a FUSE node as invalid if a check
failed. Such checks include invalid file type, changing of type from
one request to another, a size greater than 63bit, and the generation
of a inode changing while in use.
What happened was that mergerfs was using a different fixed, non-zero
value for the generation of all nodes as it was suggested that unique
inode + generation pairs are needed for proper integration with
NFS. That non-zero value was being sent back to the kernel when a
lookup request was made for root. The reason this was hard to track
down was because NFS almost uniquely uses an API which can lead to a
lookup of the root node that simply won't happen under normal
workloads and usage. And that lookup will only happen if child nodes
of the root were forgotten but NFS still had a handle to that node and
later asked for details about it. It would trigger a set of requests
to lookup info on those nodes.
This wasn't a bug in FUSE but mergerfs. However, the incorrect
behavior of mergerfs lead to FUSE behave in an unexpected and
incorrect manner. It would issue a lookup of the "parent of a child of
the root" and mergerfs would send the invalid generation value. As a
result the kernel would mark the root node as "bad" which would then
trigger the kernel to issue a "forget root" message. In between those
it would issue a request for the parent of the root... which doesn't
exist.
So the kernel was doing two invalid things. Requesting the parent of
the root and then when that failed issuing a forget for the
root. These led to chasing after the wrong possible causes.
The change was for FUSE to revert the marking of root node bad if the
generation is non-zero and warn about it. It will mark the node bad
but not unhash/forget/remove it.
mergerfs in v2.40.1 ensures that generation for root is always 0 on
lookup which should work across any kernel version.
### Truncated files
This was a bug with `mmap` and `FUSE` on 32bit platforms. Should be fixed in all LTS releases.
* [https://marc.info/?l=linux-fsdevel&m=155550785230874&w=2](https://marc.info/?l=linux-fsdevel&m=155550785230874&w=2)
### Crashing on OpenVZ
There was a bug in the OpenVZ kernel with regard to how it handles `ioctl` calls. It was making invalid requests which would lead to crashes due to mergerfs not expecting them.
* [https://bugs.openvz.org/browse/OVZ-7145](https://bugs.openvz.org/browse/OVZ-7145)
* [https://www.mail-archive.com/devel@openvz.org/msg37096.html](https://www.mail-archive.com/devel@openvz.org/msg37096.html)
### Really bad mmap performance
There was a bug in caching which affects overall performance of `mmap` through `FUSE` in Linux 4.x kernels. It is fixed in 4.4.10 and 4.5.4.
* [https://lkml.org/lkml/2016/3/16/260](https://lkml.org/lkml/2016/3/16/260)
* [https://lkml.org/lkml/2016/5/11/59](https://lkml.org/lkml/2016/5/11/59)
### Heavy load and memory pressure leads to kernel panic
* [https://lkml.org/lkml/2016/9/14/527](https://lkml.org/lkml/2016/9/14/527)
* [https://lkml.org/lkml/2016/10/4/1](https://lkml.org/lkml/2016/10/4/1)
* [https://www.theregister.com/2016/10/05/linus_torvalds_admits_buggy_crap_made_it_into_linux_48/](https://www.theregister.com/2016/10/05/linus_torvalds_admits_buggy_crap_made_it_into_linux_48/)
Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

+80
View File
@@ -0,0 +1,80 @@
# Media and Publicity
## Tutorials / Articles
- 2016-02-02 - [Linuxserver.io: The Perfect Media Server 2016](https://blog.linuxserver.io/2016/02/02/the-perfect-media-server-2016/)
- 2016-08-31 - [ZackReed.me: Mergerfs – another good option to pool your SnapRAID disks](https://zackreed.me/mergerfs-another-good-option-to-pool-your-snapraid-disks/)
- 2016-11-06 - [Linuxserver.io: Revisiting the HP ProLiant Gen8 G1610T Microserver](https://blog.linuxserver.io/2016/11/06/revisiting-the-hp-proliant-gen8-g1610t-microserver/)
- 2017-01-17 - [Setting up mergerfs on JBOD's (or a poor mans storage array)](http://corywestropp.com/develop/articles/setting-up-mergerfs/)
- 2017-06-24 - [Linuxserver.io: The Perfect Media Server 2017](https://blog.linuxserver.io/2017/06/24/the-perfect-media-server-2017/)
- 2018-02-19 - [Teknophiles: Disk Pooling in Linux with mergerFS](https://web.archive.org/web/20210324184857/https://www.teknophiles.com/2018/02/19/disk-pooling-in-linux-with-mergerfs/)
- 2018-02-20 - [Fortes.com: Using Rclone and MergerFS together across drives](https://fortes.com/2018/rclone-and-mergerfs/)
- 2019-02-10 - [Medium: Migrating from ZFS to MergerFS and SnapRAID at home](https://medium.com/@pascal.brokmeier/migrating-from-zfs-to-mergerfs-and-snapraid-at-home-89c45fd5db02)
- 2019-04-24 - [MichaelXander.com: DIY NAS with OMV, SnapRAID, MergerFS, and Disk Encryption](https://michaelxander.com/diy-nas/)
- 2019-07-16 - [Linuxserver.io: The Perfect Media Server - 2019 Edition](https://blog.linuxserver.io/2019/07/16/perfect-media-server-2019/)
- 2019-09-10 - [Rclone VFS and MergerFS Setup](https://docs.usbx.me/books/rclone/page/rclone-vfs-and-mergerfs-setup)
- 2019-12-20 - [NetworkShinobi.com: SnapRAID and MergerFS on OpenMediaVault](https://www.networkshinobi.com/snapraid-and-mergerfs-on-openmediavault/)
- 2020-01-14 - [Brandon Rozek's Blog](https://brandonrozek.com/blog/mergerfs/)
- 2020-02-14 - [SelfHostedHome.com: Combining Different Sized Drives with mergerfs and SnapRAID](https://selfhostedhome.com/combining-different-sized-drives-with-mergerfs-and-snapraid/)
- 2020-05-01 - [FedoraMagazine.org: Using mergerfs to increase your virtual storage](https://fedoramagazine.org/using-mergerfs-to-increase-your-virtual-storage/)
- 2020-08-20 - [Setting up Rclone, Mergerfs and Crontab for automated cloud storage](https://bytesized-hosting.com/pages/setting-up-rclone-mergerfs-and-crontab-for-automated-cloud-storage)
- 2020-11-22 - [Introducing… MergerFS – My FREE UNRAID alternative](https://supertechfreaks.com/introducing-mergerfs-free-unraid-alternative/)
- 2020-12-30 - [Perfect Media Server](https://perfectmediaserver.com) (a new site with docs fully fleshing out the 'Perfect Media Server' blog series)
- 2021-07-24 - [Building the Ultimate Linux Home Server - Part 1: Intro, MergerFS, and SnapRAID](https://blog.karaolidis.com/ultimate-home-server-part-1/)
- 2021-10-31 - [Better Home Storage: MergerFS + SnapRAID on OpenMediaVault](https://blog.sakuragawa.moe/better-home-storage-mergerfs-snapraid-on-openmediavault/)
- 2021-11-28 - [Linux Magazine: Come Together - Merging file systems for a simple NAS with MergerFS](https://www.linux-magazine.com/Issues/2022/254/MergerFS)
- 2022-06-04 - [MergerFS + SnapRaid Study](https://crashlaker.github.io/2022/06/04/mergerfs_+_snapraid_study.html)
- 2022-12-31 - [Merge Storages in CasaOS: A secret beta feature you know now](https://blog.casaos.io/blog/13.html)
- 2023-02-03 - [(MergerFS + SnapRAID) is the new RAID 5](https://thenomadcode.tech/mergerfs-snapraid-is-the-new-raid-5)
- 2024-02-07 - [Designing & Deploying MANS - A Hybrid NAS Approach with SnapRAID, MergerFS, and OpenZFS](https://blog.muffn.io/posts/part-3-mini-100tb-nas)
- 2024-03-11 - [Using MergerFS to combine multiple hard drives into one unified media storage](https://fullmetalbrackets.com/blog/two-drives-mergerfs/)
- 2024-12-20 - [Pooling multiple drives on my Raspberry Pi with mergerfs](https://sebi.io/posts/2024-12-20-pooling-multiple-drives-with-mergerfs/)
## Videos
- 2017-06-23 - [Alex Kretzschmar: Part 1 - Perfect Media Server 2017 - Introduction](https://www.youtube.com/watch?v=L5MH8q3lmmk)
- 2017-06-24 - [Alex Kretzschmar: Part 2 - Perfect Media server 2017 - Installing Debian 9 Stretch](https://www.youtube.com/watch?v=YpVVYRN_L_A)
- 2017-06-24 - [Alex Kretzschmar: Part 3 - Perfect Media Server 2017 - Install MergerFS and setting up your drives](https://www.youtube.com/watch?v=tbCMfm-jJ5Y)
- 2017-06-24 - [Alex Kretzschmar: Part 4 - Perfect Media Server 2017 - Installing Docker](https://www.youtube.com/watch?v=WYI32kx4hPE)
- 2017-06-24 - [Alex Kretzschmar: Part 5 - Perfect Media Server 2017 - Installing and Automating SnapRAID](https://www.youtube.com/watch?v=Ir5ZsUIbHXA)
- 2017-06-24 - [Alex Kretzschmar: Part 6 - Perfect Media Server 2017 -Turning your server into a NAS with Samba and NFS](https://www.youtube.com/watch?v=1hVdWq758ZQ)
- 2017-06-24 - [Alex Kretzschmar: Part 7 - Perfect Media Server 2017 - Managing your apps with docker-compose](https://www.youtube.com/watch?v=aI2rdw7_AmE)
- 2017-06-24 - [Alex Kretzschmar: Part 8 - Perfect Media Server 2017 - Manging your server using a web UI (Cockpit and Portainer)](https://www.youtube.com/watch?v=aLyTWdzDiCg)
- 2018-04-24 - [ElectronicsWizardy: How to setup a Linux Fileserver with Snapraid and Mergerfs Re-Export](https://www.youtube.com/watch?v=D2Klx-X7pFo)
- 2019-03-01 - [Snapraid and Unionfs: Advanced Array Options on Openmediavault (Better than ZFS and Unraid)](https://www.youtube.com/watch?v=FYkdPyCt5FU)
- 2019-03-22 - [Gamexplicit: The Perfect Plex Media Server 2019! Part 1 (Hardware)](https://www.youtube.com/watch?v=rJIRPhM2WcE)
- 2019-05-13 - [Gamexplicit: The Perfect Plex Media Server 2019! Part 2 (Ubuntu Server 18.04.2 LTS)](https://www.youtube.com/watch?v=aLyTWdzDiCg)
- 2019-05-20 - [Gamexplicit: The Perfect Plex Media Server 2019! Part 3 (SnapRaid, Samba, Plex)](https://www.youtube.com/watch?v=uW5y43XC-BI)
- 2020-08-23 - [Installing OpenMediaVault and SnapRAID and UnionFS (mergerfs)](https://www.youtube.com/watch?v=nDvzXM8UjAI)
- 2021-06-07 - [I ditched TrueNAS for MergerFS - Chia Plot Storage](https://www.youtube.com/watch?v=tpqFywkbZa4)
- 2021-08-03 - [Install and configure mergerfs to merge more than one folder in the same place](https://www.youtube.com/watch?v=69zcqEy1674)
- 2021-08-10 - [Instalando e configurando mergerfs para unir mais de uma pasta no mesmo lugar](https://www.youtube.com/watch?v=-RLxbBNBWhU)
- 2021-08-13 - [Let's Convert an Old Laptop to a NAS - What you should do](https://www.youtube.com/watch?v=F1v-TSbOymI)
- 2021-08-17 - [How to Combine Multiple Disks as One by using MergerFS | Ubuntu 20.04 LTS](https://www.youtube.com/watch?v=9e46pz5Seo4)
- 2021-08-20 - [Vamos converter um Laptop antigo para um NAS – O que você deve fazer](https://www.youtube.com/watch?v=q8EK9vWCRTc)
- 2021-10-29 - [Unlimited space for your Plex using Rclone to connect to your Cloud](https://www.youtube.com/watch?v=ghGconyrF3M)
- 2022-12-01 - [Make Your Home Server Go FAST! SSD Caching, 10Gbit Networking, etc.](https://www.youtube.com/watch?v=eRfqC_q3lkM&t=784s)
- 2022-12-07 - [Best RAID for mixed drive sizes. Unraid vs BTRFS vs Snapraid+Mergerfs vs Storage spaces.](https://www.youtube.com/watch?v=NQJkTiLXfgs)
- 2023-02-21 - [MergerFS + SnapRAID : Forget about RAID 5 in your Home Server !](https://www.youtube.com/watch?v=tX5MA-c6Qq4)
- 2023-06-26 - [How to install and setup MergerFS](https://www.youtube.com/watch?v=n7piuhTXeG4)
- 2023-07-31 - [How to recover a dead drive using Snapraid](https://www.youtube.com/watch?v=fmuiRLPcuJE)
- 2024-01-05 - [OpenMediaVault MergerFS Tutorial (Portuguese)](https://www.youtube.com/watch?v=V6Yw86dRUPQ)
- 2024-02-19 - [Setup and Install MergerFS and SnapRAID (Part 1)](https://noted.lol/mergerfs-and-snapraid-setup-1/)
- 2024-02-22 - [Setup and Install MergerFS and SnapRAID (Part 2)](https://noted.lol/mergerfs-and-snapraid-setup-part-2/)
- 2024-11-15 - [Meu servidor NAS - Parte 18: Recuperando um HD, recuperando o MergerFS e os próximos passos do NAS!](https://www.youtube.com/watch?v=5fy98kPzE3s)
## Podcasts
- 2019-11-04 - [Jupiter Extras: A Chat with mergerfs Developer Antonio Musumeci | Jupiter Extras 28](https://www.youtube.com/watch?v=VmJUAyyhSPk)
- 2019-11-07 - [Jupiter Broadcasting: ZFS Isn’t the Only Option | Self-Hosted 5](https://www.youtube.com/watch?v=JEW7UuKhMJ8)
- 2023-10-08 - [Self Hosted Episode 105 - Sleeper Storage Technology](https://selfhosted.show/105)
## Social Media
- [Reddit](https://www.reddit.com/search/?q=mergerfs&sort=new)
- [X](https://x.com/search?q=mergerfs&src=spelling_expansion_revert_click&f=live)
- [YouTube](https://www.youtube.com/results?search_query=mergerfs&sp=CAI%253D)
- [ServeTheHome Forum](https://forums.servethehome.com/index.php?search/3105813/&q=mergerfs&o=date)
+43
View File
@@ -0,0 +1,43 @@
# Tweaking Performance
mergerfs is at its is a proxy and therefore its theoretical max
performance is that of the underlying devices. However, given it is a
FUSE based filesystem working from userspace there is an increase in
overhead relative to kernel based solutions. That said the performance
can match the theoretical max but it depends greatly on the system's
configuration. Especially when adding network filesystems into the mix
there are many variables which can impact performance. Device speeds
and latency, network speeds and latency, concurrency and parallel
limits of the hardware, read/write sizes, etc.
While some settings can impact performance they are all **functional**
in nature. Meaning they change mergerfs' behavior in some way. As a
result there is no such thing as a "performance mode".
If you're having performance issues please look over the suggestions
below and the [benchmarking section.](benchmarking.md)
NOTE: Be sure to [read about these features](config/options.md) before
changing them to understand how functionality will change.
* test theoretical performance using `nullrw` or mounting a ram disk
* increase readahead: `readahead=1024`
* disable `security_capability` and/or `xattr`
* increase cache timeouts `cache.attr`, `cache.entry`, `cache.negative_entry`
* enable (or disable) page caching (`cache.files`)
* enable `parallel-direct-writes`
* enable `cache.writeback`
* enable `cache.statfs`
* enable `cache.symlinks`
* enable `cache.readdir`
* change the number of threads available
* disable `posix_acl`
* disable `async_read`
* use `symlinkify` if your data is largely static and read-only
* use tiered cache devices
* use LVM and LVM cache to place a SSD in front of your HDDs
If you come across a setting that significantly impacts performance
please [contact trapexit](support.md) so he may investigate further. Please test
both against your normal setup, a singular branch, and with
`nullrw=true`
+170
View File
@@ -0,0 +1,170 @@
# Project Comparisons
## mhddfs
* [https://romanrm.net/mhddfs](https://romanrm.net/mhddfs)
mhddfs had not been updated in over a decade and has known stability
and security issues. mergerfs provides a super set of mhddfs' features
and offers better performance. In fact, as of 2020, the author of
mhddfs has [moved to using
mergerfs.](https://romanrm.net/mhddfs#update)
Below is an example of mhddfs and mergerfs setup to work similarly.
`mhddfs -o mlimit=4G,allow_other /mnt/drive1,/mnt/drive2 /mnt/pool`
`mergerfs -o minfreespace=4G,category.create=ff /mnt/drive1:/mnt/drive2 /mnt/pool`
## aufs
* [https://aufs.sourceforge.net](https://aufs.sourceforge.net)
* [https://en.wikipedia.org/wiki/Aufs](https://en.wikipedia.org/wiki/Aufs)
While aufs still is maintained it failed to be included in the
mainline kernel and is no longer available in most Linux distros
making it harder to get installed for the average user.
While aufs can often offer better peak performance due to being
primarily kernel based, mergerfs provides more configurability and is
generally easier to use. mergerfs however does not offer the overlay /
copy-on-write (CoW) features which aufs has.
## unionfs
* [https://unionfs.filesystems.org](https://unionfs.filesystems.org)
unionfs for Linux is a "stackable unification file system" which
functions like many other union filesystems. unionfs has not been
maintained and was last released for Linux v3.14 back in 2014.
Documentation is sparse so a comparison of features is not possible
but given the lack of maintenance and support for modern kernels there
is little reason to consider it as a solution.
## unionfs-fuse
* [https://github.com/rpodgorny/unionfs-fuse](https://github.com/rpodgorny/unionfs-fuse)
unionfs-fuse is more like unionfs, aufs, and overlayfs than mergerfs
in that it offers overlay / copy-on-write (CoW) features. If you're
just looking to create a union of filesystems and want flexibility in
file/directory placement then mergerfs offers that whereas
unionfs-fuse is more for overlaying read/write filesystems over
read-only ones.
Since unionfs-fuse, as the name suggests, is a FUSE based technology
it can be used without elevated privileges that kernel solutions such
as unionfs, aufs, and overlayfs require.
## overlayfs
* [https://docs.kernel.org/filesystems/overlayfs.html](https://docs.kernel.org/filesystems/overlayfs.html)
overlayfs is effectively the successor to unionfs, unionfs-fuse, and
aufs and is widely used by Linux container platforms such as Docker and
Podman. It was developed and is maintained by the same developer who
created FUSE.
If your use case is layering a writable filesystem on top of read-only
filesystems then you should look first to overlayfs. Its feature set
however is very different from mergerfs and solve different problems.
## RAID0, JBOD, SPAN, drive concatenation, striping
* [RAID0](https://en.wikipedia.org/wiki/Standard_RAID_levels#RAID_0)
* [JBOD](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures#JBOD)
* [SPAN](https://en.wikipedia.org/wiki/Non-RAID_drive_architectures#Concatenation_(SPAN,_BIG))
* [striping](https://en.wikipedia.org/wiki/Data_striping)
These are block device technologies which in some form aggregate
devices into what appears to be a singular device on which a
traditional filesystem can be used. The filesystem has no
understanding of the underlying block layout and should one of those
underlying devices fail or be removed the filesystem will be missing
that chunk which could contain critical information and the whole
filesystem may become unrecoverable. Even if the data from the
filesystem is recoverable it will take using specialized tooling to do
so.
In contrast, with mergerfs you can format devices as one normally
would or take existing filesystems and then combine them in a pool to
aggregate their storage. The failure of any one device will have no
impact on the other devices. The downside to mergerfs' technique is
the fact you don't actually have contiguous space as large as if you
used those other technologies. Meaning you can't create a file greater
than 1TB on a pool of 2 1TB filesystems.
## UnRAID
* [https://unraid.net](https://unraid.net)
UnRAID is a full OS and offers a (FUSE based?) filesystem which
provides a union of filesystems like mergerfs but with the addition of
live parity calculation and storage. Outside parity calculations
mergerfs offers more features and due to the lack of real-time parity
calculation can have higher peak performance. Some users also prefer
an open source solution.
For semi-static data mergerfs + [SnapRaid](http://www.snapraid.it)
provides a similar, but not real-time, solution.
## ZFS
* [https://en.wikipedia.org/wiki/ZFS](https://en.wikipedia.org/wiki/ZFS)
mergerfs is very different from ZFS. mergerfs is intended to provide
flexible pooling of arbitrary filesystems (local or remote), of
arbitrary sizes, and arbitrary filesystems. Particularly in `write
once, read many` use cases such as bulk media storage. Where data
integrity and backup is managed in other ways. In those use cases ZFS
can introduce a number of costs and limitations as described
[here](http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html),
[here](https://markmcb.com/2020/01/07/five-years-of-btrfs/), and
[here](https://utcc.utoronto.ca/~cks/space/blog/solaris/ZFSWhyNoRealReshaping).
## StableBit's DrivePool
* [https://stablebit.com](https://stablebit.com)
DrivePool works only on Windows so not as common an alternative as
other Linux solutions. If you want to use Windows then DrivePool is a
good option. Functionally the two projects work a bit
differently. DrivePool always writes to the filesystem with the most
free space and later rebalances. mergerfs does not currently offer
rebalance but chooses a branch at file/directory create
time. DrivePool's rebalancing can be done differently in any directory
and has file pattern matching to further customize the
behavior. mergerfs, not having rebalancing does not have these
features, but similar features are planned for mergerfs v3. DrivePool
has builtin file duplication which mergerfs does not natively support
(but can be done via an external script.)
There are a lot of misc differences between the two projects but most
features in DrivePool can be replicated with external tools in
combination with mergerfs.
Additionally, DrivePool is a closed source commercial product vs
mergerfs a ISC licensed open source project.
## Plan9 binds
* [https://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs#Union_directories_and_namespaces](https://en.wikipedia.org/wiki/Plan_9_from_Bell_Labs#Union_directories_and_namespaces)
Plan9 has the native ability to bind multiple paths/filesystems
together to create a setup similar to simplified union
filesystem. Such bind mounts choose files in a "first found" in the
order they are listed similar to mergerfs' `ff` policy. Similar, when
creating a file it will be created on the first directory in the
union.
Plan 9 isn't a widely used OS so this comparison is mostly academic.
+189
View File
@@ -0,0 +1,189 @@
# QuickStart
## Install
First ensure you have the [latest version installed](setup/installation.md).
## Configuration
mergerfs has many options and effectively all of them are functional
in nature. What that means is that there is no "best" or "fastest"
configuration. No "make faster" options. Everything changes
behavior. Sometimes those changes in behavior affect performance.
That said: If you don't already know that you have a special use case
then use one of the following option sets as it will cover most casual
usecases.
### You use Linux v6.6 or above
* cache.files=off
* category.create=mfs
* dropcacheonclose=false
In previous versions of Linux it was unable to support `mmap` if page
caching was disabled (ie: `cache.files=off`). However, it now will
enable page caching if needed for a particular file if mmap is
requested.
`mmap` is needed by certain software to read and write to a
file. However, many software could work without it and fail to have
proper error handling. Many programs that use sqlite3 will require
`mmap` despite sqlite3 working perfectly fine without it (and in some
cases can be more performant with regular file IO.)
### You use Linux v6.5 or below
#### You need `mmap` (used by rtorrent and many sqlite3 base software)
* cache.files=auto-full
* category.create=mfs
* dropcacheonclose=true
#### You don't need `mmap`
* cache.files=off
* category.create=mfs
* dropcacheonclose=false
## Usage
### Command Line
```
mergerfs -o cache.files=off,dropcacheonclose=false,category.create=mfs /mnt/hdd0:/mnt/hdd1 /media
```
### /etc/fstab
```
/mnt/hdd0:/mnt/hdd1 /media mergerfs cache.files=off,dropcacheonclose=false,category.create=mfs 0 0
```
### /etc/fstab w/ config file
For more complex setups it can be useful to separate out the config.
#### /etc/fstab
```
/etc/mergerfs/branches/media/* /media mergerfs config=/etc/mergerfs/config/media.ini
```
#### /etc/mergerfs/config/media.ini
```ini title="media.ini" linenums="1"
cache.files=off
category.create=mfs
dropcacheonclose=false
```
#### /etc/mergerfs/branches/media/
Create a bunch of symlinks to point to the branch. mergerfs will
resolve the symlinks and use the real path.
`ls -lh /etc/mergerfs/branches/media/*`
```text
lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd00 -> /mnt/hdd/hdd00
lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd01 -> /mnt/hdd/hdd01
lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd02 -> /mnt/hdd/hdd02
lrwxrwxrwx 1 root root 21 Aug 4 2023 hdd03 -> /mnt/hdd/hdd03
```
### systemd (simple)
`/etc/systemd/system/mergerfs-media.service`
```systemd title="mergerfs-media.service" linenums="1"
[Unit]
Description=mergerfs /media service
After=local-fs.target network.target
[Service]
Type=simple
KillMode=none
ExecStart=/usr/bin/mergerfs \
-f \
-o cache.files=off \
-o category.create=mfs \
-o dropcacheonclose=false \
/mnt/hdd0:/mnt/hdd1 \
/media
ExecStop=/bin/fusermount -uz /media
Restart=on-failure
[Install]
WantedBy=default.target
```
### systemd (w/ setup script)
Since it isn't well documented otherwise: if you wish to do some setup before
you mount mergerfs follow this example.
#### setup-for-mergerfs
`/usr/local/bin/setup-for-mergerfs`
```shell title="setup-for-mergerfs" linenums="1"
#!/usr/bin/env sh
# Perform setup
/bin/sleep 10
# Report back to systemd that things are ready
/bin/systemd-notify --ready
```
#### setup-for-mergerfs.service
`/etc/systemd/system/setup-for-mergerfs.service`
```systemd title="setup-for-mergerfs.service" linenums="1"
[Unit]
Description=mergerfs setup service
[Service]
Type=notify
RemainAfterExit=yes
ExecStart=/usr/local/bin/setup-for-mergerfs
[Install]
WantedBy=default.target
```
#### mergerfs-media.service
`/etc/systemd/system/mergerfs-media.service`
```systemd title="mergerfs-media.service" linenums="1"
[Unit]
Description=mergerfs /media service
Requires=setup-for-mergerfs.service
After=local-fs.target network.target prepare-for-mergerfs.service
[Service]
Type=simple
KillMode=none
ExecStart=/usr/bin/mergerfs \
-f \
-o cache.files=off \
-o category.create=mfs \
-o dropcacheonclose=false \
/mnt/hdd0:/mnt/hdd1 \
/media
ExecStop=/bin/fusermount -uz /media
Restart=on-failure
[Install]
WantedBy=default.target
```
+83
View File
@@ -0,0 +1,83 @@
# Related Projects
## Projects using mergerfs
* [Lakka.tv](https://lakka.tv/): A turnkey software emulation Linux
distribution. Used to pool user and local storage. Also includes my
other project [Opera](https://retroarch.com/). A 3DO emulator.
* [OpenMediaVault](https://www.openmediavault.org): A network attached
storage (NAS) solution based on Debian Linux. They provide plugins
to manage mergerfs.
* [CasaOS](https://casaos.io): "A simple, easy to use, elegant open
source home cloud system." Has added initial integration with
mergerfs to create pools from existing filesystems.
* [ZimaOS](https://github.com/IceWhaleTech/zimaos-rauc): A more
commercially focused NAS OS by the authors of CasaOS at [Ice
Whale](https://www.zimaboard.com/).
* [Cosmos Cloud](https://cosmos-cloud.io/): Cosmos "take the chore out
of selfhosting, with automated maintenance and fully secured setup
out of the box. It even integrates to your existing setup."
## Software and services commonly used with mergerfs
* [snapraid](https://www.snapraid.it/): a backup program designed for
disk arrays, storing parity information for data recovery in the
event of up to six disk failures.
* [rclone](https://rclone.org/): a command-line program to manage
files on cloud storage. It is a feature-rich alternative to cloud
vendors' web storage interfaces. rclone's
[union](https://rclone.org/union/) feature is based on mergerfs
policies.
* [ZFS](https://openzfs.org/): A popular filesystem and volume
management platform originally part of Sun Solaris and later ported
to other operating systems. It is common to use ZFS with
mergerfs. ZFS for important data and mergerfs pool for replacable
media.
* [Proxmox](https://www.proxmox.com/): Proxmox is a popular, Debian
based, virtualization platform. Users tend to install mergerfs on
the host and pass the mount into containers.
* [UnRAID](https://unraid.net): "Unraid is a powerful, easy-to-use
operating system for self-hosted servers and network-attached
storage." While UnRAID has its own union filesystem it isn't
uncommon to see UnRAID users leverage mergerfs given the differences
in the technologies. There is a [plugin available by
Rysz](https://forums.unraid.net/topic/144999-plugin-mergerfs-for-unraid-support-topic/)
to ease installation and setup.
* [TrueNAS SCALE](https://www.truenas.com/truenas-scale/): An
enterprise focused NAS operating system with OpenZFS support. A Some
users are requesting mergerfs be [made part
of](https://forums.truenas.com/t/add-unionfs-or-mergerfs-and-rdam-enhancement-then-beat-all-other-nas-systems/23218)
TrueNAS.
* For a time there were a number of Chia miners recommending mergerfs.
* [cloudboxes.io](https://cloudboxes.io): VPS provider. Includes
details [on their
wiki](https://cloudboxes.io/wiki/how-to/apps/set-up-mergerfs-using-ssh):
on how to setup mergerfs.
* [QNAP](https://www.myqnap.org/product/mergerfs-apache83/): A company
known for their turnkey, consumer focused NAS devices. Someone has
created builds of mergerfs for different QNAP devices.
## Distributions including mergerfs
mergerfs can be found in the
[repositories](https://pkgs.org/download/mergerfs) of [many
Linux](https://repology.org/project/mergerfs/versions) distributions
and FreeBSD.
Note: Any non-rolling release based distro is likely to have
out-of-date versions.
* [Debian](https://packages.debian.org/bullseye/mergerfs)
* [Ubuntu](https://launchpad.net/ubuntu/+source/mergerfs)
* [Fedora](https://rpmsphere.github.io/)
* [T2](https://t2sde.org/packages/mergerfs)
* [Alpine](https://pkgs.alpinelinux.org/packages?name=mergerfs&branch=edge&repo=&arch=&maintainer=)
* [Gentoo](https://packages.gentoo.org/packages/sys-fs/mergerfs)
* [Arch (AUR)](https://aur.archlinux.org/packages/mergerfs)
* [Void](https://voidlinux.org/packages/?arch=x86_64&q=mergerfs)
* [NixOS](https://search.nixos.org/packages?type=packages&query=mergerfs)
* [Guix]()
* [Slackware](https://slackbuilds.org/repository/15.0/system/mergerfs/?search=mergerfs)
* [FreeBSD](https://www.freshports.org/filesystems/mergerfs)
+117
View File
@@ -0,0 +1,117 @@
# Remote Filesystems
Many users ask about compatibility with remote filesystems. This
section is to describe any known issues or quirks when using mergerfs
with common remote filesystems.
Keep in mind that, like with caching, it is **NOT** a good idea to
change the contents of the remote filesystem
[out-of-band](https://en.wikipedia.org/wiki/Out-of-band). Meaning that
you should not change the contents of the underlying filesystems or
mergerfs on the server hosting the remote filesystem. Doing so can
lead to weird behavior, inconsistency, errors, and even data
corruption should multiple programs try to write or read the same data
at the same time. This isn't to say you can't do it or that data
corruption is likely but it _could_ happen. It is better to always use
the remote filesystem. Even on the machine serving it.
## NFS
[NFS](https://en.wikipedia.org/wiki/Network_File_System) is a common
remote filesystem on Unix/POSIX systems. Due to how NFS works there
are some settings which need to be set in order for mergerfs to work
with it.
It should be noted that NFS and FUSE (the technology mergerfs uses) do
not work perfectly with one another due to certain design choices in
FUSE (and mergerfs.) Due to these issues, it is generally recommended
to use SMB when possible. That said mergerfs should generally work as
an export of NFS and issues discovered should still be reported.
To ensure compatibility between mergerfs and NFS use the following
settings.
mergerfs settings:
* `noforget`
* `inodecalc=path-hash`
NFS export settings:
* `fsid=UUID`
* `no_root_squash`
`noforget` is needed because NFS uses the `name_to_handle_at` and
`open_by_handle_at` functions which allow a program to keep a
reference to a file without technically having it open in the typical
sense. The problem is that FUSE has no way to know that NFS has a
handle that it will later use to open the file again. As a result, it
is possible for the kernel to tell mergerfs to forget about the node
and should NFS ever ask for that node's details in the future it would
have nothing to respond with. Keeping nodes around forever is not
ideal but at the moment the only way to manage the situation.
`inodecalc=path-hash` is needed because NFS is sensitive to
out-of-band changes. FUSE doesn't care if a file's inode value changes
but NFS, being stateful, does. So if you used the default inode
calculation algorithm then it is possible that if you changed a file
or updated a directory the file mergerfs will use will be on a
different branch and therefore the inode would change. This isn't an
ideal solution and others are being considered but it works for most
situations.
`fsid=UUID` is needed because FUSE filesystems don't have different
`st_dev` values which can cause issues when exporting. The easiest
thing to do is set each mergerfs export `fsid` to some random
value. An easy way to generate a random value is to use the command
line tool `uuid` or `uuidgen` or through a website such as
[uuidgenerator.net](https://www.uuidgenerator.net/).
`no_root_squash` is not strictly necessary but can lead to confusing
permission and ownership issues if root squashing is enabled. mergerfs
needs to run certain commands as `root` and if root squash is enabled
it NFS will tell mergerfs a non-root user is making certain calls.
## SMB / CIFS
[SMB](https://en.wikipedia.org/wiki/Server_Message_Block) is a
protocol most used by Microsoft Windows systems to share file shares,
printers, etc. However, due to the popularity of Windows, it is also
supported on many other platforms including Linux. The most popular
way of supporting SMB on Linux is via the software Samba.
[Samba](<https://en.wikipedia.org/wiki/Samba_(software)>), and other
ways of serving Linux filesystems, via SMB should work fine with
mergerfs. The services do not tend to use the same technologies which
NFS uses and therefore don't have the same issues. There should not be
special settings required to use mergerfs with Samba. However,
[CIFSD](https://en.wikipedia.org/wiki/CIFSD) and other programs have
not been extensively tested. If you use mergerfs with CIFSD or other
SMB servers please submit your experiences so these docs can be
updated.
## SSHFS
[SSHFS](https://en.wikipedia.org/wiki/SSHFS) is a FUSE filesystem
leveraging SSH as the connection and transport layer. While often
simpler to setup when compared to NFS or Samba the performance can be
lacking and the project is very much in maintenance mode.
There are no known issues using sshfs with mergerfs. You may want to
use the following arguments to improve performance but your millage
may vary.
- `-o Ciphers=arcfour`
- `-o Compression=no`
More info can be found
[here](https://ideatrash.net/2016/08/odds-and-ends-optimizing-sshfs-moving.html).
## Other
There are other remote filesystems but none popularly used to serve
mergerfs. If you use something not listed above feel free to reach out
and I will add it to the list.
+114
View File
@@ -0,0 +1,114 @@
# Runtime Interfaces
## Runtime Config
### .mergerfs pseudo file
```
<mountpoint>/.mergerfs
```
There is a pseudo file available at the mount point which allows for
the runtime modification of certain **mergerfs** options. The file
will not show up in **readdir** but can be **stat**'ed and manipulated
via [{list,get,set}xattrs](http://linux.die.net/man/2/listxattr)
calls.
Any changes made at runtime are **not** persisted. If you wish for
values to persist they must be included as options wherever you
configure the mounting of mergerfs (/etc/fstab).
#### Keys
Use `getfattr -d /mountpoint/.mergerfs` or `xattr -l
/mountpoint/.mergerfs` to see all supported keys. Some are
informational and therefore read-only. `setxattr` will return EINVAL
(invalid argument) on read-only keys.
#### Values
Same as the command line.
##### user.mergerfs.branches
Used to query or modify the list of branches. When modifying there are
several shortcuts to easy manipulation of the list.
| Value | Description |
| -------- | -------------------------- |
| [list] | set |
| +<[list] | prepend |
| +>[list] | append |
| -[list] | remove all values provided |
| -< | remove first in list |
| -> | remove last in list |
`xattr -w user.mergerfs.branches +</mnt/drive3 /mnt/pool/.mergerfs`
The `=NC`, `=RO`, `=RW` syntax works just as on the command line.
##### Example
```
[trapexit:/mnt/mergerfs] $ getfattr -d .mergerfs
user.mergerfs.branches="/mnt/a=RW:/mnt/b=RW"
user.mergerfs.minfreespace="4294967295"
user.mergerfs.moveonenospc="false"
...
[trapexit:/mnt/mergerfs] $ getfattr -n user.mergerfs.category.search .mergerfs
user.mergerfs.category.search="ff"
[trapexit:/mnt/mergerfs] $ setfattr -n user.mergerfs.category.search -v newest .mergerfs
[trapexit:/mnt/mergerfs] $ getfattr -n user.mergerfs.category.search .mergerfs
user.mergerfs.category.search="newest"
```
### file / directory xattrs
While they won't show up when using `getfattr` **mergerfs** offers a
number of special xattrs to query information about the files
served. To access the values you will need to issue a
[getxattr](http://linux.die.net/man/2/getxattr) for one of the
following:
- **user.mergerfs.basepath**: the base mount point for the file given the current getattr policy
- **user.mergerfs.relpath**: the relative path of the file from the perspective of the mount point
- **user.mergerfs.fullpath**: the full path of the original file given the getattr policy
- **user.mergerfs.allpaths**: a NUL ('\0') separated list of full paths to all files found
## Signals
- USR1: This will cause mergerfs to send invalidation notifications to
the kernel for all files. This will cause all unused files to be
released from memory.
- USR2: Trigger a general cleanup of currently unused memory. A more
thorough version of what happens every ~15 minutes.
## ioctl
Found in `fuse_ioctl.cpp`:
```C++
typedef char IOCTL_BUF[4096];
#define IOCTL_APP_TYPE 0xDF
#define IOCTL_FILE_INFO _IOWR(IOCTL_APP_TYPE,0,IOCTL_BUF)
#define IOCTL_GC _IO(IOCTL_APP_TYPE,1)
#define IOCTL_GC1 _IO(IOCTL_APP_TYPE,2)
#define IOCTL_INVALIDATE_ALL_NODES _IO(IOCTL_APP_TYPE,3)
```
- IOCTL_FILE_INFO: Same as the "file / directory xattrs" mentioned
above. Use a buffer size of 4096 bytes. Pass in a string of
"basepath", "relpath", "fullpath", or "allpaths". Receive details in
same buffer.
- IOCTL_GC: Triggers a thorough garbage collection of excess
memory. Same as SIGUSR2.
- IOCTL_GC1: Triggers a simple garbage collection of excess
memory. Same as what happens every 15 minutes normally.
- IOCTL_INVALIDATE_ALL_NODES: Same as SIGUSR1. Send invalidation
notifications to the kernel for all files causing unused files to be
released from memory.
+67
View File
@@ -0,0 +1,67 @@
# Build
**NOTE:** Prebuilt packages can be found at and recommended for most
users: https://github.com/trapexit/mergerfs/releases
**NOTE:** Only tagged releases are supported. `master` and other
branches should be considered works in progress.
First, get the code from [github](https://github.com/trapexit/mergerfs).
```
$ git clone https://github.com/trapexit/mergerfs.git
$ # or
$ wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.tar.gz
```
## Debian / Ubuntu
```
$ cd mergerfs
$ sudo tools/install-build-pkgs
$ make deb
$ sudo dpkg -i ../mergerfs_<version>_<arch>.deb
```
## RHEL / CentOS / Rocky / Fedora
```
$ su -
# cd mergerfs
# tools/install-build-pkgs
# make rpm
# rpm -i rpmbuild/RPMS/<arch>/mergerfs-<version>.<arch>.rpm
```
## Generic Linux
Have git, g++ or clang, make, python installed.
```
$ cd mergerfs
$ make
$ sudo make install
```
## FreeBSD
Have git, g++ or clang, gmake, python installed.
```
$ cd mergerfs
$ gmake
$ gmake install # as root
```
## Build options
```
$ make help
usage: make
make USE_XATTR=0 - build program without xattrs functionality
make STATIC=1 - build static binary
make LTO=1 - build with link time optimization
```
+97
View File
@@ -0,0 +1,97 @@
# Installation
If you are using a non-rolling release Linux distro such as Debian or
Ubuntu then you are almost certainly going to have an old version of
mergerfs installed if you use the "official" package. For that reason
we provide packages for major stable released distros.
Before reporting issues or bugs please be sure to upgrade to the
latest release to confirm they still exist.
All provided packages can be found at [https://github.com/trapexit/mergerfs/releases](https://github.com/trapexit/mergerfs/releases)
## ArchLinux
1. Setup AUR
2. `pacman -S mergerfs`
## CentOS / Rocky
Get the RPM from the [releases page](https://github.com/trapexit/mergerfs/releases).
```
wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.el<rel>.<arch>.rpm
sudo rpm -i mergerfs-<ver>.el<rel>.<arch>.rpm
```
## Debian based OS
Debian/Ubuntu/Raspberry Pi
Most Debian based OS installs are of a stable branch and therefore do not have
the most up to date software. While mergerfs is available via `apt` it
is suggested that users install the most recent version available from
the [releases page](https://github.com/trapexit/mergerfs/releases).
### prebuilt deb
#### Debian
```
wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs_<ver>.debian-<rel>_<arch>.deb
sudo dpkg -i mergerfs_<ver>.debian-<rel>_<arch>.deb
```
#### Ubuntu
```
wget https://github.com/trapexit/mergerfs/releases/download/<version>/mergerfs_<ver>.ubuntu-<rel>_<arch>.deb
sudo dpkg -i mergerfs_<ver>.ubuntu-<rel>_<arch>.deb
```
### apt
```
sudo apt install -y mergerfs
```
## Fedora
Get the RPM from the [releases page](https://github.com/trapexit/mergerfs/releases).
```
wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-<ver>.fc<rel>.<arch>.rpm
sudo rpm -i mergerfs-<ver>.fc<rel>.<arch>.rpm
```
## FreeBSD
[https://www.freshports.org/filesystems/mergerfs](https://www.freshports.org/filesystems/mergerfs)
```
pkg install filesystems/mergerfs
```
## NixOS
[search.nixos.org](https://search.nixos.org/packages?channel=unstable&show=mergerfs&from=0&size=50&sort=relevance&type=packages&query=mergerfs)
```
nix-env -iA nixos.mergerfs
```
## Other Linux Distros
[Check your distro.](../related_projects.md#distributions-including-mergerfs)
## Static Linux Binaries
If your distro does not package mergerfs there are static binaries
provided.
Get the tarball from the [releases page](https://github.com/trapexit/mergerfs/releases).
```
wget https://github.com/trapexit/mergerfs/releases/download/<ver>/mergerfs-static-linux_<arch>.tar.gz
sudo tar xvf mergerfs-static-linux_<arch>.tar.gz -C /
```
+25
View File
@@ -0,0 +1,25 @@
# Upgrade
mergerfs can be upgraded live by mounting on top of the previous
instance. Simply install the new version of mergerfs and follow the
instructions below.
Run mergerfs again or if using `/etc/fstab` call for it to mount
again. Existing open files and such will continue to work fine though
they won't see runtime changes since any such change would be the new
mount. If you plan on changing settings with the new mount you should
/ could apply those before mounting the new version.
```
$ sudo mount /mnt/mergerfs
$ mount | grep mergerfs
media on /mnt/mergerfs type mergerfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
media on /mnt/mergerfs type mergerfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other)
```
A problem with this approach is that the underlying instance will
continue to run even if the software using it stop or are
restarted. To work around this you can use a "lazy umount". Before
mounting over top the mount point with the new instance of mergerfs
issue: `umount -l <mergerfs_mountpoint>`. Or you can let mergerfs do
it by setting the option `lazy-umount-mountpoint=true`.
+17
View File
@@ -0,0 +1,17 @@
# Sponsorship and Donations
[https://github.com/trapexit/support](https://github.com/trapexit/support)
Development and support of a project like mergerfs requires a
significant amount of time and effort. The software is released under
the very liberal [ISC](https://opensource.org/license/isc-license-txt)
license and is therefore free to use for personal or commercial uses.
If you are a non-commercial user and find mergerfs and its support valuable
and would like to support the project financially it would be very
much appreciated.
If you are using mergerfs commercially please consider sponsoring the
project to ensure it continues to be maintained and receive
updates. If custom features are needed feel free to [contact me
directly](mailto:support@spawn.link).
+45
View File
@@ -0,0 +1,45 @@
# Support
Filesystems are complex, as are the interactions software have with
them, and therefore difficult to debug. When reporting on a suspected
issue **please** include as much of the below information as possible
otherwise it will be difficult or impossible to diagnose. Also please
read the documentation as it provides details on many previously
encountered questions/issues.
**Please make sure you are using the [latest
release](https://github.com/trapexit/mergerfs/releases) or have tried
it in comparison. Old versions, which are often included in distros
like Debian and Ubuntu, are not ever going to be updated and the issue
you are encountering may have been addressed already.**
**For commercial support or feature requests please [contact me
directly.](mailto:support@spawn.link)**
### Information to include in bug reports
* [Information about the broader problem along with any attempted
solutions.](https://xyproblem.info)
* Solution already ruled out and why.
* Version of mergerfs: `mergerfs --version`
* mergerfs settings / arguments: from fstab, systemd unit, command
line, OMV plugin, etc.
* Version of the OS: `uname -a` and `lsb_release -a`
* List of branches, their filesystem types, sizes (before and after issue): `df -h`
* **All** information about the relevant paths and files: permissions, ownership, etc.
* **All** information about the client app making the requests: version, uid/gid
* Runtime environment:
* Is mergerfs running within a container?
* Are the client apps using mergerfs running in a container?
* A `strace` of the app having problems:
* `strace -fvTtt -s 256 -o /tmp/app.strace.txt <cmd>`
* A `strace` of mergerfs while the program is trying to do whatever it is failing to do:
* `strace -fvTtt -s 256 -p <mergerfsPID> -o /tmp/mergerfs.strace.txt`
* **Precise** directions on replicating the issue. Do not leave **anything** out.
* Try to recreate the problem in the simplest way using standard programs: `ln`, `mv`, `cp`, `ls`, `dd`, etc.
### Contact / Issue submission
* github.com: [https://github.com/trapexit/mergerfs/issues](https://github.com/trapexit/mergerfs/issues)
* discord: [https://discord.gg/MpAr69V](https://discord.gg/MpAr69V)
* reddit: [https://www.reddit.com/r/mergerfs](https://www.reddit.com/r/mergerfs)
+33
View File
@@ -0,0 +1,33 @@
# Terminology
* `disk`, `drive`, `disk drive`: A [physical data storage
device](https://en.wikipedia.org/wiki/Disk_storage). Such as a hard
drive or solid-state drive. Usually requires the use of a filesystem
to be useful. mergerfs does not deal with disks.
* `filesystem`: Lowlevel software which provides a way to organize data
and provide access to said data in a standard way. A filesystem is a
higher level abstraction that may or may not be stored on a
disk. mergerfs deals exclusively with filesystems.
* `path`: A location within a filesystem. mergerfs can work with any
path within a filesystem and not simply the root.
* `branch`: A base path used in a mergerfs pool. mergerfs can
accommodate multiple paths pointing to the same filesystem.
* `pool`: The mergerfs mount. The union of the branches. The instance
of mergerfs. You can mount multiple mergerfs pools. Even with the
same branches.
* `relative path`: The path in the pool relative to the branch and
mount. `foo/bar` is the relative path of mergerfs mount
`/mnt/mergerfs/foo/bar`.
* `function`: A filesystem call such as `open`, `unlink`, `create`,
`getattr`, `rmdir`, etc. The requests your software make to the
filesystem.
* `category`: A collection of functions based on basic behavior
(action, create, search).
* `policy`: The algorithm used to select a file or files when
performing a function.
* `path preservation`: Aspect of some policies which includes checking
the path for which a file would be created.
* `out-of-band`:
[out-of-band](https://en.wikipedia.org/wiki/Out-of-band) in our
context refers to interacting with the underlying filesystem
directly instead of going through mergerfs (or NFS or Samba).
+43
View File
@@ -0,0 +1,43 @@
# Tips and Notes
* This document is literal and reasonably thorough. If a suspected
feature isn't mentioned it doesn't exist. If certain `libfuse`
arguments aren't listed they probably shouldn't be used.
* Ensure you're using the latest version. Especially before submitting
bug reports.
* Run mergerfs as `root`. mergerfs is designed and intended to be run
as `root` and may exhibit incorrect behavior if run otherwise.
* If you do not see some directories and files you expect, policies
seem to skip branches, you get strange permission errors, etc. be
sure the underlying filesystems' permissions are all the same. Use
`mergerfs.fsck` to audit the filesystem for out of sync permissions.
* If you still have permission issues be sure you are using POSIX ACL
compliant filesystems. mergerfs doesn't generally make exceptions
for FAT, NTFS, or other non-POSIX filesystem.
* Unless using Linux v6.6 or above do **not** use `cache.files=off` if
you expect applications (such as rtorrent) to use
[mmap](http://linux.die.net/man/2/mmap). Enabling `dropcacheonclose`
is recommended when `cache.files=auto-full`.
* [Kodi](http://kodi.tv), [Plex](http://plex.tv),
[Subsonic](http://subsonic.org), etc. can use directory
[mtime](http://linux.die.net/man/2/stat) to more efficiently
determine whether to scan for new content rather than simply
performing a full scan. If using the default `getattr` policy of
`ff` it's possible those programs will miss an update on account of
it returning the first directory found's `stat` info and it is a
later directory on another mount which had the `mtime` recently
updated. To fix this you will want to set
`func.getattr=newest`. Remember though that this is just `stat`. If
the file is later `open`'ed or `unlink`'ed and the policy is
different for those then a completely different file or directory
could be acted on.
* Some policies mixed with some functions may result in strange
behaviors. Not that some of these behaviors and race conditions
couldn't happen outside mergerfs but that they are far more
likely to occur on account of the attempt to merge multiple sources
of data which could be out of sync due to the different policies.
* For consistency it's generally best to set `category` wide policies
rather than individual `func`'s. This will help limit the
confusion of tools such as
[rsync](http://linux.die.net/man/1/rsync). However, the flexibility
is there if needed.
+117
View File
@@ -0,0 +1,117 @@
# Tooling
## preload.so
EXPERIMENTAL
For some time there has been work to enable passthrough IO in
FUSE. Passthrough IO would allow for near native performance with
regards to reads and writes (at the expense of certain mergerfs
features.) In Linux v6.9 that feature made its way into the kernel
however in a somewhat limited form which is incompatible with aspects
of how mergerfs currently functions. While work will continue to
support passthrough IO in mergerfs this library was created to offer
similar functionality in a more limited way.
`/usr/lib/mergerfs/preload.so`
This [preloadable
library](https://man7.org/linux/man-pages/man8/ld.so.8.html#ENVIRONMENT)
overrides the creation and opening of files in order to simulate
passthrough file IO. It catches the open/creat/fopen calls, has
mergerfs do the call, queries mergerfs for the branch the file exists
on, reopens the file on the underlying filesystem and returns that
instead. Meaning that you will get native read/write performance
because mergerfs is no longer part of the workflow. Keep in mind that
this also means certain mergerfs features that work by interrupting
the read/write workflow, such as `moveonenospc`, will no longer work.
Also, understand that this will only work on dynamically linked
software. Anything statically compiled will not work. Many GoLang and
Rust apps are statically compiled.
The library will not interfere with non-mergerfs filesystems. The
library is written to always fallback to returning the mergerfs opened
file on error.
While the library was written to account for a number of edgecases
there could be some yet accounted for so please report any oddities.
Thank you to
[nohajc](https://github.com/nohajc/mergerfs-io-passthrough) for
prototyping the idea.
### casual usage
```sh
LD_PRELOAD=/usr/lib/mergerfs/preload.so touch /mnt/mergerfs/filename
```
Or run `export LD_PRELOAD=/usr/lib/mergerfs/preload.so` in your shell
or place it in your shell config file to have it be picked up by all
software ran from your shell.
### Docker and Podman usage
Assume `/mnt/fs0` and `/mnt/fs1` are pooled with mergerfs at `/media`.
All mergerfs branch paths _must_ be bind mounted into the container at
the same path as found on the host so the preload library can see
them.
**NOTE:** Since a container can have its own OS setup there is no
guarentee that `preload.so` from the host install will be compatible
with the loader found in the container. If that is true it simply
won't work and shouldn't cause any issues.
```sh
docker run \
-e LD_PRELOAD=/usr/lib/mergerfs/preload.so \
-v /usr/lib/mergerfs/preload.so:/usr/lib/mergerfs/preload.so:ro \
-v /media:/media \
-v /mnt:/mnt \
ubuntu:latest \
bash
```
or more explicitly
```sh
docker run \
-e LD_PRELOAD=/usr/lib/mergerfs/preload.so \
-v /usr/lib/mergerfs/preload.so:/usr/lib/mergerfs/preload.so:ro \
-v /media:/media \
-v /mnt/fs0:/mnt/fs0 \
-v /mnt/fs1:/mnt/fs1 \
ubuntu:latest \
bash
```
### systemd unit
Use the `Environment` option to set the LD_PRELOAD variable.
* [https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Command%20lines](https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Command%20lines)
* [https://serverfault.com/questions/413397/how-to-set-environment-variable-in-systemd-service](https://serverfault.com/questions/413397/how-to-set-environment-variable-in-systemd-service)
```
[Service]
Environment=LD_PRELOAD=/usr/lib/mergerfs/preload.so
```
## Misc
- https://github.com/trapexit/mergerfs-tools
- mergerfs.ctl: A tool to make it easier to query and configure mergerfs at runtime
- mergerfs.fsck: Provides permissions and ownership auditing and the ability to fix them
- mergerfs.dedup: Will help identify and optionally remove duplicate files
- mergerfs.dup: Ensure there are at least N copies of a file across the pool
- mergerfs.balance: Rebalance files across filesystems by moving them from the most filled to the least filled
- mergerfs.consolidate: move files within a single mergerfs directory to the filesystem with most free space
- https://github.com/trapexit/scorch
- scorch: A tool to help discover silent corruption of files and keep track of files
- https://github.com/trapexit/bbf
- bbf (bad block finder): a tool to scan for and 'fix' hard drive bad blocks and find the files using those blocks
+119
View File
@@ -0,0 +1,119 @@
# Usage Patterns
## tiered cache
Some storage technologies support what is called "tiered" caching. The
placing of smaller, faster storage as a transparent cache to larger,
slower storage. NVMe, SSD, Optane in front of traditional HDDs for
instance.
mergerfs does not natively support any sort of tiered caching. Most
users have no use for such a feature and its inclusion would
complicate the code as it exists today. However, there are a few
situations where a cache filesystem could help with a typical mergerfs
setup.
1. Fast network, slow filesystems, many readers: You've a 10+Gbps
network with many readers and your regular filesystems can't keep
up.
2. Fast network, slow filesystems, small'ish bursty writes: You have
a 10+Gbps network and wish to transfer amounts of data less than
your cache filesystem but wish to do so quickly and the time
between bursts is long enough to migrate data.
With #1 it's arguable if you should be using mergerfs at all. A RAID
level that can aggregate performance or using higher performance
storage would probably be the better solution. If you're going to use
mergerfs there are other tactics that may help: spreading the data
across filesystems (see the mergerfs.dup tool) and setting
`func.open=rand`, using `symlinkify`, or using dm-cache or a similar
technology to add tiered cache to the underlying device itself.
With #2 one could use a block cache solution as available via LVM and
dm-cache but there is another solution which requires only mergerfs, a
script to move files around, and a cron job to run said script.
* Create two mergerfs pools. One which includes just the **slow**
branches and one which has both the **fast** branches
(SSD,NVME,etc.) and **slow** branches. The **base** pool and the
**cache** pool.
* The **cache** pool should have the cache branches listed first in
the branch list in order to to make it easier to prioritize them.
* The best `create` policies to use for the **cache** pool would
probably be `ff`, `lus`, or `lfs`. The latter two under the
assumption that the cache filesystem(s) are far smaller than the
backing filesystems.
* You can also set the **slow** filesystems mode to `NC` which would
give you the ability to use other `create` policies though that'd
mean if the cache filesystems fill you'd get "out of space"
errors. This however may be good as it would indicate the script
moving files around is not configured properly.
* Set your programs to use the **cache** pool.
* Configure the **base** pool with the `create` policy you would like
to lay out files as you like.
* Save one of the below scripts or create your own. The script's
responsibility is to move files from the **cache** branches (not
pool) to the **base** pool.
* Use `cron` (as root) to schedule the command at whatever frequency
is appropriate for your workflow.
### time based expiring
Move files from cache filesystem to base pool which have an access
time older than the supplied number of days. Replace `-atime` with
`-amin` in the script if you want minutes rather than days.
**NOTE:** The arguments to these scripts include the cache
**filesystem** itself. Not the pool with the cache filesystem. You
could have data loss if the source is the cache pool.
[mergerfs.time-based-mover](https://github.com/trapexit/mergerfs/blob/latest-release/tools/mergerfs.time-based-mover?raw=1)
Download:
```
curl -o /usr/local/bin/mergerfs.time-based-mover https://raw.githubusercontent.com/trapexit/mergerfs/refs/heads/latest-release/tools/mergerfs.time-based-mover
```
crontab entry:
```
# m h dom mon dow command
0 * * * * /usr/local/bin/mergerfs.time-based-mover /mnt/ssd/cache00 /mnt/base-pool 1
```
If you have more than one cache filesystem then simply add a cron
entry for each.
If you want to only move files from a subdirectory then use the
subdirectories. `/mnt/ssd/cache00/foo` and `/mnt/base-pool/foo`
respectively.
### percentage full expiring
While the cache filesystem's percentage full is above the provided
value move the oldest file from the cache filesystem to the base pool.
**NOTE:** The arguments to these scripts include the cache
**filesystem** itself. Not the pool with the cache filesystem. You
could have data loss if the source is the cache pool.
[mergerfs.percent-full-mover](https://github.com/trapexit/mergerfs/blob/latest-release/tools/mergerfs.percent-full-mover?raw=1)
Download:
```
curl -o /usr/local/bin/mergerfs.percent-full-mover https://raw.githubusercontent.com/trapexit/mergerfs/refs/heads/latest-release/tools/mergerfs.percent-full-mover
```
crontab entry:
```
# m h dom mon dow command
0 * * * * /usr/local/bin/mergerfs.percent-full-mover /mnt/ssd/cache00 /mnt/base-pool 80
```
If you have more than one cache filesystem then simply add a cron
entry for each.
If you want to only move files from a subdirectory then use the
subdirectories. `/mnt/ssd/cache00/foo` and `/mnt/base-pool/foo`
respectively.
+104
View File
@@ -0,0 +1,104 @@
site_name: mergerfs
site_description: mergerfs - a featureful union filesystem
site_url: https://trapexit.github.io/mergerfs/
repo_name: mergerfs
repo_url: https://github.com/trapexit/mergerfs
edit_uri: edit/master/mkdocs/docs/
docs_dir: docs
theme:
name: material
logo: logo.jpeg
features:
- content.action.edit
- content.action.view
- content.code.copy
- content.code.select
- navigation.footer
- navigation.instant
- navigation.instant.prefetch
- navigation.path
- navigation.top
- navigation.tracking
- optimize
- search.share
- toc.follow
palette:
- media: "(prefers-color-scheme)"
toggle:
icon: material/brightness-auto
name: Switch to light mode
- media: "(prefers-color-scheme: light)"
scheme: default
toggle:
icon: material/brightness-7
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
toggle:
icon: material/brightness-4
name: Switch to system preference
markdown_extensions:
- footnotes
- pymdownx.highlight:
auto_title: false
linenums_style: pymdownx-inline
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
nav:
- Home: index.md
- QuickStart: quickstart.md
- Installation:
- setup/installation.md
- setup/upgrade.md
- setup/build.md
- terminology.md
- Config:
- config/options.md
- config/deprecated_options.md
- config/branches.md
- config/functions_categories_and_policies.md
- config/func_readdir.md
- config/rename_and_link.md
- config/cache.md
- config/readahead.md
- config/inodecalc.md
- config/threads.md
- config/pin-threads.md
- config/link_cow.md
- config/fuse_msg_size.md
- config/follow-symlinks.md
- config/link-exdev.md
- config/rename-exdev.md
- config/symlinkify.md
- config/nullrw.md
- config/xattr.md
- config/nfsopenhack.md
- config/statfs.md
- config/flush-on-close.md
- config/export-support.md
- error_handling_and_logging.md
- runtime_interfaces.md
- remote_filesystems.md
- tips_notes.md
- known_issues_bugs.md
- project_comparisons.md
- performance.md
- benchmarking.md
- tooling.md
- usage_patterns.md
- FAQ:
- faq/reliability_and_scalability.md
- faq/usage_and_functionality.md
- faq/configuration_and_policies.md
- faq/compatibility_and_integration.md
- faq/recommendations_and_warnings.md
- faq/technical_behavior_and_limitations.md
- faq/limit_drive_spinup.md
- related_projects.md
- media_and_publicity.md
- support.md
- sponsorship_and_donations.md
+3
View File
@@ -58,6 +58,7 @@ namespace l
IFERT("branches-mount-timeout");
IFERT("cache.symlinks");
IFERT("cache.writeback");
IFERT("direct-io-allow-mmap");
IFERT("export-support");
IFERT("fsname");
IFERT("fuse_msg_size");
@@ -94,6 +95,7 @@ Config::Config()
cache_symlinks(false),
category(func),
direct_io(false),
direct_io_allow_mmap(true),
dropcacheonclose(false),
export_support(true),
flushonclose(FlushOnClose::ENUM::OPENED_FOR_WRITE),
@@ -150,6 +152,7 @@ Config::Config()
_map["category.create"] = &category.create;
_map["category.search"] = &category.search;
_map["direct_io"] = &direct_io;
_map["direct-io-allow-mmap"] = &direct_io_allow_mmap;
_map["dropcacheonclose"] = &dropcacheonclose;
_map["export-support"] = &export_support;
_map["flush-on-close"] = &flushonclose;
+1
View File
@@ -117,6 +117,7 @@ public:
ConfigBOOL cache_symlinks;
Categories category;
ConfigBOOL direct_io;
ConfigBOOL direct_io_allow_mmap;
ConfigBOOL dropcacheonclose;
ConfigBOOL export_support;
FlushOnClose flushonclose;
+5 -1
View File
@@ -25,7 +25,11 @@
#include <fstream>
#include <string>
#include <sys/sysmacros.h>
#ifdef __FreeBSD__
# include <sys/types.h>
#else
# include <sys/sysmacros.h>
#endif
namespace l
{
+9 -1
View File
@@ -18,8 +18,16 @@
#pragma once
#ifdef __FreeBSD__
# include <sys/param.h>
# include <sys/mount.h>
# define umount2(target,flags) unmount(target,flags)
# define MNT_DETACH 0
#else
# include <sys/mount.h>
#endif
#include <errno.h>
#include <sys/mount.h>
#include <string>
+2 -1
View File
@@ -144,14 +144,15 @@ namespace FUSE
l::want_if_capable(conn_,FUSE_CAP_ATOMIC_O_TRUNC);
l::want_if_capable(conn_,FUSE_CAP_BIG_WRITES);
l::want_if_capable(conn_,FUSE_CAP_CACHE_SYMLINKS,&cfg->cache_symlinks);
l::want_if_capable(conn_,FUSE_CAP_DIRECT_IO_ALLOW_MMAP,&cfg->direct_io_allow_mmap);
l::want_if_capable(conn_,FUSE_CAP_DONT_MASK);
l::want_if_capable(conn_,FUSE_CAP_EXPORT_SUPPORT,&cfg->export_support);
l::want_if_capable(conn_,FUSE_CAP_IOCTL_DIR);
l::want_if_capable(conn_,FUSE_CAP_PARALLEL_DIROPS);
l::want_if_capable(conn_,FUSE_CAP_POSIX_ACL,&cfg->posix_acl);
l::want_if_capable(conn_,FUSE_CAP_READDIR_PLUS,&cfg->readdirplus);
// l::want_if_capable(conn_,FUSE_CAP_READDIR_PLUS_AUTO);
l::want_if_capable(conn_,FUSE_CAP_WRITEBACK_CACHE,&cfg->writeback_cache);
// l::want_if_capable(conn_,FUSE_CAP_READDIR_PLUS_AUTO);
l::want_if_capable_max_pages(conn_,cfg);
conn_->want &= ~FUSE_CAP_POSIX_LOCKS;
conn_->want &= ~FUSE_CAP_FLOCK_LOCKS;
+26 -10
View File
@@ -1,21 +1,37 @@
#!/usr/bin/env sh
if [ $# != 3 ]; then
echo "usage: $0 <cache-fs> <backing-pool> <percentage>"
exit 1
echo "usage: $0 <cache-fs> <base-pool> <percentage>"
exit 1
fi
CACHE="${1}"
BACKING="${2}"
CACHEFS="${1}"
BASEPOOL="${2}"
PERCENTAGE=${3}
set -o errexit
while [ $(df --output=pcent "${CACHE}" | grep -v Use | cut -d'%' -f1) -gt ${PERCENTAGE} ]
while [ $(df "${CACHE}" | tail -n1 | awk '{print $5}' | cut -d'%' -f1) -gt ${PERCENTAGE} ]
do
# Find the file with the oldest access time
FILE=$(find "${CACHE}" -type f -printf '%A@ %P\n' | \
sort | \
head -n 1 | \
cut -d' ' -f2-)
test -n "${FILE}"
rsync -axqHAXWESR --preallocate --remove-source-files "${CACHE}/./${FILE}" "${BACKING}/"
sort | \
head -n 1 | \
cut -d' ' -f2-)
# If no file found, exit
test -n "${FILE}" || exit 0
# Move file
rsync \
--archive \
--acls \
--xattrs \
--atimes \
--hard-links \
--one-file-system \
--quiet \
--preallocate \
--remove-source-files \
--relative \
--log-file=/tmp/mergerfs-cache-rsync.log \
"${CACHE}/./${FILE}" \
"${BACKING}/"
done
+20 -7
View File
@@ -1,13 +1,26 @@
#!/usr/bin/env sh
if [ $# != 3 ]; then
echo "usage: $0 <cache-fs> <backing-pool> <days-old>"
exit 1
echo "usage: $0 <cache-fs> <base-pool> <days-old>"
exit 1
fi
CACHE="${1}"
BACKING="${2}"
N=${3}
CACHEFS="${1}"
BASEPOOL="${2}"
DAYS_OLD=${3}
find "${CACHE}" -type f -atime +${N} -printf '%P\n' | \
rsync --files-from=- -axqHAXWES --preallocate --remove-source-files "${CACHE}/" "${BACKING}/"
find "${CACHEFS}" -type f -atime +${DAYS_OLD} -printf '%P\n' | \
rsync \
--files-from=- \
--archive \
--acls \
--xattrs \
--atimes \
--hard-links \
--one-file-system \
--quiet \
--preallocate \
--remove-source-files \
--log-file=/tmp/mergerfs-cache-rsync.log \
"${CACHEFS}/" \
"${BASEPOOL}/"
+13 -9
View File
@@ -16,8 +16,12 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef __FreeBSD__
#define O_TMPFILE 0
#else
#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L
//#define _POSIX_C_SOURCE 200809L
#endif
#include <assert.h>
#include <dlfcn.h>
@@ -107,7 +111,7 @@ open(const char *pathname_,
LOAD_FUNC(open);
mode = 0;
if(flags_ & O_CREAT)
if(flags_ & (O_CREAT|O_TMPFILE))
{
va_list args;
va_start(args,flags_);
@@ -119,7 +123,7 @@ open(const char *pathname_,
if(fd == -1)
return -1;
if(flags_ & (O_DIRECTORY|O_PATH))
if(flags_ & (O_DIRECTORY|O_PATH|O_TMPFILE))
return fd;
rv = fstat(fd,&st);
if(rv == -1)
@@ -155,7 +159,7 @@ open64(const char *pathname_,
LOAD_FUNC(open64);
mode = 0;
if(flags_ & O_CREAT)
if(flags_ & (O_CREAT|O_TMPFILE))
{
va_list args;
va_start(args,flags_);
@@ -167,7 +171,7 @@ open64(const char *pathname_,
if(fd == -1)
return -1;
if(flags_ & (O_DIRECTORY|O_PATH))
if(flags_ & (O_DIRECTORY|O_PATH|O_TMPFILE))
return fd;
rv = fstat(fd,&st);
if(rv == -1)
@@ -204,7 +208,7 @@ openat(int dirfd_,
LOAD_FUNC(openat);
mode = 0;
if(flags_ & O_CREAT)
if(flags_ & (O_CREAT|O_TMPFILE))
{
va_list args;
va_start(args,flags_);
@@ -216,7 +220,7 @@ openat(int dirfd_,
if(fd == -1)
return -1;
if(flags_ & (O_DIRECTORY|O_PATH))
if(flags_ & (O_DIRECTORY|O_PATH|O_TMPFILE))
return fd;
rv = fstat(fd,&st);
if(rv == -1)
@@ -253,7 +257,7 @@ openat64(int dirfd_,
LOAD_FUNC(openat64);
mode = 0;
if(flags_ & O_CREAT)
if(flags_ & (O_CREAT|O_TMPFILE))
{
va_list args;
va_start(args,flags_);
@@ -265,7 +269,7 @@ openat64(int dirfd_,
if(fd == -1)
return -1;
if(flags_ & (O_DIRECTORY|O_PATH))
if(flags_ & (O_DIRECTORY|O_PATH|O_TMPFILE))
return fd;
rv = fstat(fd,&st);
if(rv == -1)