forked from openzfs/zfs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openzfs#14 from bgly/fixes
Fixes
- Loading branch information
Showing
20 changed files
with
474 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
debian/tree/zfsutils-linux/usr/lib/zfs-linux/share-cleanup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash -u | ||
|
||
# | ||
# Copyright (c) 2019 by Delphix. All rights reserved. | ||
# | ||
|
||
# | ||
# Cleanup the ZFS exports | ||
# | ||
# The zfs-share service generates 'zfs.exports' which is consumed by the | ||
# nfs-server service in ExecStartPre. To catch any zfs shares that were | ||
# enabled since the zfs-share service started, we must re-generate the | ||
# 'zfs.exports' file and check for any changes. If there is a delta, we | ||
# run 'exportfs -a' to export the new additions. | ||
# | ||
|
||
function die() { | ||
echo "$(basename $0): $1" >&2 | ||
# always remove the zfs.exports file | ||
if [[ -f "$ZFS_EXPORTS" ]]; then | ||
/bin/rm -f "$ZFS_EXPORTS" | ||
fi | ||
exit 1 | ||
} | ||
|
||
ZFS_EXPORTS=/etc/exports.d/zfs.exports | ||
ZFS_EXPORTS_BAK=${ZFS_EXPORTS}.bak | ||
changes=0 | ||
|
||
if [[ -f "$ZFS_EXPORTS" ]]; then | ||
# save the zfs-share service generated copy | ||
/bin/mv -f "$ZFS_EXPORTS" "$ZFS_EXPORTS_BAK" || die "rename failed" | ||
|
||
# generate a new zfs.exports | ||
/sbin/zfs share -g || die "failed to generate zfs exports" | ||
|
||
cmp --silent "$ZFS_EXPORTS" "$ZFS_EXPORTS_BAK" | ||
changes=$? | ||
|
||
/bin/rm -f "$ZFS_EXPORTS_BAK" | ||
|
||
[[ $changes -eq 2 ]] && die "compare failed" | ||
else | ||
# generate a new zfs.exports | ||
/sbin/zfs share -g || die "failed to generate zfs exports" | ||
if [[ -f "$ZFS_EXPORTS" ]]; then | ||
changes=1 | ||
fi | ||
fi | ||
|
||
# if the zfs.exports content has changed then re-export | ||
if [[ $changes -eq 1 ]]; then | ||
shares=$(wc -l < $ZFS_EXPORTS) | ||
echo re-exporting, zfs shares exported: $shares | ||
/usr/sbin/exportfs -a || die "re-exporting failed" | ||
fi | ||
|
||
/bin/rm -f "$ZFS_EXPORTS" | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[Unit] | ||
Description=ZFS file system shares cleanup | ||
After=nfs-server.service | ||
PartOf=nfs-server.service nfs-kernel-server.service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=-/usr/lib/zfs-linux/share-cleanup | ||
|
||
[Install] | ||
WantedBy=zfs.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.