X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fmount_utils_zfs.c;h=0f30e13942f6ae0878b23c52a632b7e2a2d8265d;hb=0cc1756e9fb28609705f5f86b8e2197f57b40513;hp=755c218913567c5568e6573662da07dd598678ff;hpb=3092629deca3988f7b74e4c2877601688828462a;p=fs%2Flustre-release.git diff --git a/lustre/utils/mount_utils_zfs.c b/lustre/utils/mount_utils_zfs.c index 755c218..0f30e13 100644 --- a/lustre/utils/mount_utils_zfs.c +++ b/lustre/utils/mount_utils_zfs.c @@ -20,7 +20,7 @@ * GPL HEADER END */ /* - * Copyright (c) 2012, 2014, Intel Corporation. + * Copyright (c) 2012, 2016, Intel Corporation. * Use is subject to license terms. */ /* @@ -32,6 +32,8 @@ #include #include +#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" @@ -198,6 +200,23 @@ static int zfs_check_hostid(struct mkfs_opts *mop) 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 "