* GPL HEADER END
*/
/*
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
* Use is subject to license terms.
*/
/*
#include <string.h>
#include <libzfs.h>
+#define HOSTID_PATH "/etc/hostid"
+
/* Persistent mount data is stored in these user attributes */
#define LDD_PREFIX "lustre:"
#define LDD_VERSION_PROP LDD_PREFIX "version"
{
char *params_dup, *token, *key, *value;
char *save_token = NULL;
- char prop_name[ZFS_MAXNAMELEN];
+ char prop_name[ZFS_MAXPROPLEN];
int ret = 0;
params_dup = strdup(params);
return rc;
}
+ if (hostid != 0)
+ return 0;
+
+ f = fopen(HOSTID_PATH, "r");
+ if (f == NULL)
+ goto out;
+
+ rc = fread(&hostid, sizeof(uint32_t), 1, f);
+ fclose(f);
+
+ if (rc != 1) {
+ fprintf(stderr, "Failed to read "HOSTID_PATH": %d\n",
+ rc);
+ hostid = 0;
+ }
+
+out:
if (hostid == 0) {
if (mop->mo_flags & MO_NOHOSTID_CHECK) {
fprintf(stderr, "WARNING: spl_hostid not set. ZFS has "
{
nvlist_t *props;
nvpair_t *nvp;
- char key[ZFS_MAXNAMELEN];
+ char key[ZFS_MAXPROPLEN];
char *value;
int ret = 0;
g_zfs = libzfs_init();
if (g_zfs == NULL) {
- fprintf(stderr, "Failed to initialize ZFS library\n");
- ret = EINVAL;
- } else {
- osd_zfs_setup = 1;
+ /* Try to load zfs.ko and retry libzfs_init() */
+
+ ret = system("/sbin/modprobe -q zfs");
+
+ if (ret == 0) {
+ g_zfs = libzfs_init();
+ if (g_zfs == NULL)
+ ret = EINVAL;
+ }
}
+ if (ret == 0)
+ osd_zfs_setup = 1;
+
+ else
+ fprintf(stderr, "Failed to initialize ZFS library: %d\n", ret);
+
return ret;
}