From ede037cda73675f42b1452187e8dd3438fafc220 Mon Sep 17 00:00:00 2001 From: Don Brady Date: Fri, 9 Sep 2022 11:54:16 -0600 Subject: 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 Reviewed-by: Brian Behlendorf Signed-off-by: Don Brady Closes #13775 --- lib/libzfs/libzfs.abi | 55 +++++++++++++++++++++++++++++++++-------------- lib/libzfs/libzfs_mount.c | 12 ++++++++++- 2 files changed, 50 insertions(+), 17 deletions(-) (limited to 'lib/libzfs') diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index 0494aec20..7dd12df81 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -245,6 +245,7 @@ + @@ -428,6 +429,7 @@ + @@ -758,6 +760,10 @@ + + + + @@ -787,7 +793,7 @@ - + @@ -803,6 +809,9 @@ + + + @@ -816,6 +825,8 @@ + + @@ -832,6 +843,9 @@ + + + @@ -2302,6 +2316,7 @@ + @@ -3034,6 +3049,10 @@ + + + + @@ -3150,6 +3169,7 @@ + @@ -3750,7 +3770,7 @@ - + @@ -3790,6 +3810,9 @@ + + + @@ -3903,16 +3926,17 @@ + - + - + @@ -4032,8 +4056,8 @@ - - + + @@ -4102,15 +4126,15 @@ - + - - + + @@ -4123,7 +4147,7 @@ - + @@ -4771,8 +4795,8 @@ - - + + @@ -4872,7 +4896,7 @@ - + @@ -4935,7 +4959,7 @@ - + @@ -5013,7 +5037,7 @@ - + @@ -5455,7 +5479,6 @@ - diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index fdfdd8d28..44f7d698c 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -22,7 +22,7 @@ /* * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2014, 2021 by Delphix. All rights reserved. + * Copyright (c) 2014, 2022 by Delphix. All rights reserved. * Copyright 2016 Igor Kozhukhov * Copyright 2017 RackTop Systems. * Copyright (c) 2018 Datto Inc. @@ -788,6 +788,16 @@ zfs_commit_shares(const enum sa_protocol *proto) sa_commit_shares(*p); } +void +zfs_truncate_shares(const enum sa_protocol *proto) +{ + if (proto == NULL) + proto = share_all_proto; + + for (const enum sa_protocol *p = proto; *p != SA_NO_PROTOCOL; ++p) + sa_truncate_shares(*p); +} + /* * Unshare the given filesystem. */ -- cgit v1.2.3