diff options
author | Don Brady <[email protected]> | 2022-09-09 11:54:16 -0600 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-09 10:54:16 -0700 |
commit | ede037cda73675f42b1452187e8dd3438fafc220 (patch) | |
tree | faa6d73ad888591c98ffb9b962ca6d13c6feb695 /lib/libshare/nfs.c | |
parent | 60d995727a19104a2832d475f5c0861ffbae2c97 (diff) |
Make zfs-share service resilient to stale exports
The are a few cases where stale entries in /etc/exports.d/zfs.exports
will cause the nfs-server service to fail when starting up.
Since the nfs-server startup consumes /etc/exports.d/zfs.exports, the
zfs-share service (which rebuilds the list of zfs exports) should run
before the nfs-server service.
To make the zfs-share service resilient to stale exports, this change
truncates the zfs config file as part of the zfs share -a operation.
Reviewed-by: Allan Jude <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Don Brady <[email protected]>
Closes #13775
Diffstat (limited to 'lib/libshare/nfs.c')
-rw-r--r-- | lib/libshare/nfs.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/libshare/nfs.c b/lib/libshare/nfs.c index 161bbfb0c..bbaea93fc 100644 --- a/lib/libshare/nfs.c +++ b/lib/libshare/nfs.c @@ -28,6 +28,7 @@ #include <stdio.h> #include <errno.h> #include <libshare.h> +#include <unistd.h> #include "nfs.h" @@ -281,6 +282,17 @@ fullerr: return (error); } +void +nfs_reset_shares(const char *lockfile, const char *exports) +{ + int nfs_lock_fd = -1; + + if (nfs_exports_lock(lockfile, &nfs_lock_fd) == 0) { + (void) ! truncate(exports, 0); + nfs_exports_unlock(lockfile, &nfs_lock_fd); + } +} + static boolean_t nfs_is_shared_cb(void *userdata, char *line, boolean_t found_mountpoint) { |