zfs: Expose hostid to zfs, as in gethostid/sethostid(3).

If set to nonzero, the hostid is recorded in the metadata of a zpool,
and checked by `zpool import' when the pool has not been explicitly
exported.  After reboot, zpool import will not need `-f' to reimport
the pool.

Setting the hostid must be done explicitly through sysctl (or the
sethostid(3) library call) on all ports except acorn32, amiga,
mvme68k, newsmips, sparc, sparc64, sun2, and sun3.  So for most users
this change will have no immediate effect.  But you can obviate the
need for `zpool import -f' by adding `kern.hostid=123456789' to
/etc/sysctl.conf and importing the pool one last time with `-f'.
This commit is contained in:
riastradh 2021-12-28 17:51:23 +00:00
parent 77e13755e6
commit 11ba2468a1
1 changed files with 2 additions and 1 deletions

View File

@ -130,6 +130,7 @@ extern "C" {
#include <vm/vnode_pager.h>
#else /* !__NetBSD__ */
#include <sys/callout.h>
#include <sys/kernel.h>
#include <sys/stdarg.h>
#include <miscfs/specfs/specdev.h>
@ -165,7 +166,7 @@ extern "C" {
#define td_ru l_ru
#define UID_NOBODY (32767)
#define vnode_pager_setsize(vp, size) zfs_netbsd_setsize(vp, size)
#define zone_get_hostid(a) 0
#define zone_get_hostid(a) ((unsigned)hostid)
extern struct utsname utsname;