fix(mount): do not truncate shares not zfs mount

When running zfs share -a resetting the exports.d/zfs.exports makes
sense the get a clean state.
Truncating was also called with zfs mount which would not populate the
file again.
Add test to verify shares persist after mount -a.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Closes #15607 
Closes #15660
This commit is contained in:
Stefan Lendl
2024-01-12 21:05:11 +01:00
committed by Brian Behlendorf
parent 8b1c6db3d2
commit 4db88c37cc
4 changed files with 67 additions and 2 deletions
+2 -1
View File
@@ -7230,7 +7230,8 @@ share_mount(int op, int argc, char **argv)
pthread_mutex_init(&share_mount_state.sm_lock, NULL);
/* For a 'zfs share -a' operation start with a clean slate. */
zfs_truncate_shares(NULL);
if (op == OP_SHARE)
zfs_truncate_shares(NULL);
/*
* libshare isn't mt-safe, so only do the operation in parallel