zfs-import-{cache,scan}: change condition to FileNotEmpty

When all pools are exported ZFS will generate an empty cache file.
This will cause the import service to fail, which is sub-optimal, 
since this means that dracut fails, and it necessary to run 
`zpool import -a` to boot, delete the file, and regenerate+reinstall 
the initrd.

This resolves the issue by treating an zero-length cache files the
same as a missing cache file.  This aligns the behavior with that
of the `zpool` command itself.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11568
This commit is contained in:
наб 2021-02-05 20:25:22 +01:00 committed by GitHub
parent 32366649d3
commit 7c64ee9e77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -8,7 +8,7 @@ After=cryptsetup.target
After=multipathd.target After=multipathd.target
After=systemd-remount-fs.service After=systemd-remount-fs.service
Before=zfs-import.target Before=zfs-import.target
ConditionPathExists=@sysconfdir@/zfs/zpool.cache ConditionFileNotEmpty=@sysconfdir@/zfs/zpool.cache
ConditionPathIsDirectory=/sys/module/zfs ConditionPathIsDirectory=/sys/module/zfs
[Service] [Service]

View File

@ -7,7 +7,7 @@ After=systemd-udev-settle.service
After=cryptsetup.target After=cryptsetup.target
After=multipathd.target After=multipathd.target
Before=zfs-import.target Before=zfs-import.target
ConditionPathExists=!@sysconfdir@/zfs/zpool.cache ConditionFileNotEmpty=!@sysconfdir@/zfs/zpool.cache
ConditionPathIsDirectory=/sys/module/zfs ConditionPathIsDirectory=/sys/module/zfs
[Service] [Service]