.BI \--stripe-count-hint= stripes
Used for optizing MDT inode size
.TP
+.BI \--force-nohostid
+Ignore unset hostid for ZFS import protection. To set hostid either set
+spl_hostid parameter for spl.ko or set /etc/hostid, see genhostid(1).
+
+.TP
.BI \--verbose
Print more information.
.TP
.BI \--nomgs
Remove a configuration management service to this target
.TP
+.BI \--force-nohostid
+Ignore unset hostid for ZFS import protection. To set hostid either set
+spl_hostid option for spl.ko or set /etc/hostid, see genhostid(1).
+.TP
.BI \--quiet
Print less information.
.TP
set_default_debug_nodes $node
}
+set_hostid () {
+ local hostid=${1:-$(hostid)}
+
+ if [ ! -s /etc/hostid ]; then
+ printf $(echo -n $hostid |
+ sed 's/\(..\)\(..\)\(..\)\(..\)/\\x\4\\x\3\\x\2\\x\1/') >/etc/hostid
+ fi
+}
+
# Facet functions
mount_facets () {
local facets=${1:-$(get_facets)}
formatall() {
stopall
+ # Set hostid for ZFS/SPL zpool import protection
+ do_rpc_nodes "$(comma_list $(remote_nodes_list))" set_hostid
+
# We need ldiskfs here, may as well load them all
load_modules
[ "$CLIENTONLY" ] && return
"\t\t--comment=<user comment>: arbitrary string (%d bytes)\n"
"\t\t--dryrun: report what we would do; don't write to disk\n"
"\t\t--verbose: e.g. show mkfs progress\n"
+ "\t\t--force-nohostid: Ignore hostid requirement for ZFS "
+ "import\n"
"\t\t-V|--version: output build version of the utility and\n"
"\t\t\texit\n"
"\t\t--quiet\n",
{ "servicenode", required_argument, NULL, 's' },
{ "network", required_argument, NULL, 't' },
{ "comment", required_argument, NULL, 'u' },
+ { "force-nohostid", no_argument, NULL, 'U' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
#ifndef TUNEFS
strscpy(ldd->ldd_userdata, optarg,
sizeof(ldd->ldd_userdata));
break;
+ case 'U':
+ mop->mo_flags |= MO_NOHOSTID_CHECK;
+ break;
case 'v':
verbose++;
break;
memset(&mkop, 0, sizeof(mkop));
mkop.mo_ldd = *ldd;
mkop.mo_ldd.ldd_flags &= ~LDD_F_UPDATE;
+ mkop.mo_flags = MO_NOHOSTID_CHECK; /* Ignore missing hostid */
if (strlen(source) > sizeof(mkop.mo_device)-1) {
fatal();
fprintf(stderr, "Device name too long: %s\n", source);
#define MO_FAILOVER 0x04
#define MO_DRYRUN 0x08
#define MO_QUOTA 0x10
+#define MO_NOHOSTID_CHECK 0x20
#define MAX_LOOP_DEVICES 16
#define INDEX_UNASSIGNED 0xFFFF
return ret;
}
+static int zfs_check_hostid(struct mkfs_opts *mop)
+{
+ FILE *f;
+ unsigned long hostid;
+ int rc;
+
+ if (strstr(mop->mo_ldd.ldd_params, PARAM_FAILNODE) == NULL)
+ return 0;
+
+ f = fopen("/sys/module/spl/parameters/spl_hostid", "r");
+ if (f == NULL) {
+ fatal();
+ fprintf(stderr, "Failed to open spl_hostid: %s\n",
+ strerror(errno));
+ return errno;
+ }
+ rc = fscanf(f, "%li", &hostid);
+ fclose(f);
+ if (rc != 1) {
+ fatal();
+ fprintf(stderr, "Failed to read spl_hostid: %d\n", rc);
+ return rc;
+ }
+
+ if (hostid == 0) {
+ if (mop->mo_flags & MO_NOHOSTID_CHECK) {
+ fprintf(stderr, "WARNING: spl_hostid not set. ZFS has "
+ "no zpool import protection\n");
+ } else {
+ fatal();
+ fprintf(stderr, "spl_hostid not set. See %s(8)",
+ progname);
+ return EINVAL;
+ }
+ }
+
+ return 0;
+}
+
static int osd_check_zfs_setup(void)
{
if (osd_zfs_setup == 0) {
int i, ret = EINVAL;
if (osd_check_zfs_setup() == 0)
- return EINVAL;
+ goto out;
zhp = zfs_open(g_zfs, ds, ZFS_TYPE_FILESYSTEM);
if (zhp == NULL) {
goto out;
}
+ ret = zfs_check_hostid(mop);
+ if (ret != 0)
+ goto out;
+
vprint("Writing %s properties\n", ds);
for (i = 0; special_ldd_prop_params[i].zlpb_prop_name != NULL; i++) {
return EINVAL;
}
+ ret = zfs_check_hostid(mop);
+ if (ret != 0)
+ goto out;
+
pool = strdup(ds);
if (pool == NULL)
return ENOMEM;