openzfsonwindows / ZFSin

OpenZFS on Windows port

Home Page:https://openzfsonwindows.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Import pools from zpool.cache

lundman opened this issue · comments

Now that we have a zpool.cache location and support routines, we should add the feature to import the pools listed in the cache file, as expected from ZFS.

Do you mean zpool import -a -c should work ? if so, then it is already working:

> zpool status
no pools available
> zpool import -a -c "C:\Windows\System32\drivers\zpool.cache"
> zpool status
  pool: tank
  state: ONLINE
  scan: none requested
config:
 
        NAME                   STATE     READ WRITE CKSUM
        tank                   ONLINE       0     0     0
          /dev/physicaldrive1  ONLINE       0     0     0
 
errors: No known data errors

The "zpool.cache" file just keeps a list of pools that was still in "imported state" before a reboot. After the reboot, (when the driver is loaded) it automatically loads zpool.cache and imports them again.

Hmm since you guys added zfs_file_open() - it might already work. Worth trying
https://github.com/openzfsonwindows/ZFSin/blob/master/ZFSin/zfs/module/zfs/spa_config.c#L71

since zfs_autoimport_disable is true by default then spa_config_load will not import zpools by default when driver is loaded:

#ifdef _KERNEL
if (zfs_autoimport_disable)
return;
#endif

On Linux also startup scripts import zpools, it is not auto-imported by the zfs module.

illumos (the original) reads the cache file, Linux added the disable and went for scripts. I am unsure why at the moment. But you can enable it when you load the module on Linux, and I suppose that also works in Windows.

Ideally it should work, but I don't see zfs_autoimport_disable is tunable through kstat in Windows. Maybe that is what should be added?

Ah, I must have missed it - but yeah, then users can just set it on and registry and everything works