Skip to content

Conversation

@alex-moch
Copy link

@alex-moch alex-moch commented Nov 29, 2025

Calling nfs_reset_shares on Linux prints a warning: failed to lock /etc/exports.d/zfs.exports.lock: No such file or directory
when /etc/exports.d does not exist. The directory gets created, when a filesystem is actually exported through nfs_toggle_share and nfs_init_share. The truncation of /etc/exports.d/zfs.exports happens unconditionally when calling zfs mount -a (via zfs_do_mount and share_mount in cmd/zfs/zfs_main.c).

Fixing the issue only in the Linux part, since the exports file on freebsd is in /etc/zfs/, which seems present on 2 FreeBSD systems I have access to (through /etc/zfs/compatibility.d/), while a Debian box does not have the directory even if /usr/sbin/exportfs is present through the nfs-kernel-server package.

The code for exports_available is copied from nfs_available above.

Fixes: ede037c
("Make zfs-share service resilient to stale exports")

Reviewed-by: Brian Atkinson [email protected]
Reviewed-by: Brian Behlendorf [email protected]

Closes #15369
Closes #15468


Motivation and Context

Backport of #15468 to the zfs-2.2.10-staging branch.

Fixes #15369 and #17967

Description

Clean cherry-pick of commit 41e55b4 from master to zfs-2.2.10-staging.

The fix adds an exports_available() check before attempting to truncate the exports file, preventing the segfault when the directory doesn't exist.

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@github-actions github-actions bot added the Status: Work in Progress Not yet ready for general review label Nov 29, 2025
Calling nfs_reset_shares on Linux prints a warning:
`failed to lock /etc/exports.d/zfs.exports.lock: No such file or
directory`
when /etc/exports.d does not exist. The directory gets created, when a
filesystem is actually exported through nfs_toggle_share and
nfs_init_share. The truncation of /etc/exports.d/zfs.exports happens
unconditionally when calling `zfs mount -a` (via zfs_do_mount and
share_mount in `cmd/zfs/zfs_main.c`).

Fixing the issue only in the Linux part, since the exports file on
freebsd is in `/etc/zfs/`, which seems present on 2 FreeBSD systems I
have access to (through `/etc/zfs/compatibility.d/`), while a Debian
box does not have the directory even if `/usr/sbin/exportfs` is
present through the `nfs-kernel-server` package.

The code for exports_available is copied from nfs_available above.

Fixes: ede037c
("Make zfs-share service resilient to stale exports")

Reviewed-by: Brian Atkinson <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Stoiko Ivanov <[email protected]>
Closes openzfs#15369
Closes openzfs#15468
(cherry picked from commit 41e55b4)
Signed-off-by: Alexander Moch <[email protected]>
@alex-moch alex-moch marked this pull request as ready for review November 29, 2025 18:01
@github-actions github-actions bot added Status: Code Review Needed Ready for review and testing and removed Status: Work in Progress Not yet ready for general review labels Nov 29, 2025
@alex-moch alex-moch changed the base branch from zfs-2.2-release to zfs-2.2.10-staging December 1, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Code Review Needed Ready for review and testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants