[pve-devel] [PATCH storage] zfs: set cachefile=none when creating pool

Oguz Bektas o.bektas at proxmox.com
Thu Mar 5 15:37:58 CET 2020


hi,

On Thu, Mar 05, 2020 at 03:21:11PM +0100, Thomas Lamprecht wrote:
> On 3/5/20 2:16 PM, Oguz Bektas wrote:
> > the first rpool we create during setup with our installer has
> > cachefile=none set.
> > 
> > when this isn't specified, zfs defaults to /etc/zfs/zpool.cache
> > which later can cause problems
> > 
> > [0]: https://forum.proxmox.com/threads/zfs-mirror-werden-nach-reboot-nicht-mehr-automatisch-gemountet.66222/#post-298984
> 
> can you please elaborate a bit why this is OK, why and which problems are
> being caused without this. I'm not saying it's wrong, I just want some
> real rationale in the commit message, thanks!

of course.

i started looking into this after many users in forum started talking
about their zvols not being mounted after reboot, which seems to get
fixed after updating the cachefile.
except we don't use a cachefile by default when creating the first
'rpool' during setup (see pve-installer code).

however in the storage code pools are created without the
'cachefile=none' option, which results in zfs using the default
cachefile. (cachefile doesn't exist before that)

after creating a pool without the explicit option (using our GUI for
example where this bit of code gets called), /etc/zfs/zpool.cache
cachefile is created which results in systemd deciding to use the
import-cache service instead.

that's also most likely the reason the cachefile gets outdated (which
results in the problem in the forum post)
> 
> > 
> > Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> > ---
> >  PVE/API2/Disks/ZFS.pm | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/PVE/API2/Disks/ZFS.pm b/PVE/API2/Disks/ZFS.pm
> > index 551f21a..78484eb 100644
> > --- a/PVE/API2/Disks/ZFS.pm
> > +++ b/PVE/API2/Disks/ZFS.pm
> > @@ -371,7 +371,7 @@ __PACKAGE__->register_method ({
> >  	    PVE::Diskmanage::locked_disk_action(sub {
> >  		# create zpool with desired raidlevel
> >  
> > -		my $cmd = [$ZPOOL, 'create', '-o', "ashift=$ashift", $name];
> > +		my $cmd = [$ZPOOL, 'create', '-o', "cachefile=none", "ashift=$ashift", $name];
> >  
> >  		if ($raidlevel eq 'raid10') {
> >  		    for (my $i = 0; $i < @$devs; $i+=2) {
> > 
> 




More information about the pve-devel mailing list