mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-01-12 19:20:28 +03:00
Let zpool import
ignore a missing hostid record.
Change the zpool program to skip its hostid mismatch check in the same way that libzfs already does. Invoked imports fail if the ZPOOL_CONFIG_HOSTID nvpair is missing in the /etc/zfs/zpool.cache file, which can happen as of the /etc/hostid deprecation in commit zfsonlinux/spl@acf0ade362. Signed-off-by: Darik Horn <dajhorn@vanadac.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #2794
This commit is contained in:
parent
33074f2254
commit
d94fd5f0de
@ -1914,37 +1914,30 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
|
|||||||
return (1);
|
return (1);
|
||||||
} else if (state != POOL_STATE_EXPORTED &&
|
} else if (state != POOL_STATE_EXPORTED &&
|
||||||
!(flags & ZFS_IMPORT_ANY_HOST)) {
|
!(flags & ZFS_IMPORT_ANY_HOST)) {
|
||||||
uint64_t hostid;
|
uint64_t hostid = 0;
|
||||||
|
unsigned long system_hostid = gethostid() & 0xffffffff;
|
||||||
|
|
||||||
if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_HOSTID,
|
(void) nvlist_lookup_uint64(config, ZPOOL_CONFIG_HOSTID,
|
||||||
&hostid) == 0) {
|
&hostid);
|
||||||
unsigned long system_hostid = gethostid() & 0xffffffff;
|
|
||||||
|
|
||||||
if ((unsigned long)hostid != system_hostid) {
|
if (hostid != 0 && (unsigned long)hostid != system_hostid) {
|
||||||
char *hostname;
|
char *hostname;
|
||||||
uint64_t timestamp;
|
uint64_t timestamp;
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
verify(nvlist_lookup_string(config,
|
verify(nvlist_lookup_string(config,
|
||||||
ZPOOL_CONFIG_HOSTNAME, &hostname) == 0);
|
ZPOOL_CONFIG_HOSTNAME, &hostname) == 0);
|
||||||
verify(nvlist_lookup_uint64(config,
|
verify(nvlist_lookup_uint64(config,
|
||||||
ZPOOL_CONFIG_TIMESTAMP, ×tamp) == 0);
|
ZPOOL_CONFIG_TIMESTAMP, ×tamp) == 0);
|
||||||
t = timestamp;
|
t = timestamp;
|
||||||
(void) fprintf(stderr, gettext("cannot import "
|
(void) fprintf(stderr, gettext("cannot import "
|
||||||
"'%s': pool may be in use from other "
|
"'%s': pool may be in use from other "
|
||||||
"system, it was last accessed by %s "
|
"system, it was last accessed by %s "
|
||||||
"(hostid: 0x%lx) on %s"), name, hostname,
|
"(hostid: 0x%lx) on %s"), name, hostname,
|
||||||
(unsigned long)hostid,
|
(unsigned long)hostid,
|
||||||
asctime(localtime(&t)));
|
asctime(localtime(&t)));
|
||||||
(void) fprintf(stderr, gettext("use '-f' to "
|
(void) fprintf(stderr, gettext("use '-f' to "
|
||||||
"import anyway\n"));
|
"import anyway\n"));
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
(void) fprintf(stderr, gettext("cannot import '%s': "
|
|
||||||
"pool may be in use from other system\n"), name);
|
|
||||||
(void) fprintf(stderr, gettext("use '-f' to import "
|
|
||||||
"anyway\n"));
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user