HomeFreeBSD

Fix nfs_truncate_shares without /etc/exports.d

Description

Fix nfs_truncate_shares without /etc/exports.d

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: ede037cda73675f42b1452187e8dd3438fafc220
("Make zfs-share service resilient to stale exports")

Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Closes #15369
Closes #15468

Details

Provenance
siv0 <github@nomore.at>Authored on Oct 31 2023, 8:57 PM
GitHub <noreply@github.com>Committed on Oct 31 2023, 8:57 PM
Parents
rG763ca47fa818: Fix block cloning between unencrypted and encrypted datasets
Branches
Unknown
Tags
Unknown