From 951eb9540d0ccdb9f9654046504e3cd9532f3177 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Sun, 25 Feb 2024 17:03:47 -0600 Subject: [PATCH 1/2] Ensure lookups of FUSE_ROOT_ID always return generation=0 --- libfuse/lib/fuse.c | 11 ++++++++++- libfuse/lib/fuse_lowlevel.c | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libfuse/lib/fuse.c b/libfuse/lib/fuse.c index f766f334..3cb3b5ad 100644 --- a/libfuse/lib/fuse.c +++ b/libfuse/lib/fuse.c @@ -1375,7 +1375,7 @@ set_path_info(struct fuse *f, return -ENOMEM; e->ino = node->nodeid; - e->generation = f->nodeid_gen.generation; + e->generation = ((e->ino == FUSE_ROOT_ID) ? 0 : f->nodeid_gen.generation); pthread_mutex_lock(&f->lock); update_stat(node,&e->attr); @@ -1386,6 +1386,15 @@ set_path_info(struct fuse *f, return 0; } +/* + lookup requests only come in for FUSE_ROOT_ID when a "parent of + child of root node" request is made. This can happen when using + EXPORT_SUPPORT=true and a file handle is used to keep a reference to + a node which has been forgotten. Mostly a NFS concern but not + excluslively. Root node always has a nodeid of 1 and generation of + 0. To ensure this set_path_info() explicitly ensures the root id has + a generation of 0. + */ static int lookup_path(struct fuse *f, diff --git a/libfuse/lib/fuse_lowlevel.c b/libfuse/lib/fuse_lowlevel.c index 37f24dd3..96511568 100644 --- a/libfuse/lib/fuse_lowlevel.c +++ b/libfuse/lib/fuse_lowlevel.c @@ -294,6 +294,11 @@ fuse_reply_entry(fuse_req_t req, fill_entry(&arg, e); +#ifdef NDEBUG + // TODO: Add checks for cases where a node could be marked bad by + // the kernel. +#endif + return send_reply_ok(req, &arg, size); } From a234e9446c304fa09237d4949ecce21b49e36add Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Sun, 25 Feb 2024 17:27:08 -0600 Subject: [PATCH 2/2] Update README to remove unnecessary references to export-support for NFS --- README.md | 51 ++++++++++++++------------------------------- man/mergerfs.1 | 56 +++++++++++++++----------------------------------- 2 files changed, 31 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index f4d5c7ac..f303acfa 100644 --- a/README.md +++ b/README.md @@ -682,21 +682,13 @@ is empty is opened for writing. 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 with -NFS. mergerfs does support these messages but due to a possible bug in -the Linux kernel this option needs to be configurable. As it turns out -at least certain versions of NFS can still work when disabled and no -longer triggers the bug. - -While it may be safe to default this setting to `false` in an -abundance of caution it is being left enabled by default. +NFS. mergerfs does support these messages but due 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. -See [Kernel Issues & -Bugs](https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs) -for more details. - # FUNCTIONS, CATEGORIES and POLICIES @@ -2047,17 +2039,19 @@ 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 till situations -change. That said issues should still be reported. NFS is not really -recommended but it isn't unsupported. +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 till situations change. 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 -* export-support=false (only available in v2.40.0 and above) NFS export settings: * fsid=UUID @@ -2080,32 +2074,17 @@ 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. It might be possible to leave the default value of -`hybrid-hash` if `export-support=false` but it hasn't been fully -tested yet. - -`export-support=false` is a low-level FUSE option that is needed as a -workaround to a Linux kernel bug. Technically this option should be -set to `true` when expecting to use mergerfs with NFS but it turns out -that at least some versions of NFS work when not enabled. At the -moment it is unclear if this has any negative side effects but when -disabled NFS appears to work alright and the kernel no longer sends -invalid requests. When the issue is resolved in the kernel these docs -will be updated with appropriate details. - -Also see [Kernel Issues & -Bugs](https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs) -for more details. +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 `uuidgen` or through a website such as +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. +permission and ownership issues if root squashing is enabled. ## SMB / CIFS diff --git a/man/mergerfs.1 b/man/mergerfs.1 index 27a01cf3..a78a4baa 100644 --- a/man/mergerfs.1 +++ b/man/mergerfs.1 @@ -115,7 +115,7 @@ start with one of the following option sets. \f[C]mergerfs -o cache.files=partial,dropcacheonclose=true,category.create=mfs /mnt/hdd0:/mnt/hdd1 /media\f[R] .SS /etc/fstab .PP -\f[C]/mnt/hdd0:/mnt/hdd1 /media fuse.mergerfs cache.files=partial,dropcacheonclose=true,category.create=mfs 0 0\f[R] +\f[C]/mnt/hdd0:/mnt/hdd1 /media mergerfs cache.files=partial,dropcacheonclose=true,category.create=mfs 0 0\f[R] .SS systemd mount .PP https://github.com/trapexit/mergerfs/wiki/systemd @@ -516,8 +516,8 @@ tools use \f[B]/etc/fstab\f[R]. .IP .nf \f[C] -# -/mnt/hdd*:/mnt/ssd /media fuse.mergerfs minfreespace=16G 0 0 +# +/mnt/hdd*:/mnt/ssd /media mergerfs minfreespace=16G 0 0 \f[R] .fi .PP @@ -847,20 +847,12 @@ 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 with NFS. -mergerfs does support these messages but due to a possible bug in the -Linux kernel this option needs to be configurable. -As it turns out at least certain versions of NFS can still work when -disabled and no longer triggers the bug. -.PP -While it may be safe to default this setting to \f[C]false\f[R] in an -abundance of caution it is being left enabled by default. +mergerfs does support these messages but due bugs and quirks found in +the kernel and mergerfs this option is provided just in case it is +needed for debugging. .PP Given that this flag is set when the FUSE connection is first initiated it is not possible to change during run time. -.PP -See Kernel Issues & -Bugs (https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs) -for more details. .SH FUNCTIONS, CATEGORIES and POLICIES .PP The POSIX filesystem API is made up of a number of functions. @@ -1577,8 +1569,8 @@ apply those before mounting the new version. \f[C] $ sudo mount /mnt/mergerfs $ mount | grep mergerfs -media on /mnt/mergerfs type fuse.mergerfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other) -media on /mnt/mergerfs type fuse.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) +media on /mnt/mergerfs type mergerfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other) \f[R] .fi .PP @@ -2588,11 +2580,13 @@ 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 till situations change. -That said issues should still be reported. -NFS is not really recommended but it isn\[cq]t unsupported. +That said mergerfs should generally work as an export of NFS and issues +discovered should still be reported. +.PP +To ensure compatibility between mergerfs and NFS use the following +settings. .PP -mergerfs settings: * noforget * inodecalc=path-hash * -export-support=false (only available in v2.40.0 and above) +mergerfs settings: * noforget * inodecalc=path-hash .PP NFS export settings: * fsid=UUID * no_root_squash .PP @@ -2618,35 +2612,17 @@ mergerfs will use will be on a different branch and therefore the inode would change. This isn\[cq]t an ideal solution and others are being considered but it works for most situations. -It might be possible to leave the default value of \f[C]hybrid-hash\f[R] -if \f[C]export-support=false\f[R] but it hasn\[cq]t been fully tested -yet. -.PP -\f[C]export-support=false\f[R] is a low-level FUSE option that is needed -as a workaround to a Linux kernel bug. -Technically this option should be set to \f[C]true\f[R] when expecting -to use mergerfs with NFS but it turns out that at least some versions of -NFS work when not enabled. -At the moment it is unclear if this has any negative side effects but -when disabled NFS appears to work alright and the kernel no longer sends -invalid requests. -When the issue is resolved in the kernel these docs will be updated with -appropriate details. -.PP -Also see Kernel Issues & -Bugs (https://github.com/trapexit/mergerfs/wiki/Kernel-Issues-&-Bugs) -for more details. .PP \f[C]fsid=UUID\f[R] is needed because FUSE filesystems don\[cq]t have different \f[C]st_dev\f[R] values which can cause issues when exporting. The easiest thing to do is set each mergerfs export \f[C]fsid\f[R] to some random value. An easy way to generate a random value is to use the command line tool -\f[C]uuidgen\f[R] or through a website such as +\f[C]uuid\f[R] or \f[C]uuidgen\f[R] or through a website such as uuidgenerator.net (https://www.uuidgenerator.net/). .PP \f[C]no_root_squash\f[R] is not strictly necessary but can lead to -confusing permission and ownership issues. +confusing permission and ownership issues if root squashing is enabled. .SS SMB / CIFS .PP SMB (https://en.wikipedia.org/wiki/Server_Message_Block) is a protocol