Backport #15468 to 2.2: Fix nfs_truncate_shares without /etc/exports.d #17993
+18
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Calling nfs_reset_shares on Linux prints a warning:
failed to lock /etc/exports.d/zfs.exports.lock: No such file or directorywhen /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 incmd/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/exportfsis present through thenfs-kernel-serverpackage.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?
zfs-2.2.10-stagingzfs share -ano longer segfaultTypes of changes
Checklist:
Signed-off-by.