4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License version 2 for more details. A copy is
14 * included in the COPYING file that accompanied this code.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Copyright (c) 2012, 2017, Intel Corporation.
24 * Use is subject to license terms.
27 * Author: Brian Behlendorf <behlendorf1@llnl.gov>
29 #include "mount_utils.h"
34 #include <sys/systeminfo.h>
36 /* Persistent mount data is stored in these user attributes */
37 #define LDD_PREFIX "lustre:"
38 #define LDD_VERSION_PROP LDD_PREFIX "version"
39 #define LDD_FLAGS_PROP LDD_PREFIX "flags"
40 #define LDD_INDEX_PROP LDD_PREFIX "index"
41 #define LDD_FSNAME_PROP LDD_PREFIX "fsname"
42 #define LDD_SVNAME_PROP LDD_PREFIX "svname"
43 #define LDD_UUID_PROP LDD_PREFIX "uuid"
44 #define LDD_USERDATA_PROP LDD_PREFIX "userdata"
45 #define LDD_MOUNTOPTS_PROP LDD_PREFIX "mountopts"
47 /* This structure is used to help bridge the gap between the ZFS
48 * properties Lustre uses and their corresponding internal LDD fields.
49 * It is meant to be used internally by the mount utility only. */
50 struct zfs_ldd_prop_bridge {
51 /* Contains the publicly visible name for the property
52 * (i.e. what is shown when running "zfs get") */
54 /* Contains the offset into the lustre_disk_data structure where
55 * the value of this property is or will be stored. (i.e. the
56 * property is read from and written to this offset within ldd) */
58 /* Function pointer responsible for reading in the @prop
59 * property from @zhp and storing it in @ldd_field */
60 #ifdef HAVE_ZFS_NVLIST_CONST_INTERFACES
61 int (*zlpb_get_prop_fn)(zfs_handle_t *zhp, const char *prop,
64 int (*zlpb_get_prop_fn)(zfs_handle_t *zhp, char *prop, void *ldd_field);
66 /* Function pointer responsible for writing the value of @ldd_field
67 * into the @prop dataset property in @zhp */
68 int (*zlpb_set_prop_fn)(zfs_handle_t *zhp, char *prop, void *ldd_field);
71 /* Forward declarations needed to initialize the ldd prop bridge list */
72 #ifdef HAVE_ZFS_NVLIST_CONST_INTERFACES
73 static int zfs_get_prop_int(zfs_handle_t *, const char *, void *);
74 static int zfs_get_prop_str(zfs_handle_t *, const char *, void *);
76 static int zfs_get_prop_int(zfs_handle_t *, char *, void *);
77 static int zfs_get_prop_str(zfs_handle_t *, char *, void *);
79 static int zfs_set_prop_int(zfs_handle_t *, char *, void *);
80 static int zfs_set_prop_str(zfs_handle_t *, char *, void *);
82 /* Helper for initializing the entries in the special_ldd_prop_params list.
83 * - @name: stored directly in the zlpb_prop_name field
84 * (e.g. lustre:fsname, lustre:version, etc.)
85 * - @field: the field in the lustre_disk_data which directly maps to
86 * the @name property. (e.g. ldd_fsname, ldd_config_ver, etc.)
87 * - @type: The type of @field. Only "int" and "str" are supported.
89 #define ZLB_INIT(name, field, type) \
91 .zlpb_prop_name = name, \
92 .zlpb_ldd_offset = offsetof(struct lustre_disk_data, field), \
93 .zlpb_get_prop_fn = zfs_get_prop_ ## type, \
94 .zlpb_set_prop_fn = zfs_set_prop_ ## type \
97 /* These ldd properties are special because they all have their own
98 * individual fields in the lustre_disk_data structure, as opposed to
99 * being globbed into the ldd_params field. As such, these need special
100 * handling when reading/writing the ldd structure to/from persistent
102 struct zfs_ldd_prop_bridge special_ldd_prop_params[] = {
103 ZLB_INIT(LDD_VERSION_PROP, ldd_config_ver, int),
104 ZLB_INIT(LDD_FLAGS_PROP, ldd_flags, int),
105 ZLB_INIT(LDD_INDEX_PROP, ldd_svindex, int),
106 ZLB_INIT(LDD_FSNAME_PROP, ldd_fsname, str),
107 ZLB_INIT(LDD_SVNAME_PROP, ldd_svname, str),
108 ZLB_INIT(LDD_UUID_PROP, ldd_uuid, str),
109 ZLB_INIT(LDD_USERDATA_PROP, ldd_userdata, str),
110 ZLB_INIT(LDD_MOUNTOPTS_PROP, ldd_mount_opts, str),
114 /* indicate if the ZFS OSD has been successfully setup */
115 static int osd_zfs_setup = 0;
117 static libzfs_handle_t *g_zfs;
121 static int zfs_set_prop_int(zfs_handle_t *zhp, char *prop, void *val)
126 (void) snprintf(str, sizeof (str), "%i", *(int *)val);
127 vprint(" %s=%s\n", prop, str);
128 ret = zfs_prop_set(zhp, prop, str);
134 * Write the zfs property string, note that properties with a NULL or
135 * zero-length value will not be written and 0 returned.
137 static int zfs_set_prop_str(zfs_handle_t *zhp, char *prop, void *val)
141 if (val && strlen(val) > 0) {
142 vprint(" %s=%s\n", prop, (char *)val);
143 ret = zfs_prop_set(zhp, prop, (char *)val);
150 * Remove a property from zfs property dataset
152 static int zfs_remove_prop(zfs_handle_t *zhp, nvlist_t *nvl, char *propname)
154 nvlist_remove_all(nvl, propname);
155 /* XXX: please replace zfs_prop_inherit() if there is a better function
156 * to call zfs_ioctl() to update data on-disk.
158 return zfs_prop_inherit(zhp, propname, false);
161 static int zfs_erase_prop(zfs_handle_t *zhp, char *param)
164 char propname[ZFS_MAXPROPLEN];
165 int len = strlen(param) + strlen(LDD_PREFIX);
167 if (len > ZFS_MAXPROPLEN) {
168 fprintf(stderr, "%s: zfs prop to erase is too long-\n%s\n",
173 nvl = zfs_get_user_props(zhp);
177 snprintf(propname, len + 1, "%s%s", LDD_PREFIX, param);
178 return zfs_remove_prop(zhp, nvl, propname);
181 #ifdef HAVE_ZFS_NVLIST_CONST_INTERFACES
182 static int zfs_is_special_ldd_prop_param(const char *name)
184 static int zfs_is_special_ldd_prop_param(char *name)
189 for (i = 0; special_ldd_prop_params[i].zlpb_prop_name != NULL; i++)
190 if (!strcmp(name, special_ldd_prop_params[i].zlpb_prop_name))
196 static int zfs_erase_allprops(zfs_handle_t *zhp)
200 size_t str_size = 1024 * 1024;
204 strs = malloc(str_size);
209 props = zfs_get_user_props(zhp);
215 while (nvp = nvlist_next_nvpair(props, nvp), nvp) {
216 if (strncmp(nvpair_name(nvp), LDD_PREFIX, strlen(LDD_PREFIX)))
219 if (zfs_is_special_ldd_prop_param(nvpair_name(nvp)))
222 rc = snprintf(cur, str_size - (cur - strs), "%s",
224 if (rc != strlen(nvpair_name(nvp))) {
225 fprintf(stderr, "%s: zfs has too many properties to erase, please repeat\n",
230 cur += strlen(cur) + 1;
233 while ( cur < (strs + str_size) && strlen(cur) > 0) {
234 zfs_prop_inherit(zhp, cur, false);
235 cur += strlen(cur) + 1;
243 * Map '<key>=<value> ...' pairs in the passed string to dataset properties
244 * of the form 'lustre:<key>=<value>'. "<key>=" means to remove this key
247 static int zfs_set_prop_params(zfs_handle_t *zhp, char *params)
249 char *params_dup, *token, *key, *value;
250 char *save_token = NULL;
251 char propname[ZFS_MAXPROPLEN];
254 params_dup = strdup(params);
255 if (params_dup == NULL)
258 token = strtok_r(params_dup, " ", &save_token);
260 key = strtok(token, "=");
264 value = strtok(NULL, "=");
266 /* remove this prop when its value is null */
267 ret = zfs_erase_prop(zhp, key);
271 snprintf(propname, strlen(LDD_PREFIX) + strlen(key) + 1,
272 "%s%s", LDD_PREFIX, key);
273 vprint(" %s=%s\n", propname, value);
275 ret = zfs_prop_set(zhp, propname, value);
280 token = strtok_r(NULL, " ", &save_token);
288 static int zfs_check_hostid(struct mkfs_opts *mop)
290 unsigned long hostid;
292 if (strstr(mop->mo_ldd.ldd_params, PARAM_FAILNODE) == NULL)
295 hostid = get_system_hostid();
297 if (mop->mo_flags & MO_NOHOSTID_CHECK) {
298 fprintf(stderr, "WARNING: spl_hostid not set. ZFS has "
299 "no zpool import protection\n");
302 fprintf(stderr, "spl_hostid not set. See %s(8)",
311 static int osd_check_zfs_setup(void)
313 if (osd_zfs_setup == 0) {
316 fprintf(stderr, "Failed to initialize ZFS library. Are the ZFS "
317 "packages and modules correctly installed?\n");
319 return osd_zfs_setup == 1;
322 /* Write the server config as properties associated with the dataset */
323 int zfs_write_ldd(struct mkfs_opts *mop)
325 struct lustre_disk_data *ldd = &mop->mo_ldd;
326 char *ds = mop->mo_device;
328 struct zfs_ldd_prop_bridge *bridge;
331 if (osd_check_zfs_setup() == 0)
334 zhp = zfs_open(g_zfs, ds, ZFS_TYPE_FILESYSTEM);
336 fprintf(stderr, "Failed to open zfs dataset %s\n", ds);
340 ret = zfs_check_hostid(mop);
344 vprint("Writing %s properties\n", ds);
346 if (mop->mo_flags & MO_ERASE_ALL) {
347 ret = zfs_erase_allprops(zhp);
349 fprintf(stderr, "zfs_erase_allprops Failed: %d\n", ret);
353 ret = zfs_set_prop_params(zhp, ldd->ldd_params);
355 for (i = 0; special_ldd_prop_params[i].zlpb_prop_name != NULL; i++) {
356 bridge = &special_ldd_prop_params[i];
357 ret = bridge->zlpb_set_prop_fn(zhp, bridge->zlpb_prop_name,
358 (void *)ldd + bridge->zlpb_ldd_offset);
369 /* Mark a property to be removed by the form of "key=" */
370 int zfs_erase_ldd(struct mkfs_opts *mop, char *param)
372 char key[ZFS_MAXPROPLEN] = "";
374 if (strlen(LDD_PREFIX) + strlen(param) > ZFS_MAXPROPLEN) {
375 fprintf(stderr, "%s: zfs prop to erase is too long-\n%s\n",
379 snprintf(key, strlen(param) + 2, "%s=", param);
380 return add_param(mop->mo_ldd.ldd_params, key, "");
383 #ifdef HAVE_ZFS_NVLIST_CONST_INTERFACES
384 static int zfs_get_prop_int(zfs_handle_t *zhp, const char *prop, void *val)
388 static int zfs_get_prop_int(zfs_handle_t *zhp, char *prop, void *val)
395 ret = nvlist_lookup_nvlist(zfs_get_user_props(zhp), prop, &propval);
399 ret = nvlist_lookup_string(propval, ZPROP_VALUE, &propstr);
404 *(__u32 *)val = strtoul(propstr, NULL, 10);
411 #ifdef HAVE_ZFS_NVLIST_CONST_INTERFACES
412 static int zfs_get_prop_str(zfs_handle_t *zhp, const char *prop, void *val)
416 static int zfs_get_prop_str(zfs_handle_t *zhp, char *prop, void *val)
423 ret = nvlist_lookup_nvlist(zfs_get_user_props(zhp), prop, &propval);
427 ret = nvlist_lookup_string(propval, ZPROP_VALUE, &propstr);
431 (void) strcpy(val, propstr);
436 static int zfs_get_prop_params(zfs_handle_t *zhp, char *param)
440 char key[ZFS_MAXPROPLEN] = "";
441 char value[PARAM_MAX] = "";
444 props = zfs_get_user_props(zhp);
449 while (nvp = nvlist_next_nvpair(props, nvp), nvp) {
450 ret = zfs_get_prop_str(zhp, nvpair_name(nvp), value);
454 if (strncmp(nvpair_name(nvp), LDD_PREFIX, strlen(LDD_PREFIX)))
457 if (zfs_is_special_ldd_prop_param(nvpair_name(nvp)))
460 sprintf(key, "%s=", nvpair_name(nvp) + strlen(LDD_PREFIX));
461 ret = add_param(param, key, value);
470 * Read the server config as properties associated with the dataset.
471 * Missing entries as not treated error and are simply skipped.
473 int zfs_read_ldd(char *ds, struct lustre_disk_data *ldd)
476 struct zfs_ldd_prop_bridge *bridge;
479 if (osd_check_zfs_setup() == 0)
482 zhp = zfs_open(g_zfs, ds, ZFS_TYPE_FILESYSTEM);
484 zhp = zfs_open(g_zfs, ds, ZFS_TYPE_SNAPSHOT);
489 for (i = 0; special_ldd_prop_params[i].zlpb_prop_name != NULL; i++) {
490 bridge = &special_ldd_prop_params[i];
491 ret = bridge->zlpb_get_prop_fn(zhp, bridge->zlpb_prop_name,
492 (void *)ldd + bridge->zlpb_ldd_offset);
493 if (ret && (ret != ENOENT))
497 ret = zfs_get_prop_params(zhp, ldd->ldd_params);
498 if (ret && (ret != ENOENT))
501 ldd->ldd_mount_type = LDD_MT_ZFS;
504 if (strstr(ldd->ldd_params, PARAM_FAILNODE) != NULL) {
505 zpool_handle_t *pool = zfs_get_pool_handle(zhp);
506 uint64_t mh = zpool_get_prop_int(pool, ZPOOL_PROP_MULTIHOST,
509 fprintf(stderr, "%s: %s is configured for failover "
510 "but zpool does not have multihost enabled\n",
521 /* Print ldd params */
522 void zfs_print_ldd_params(struct mkfs_opts *mop)
524 char *from = mop->mo_ldd.ldd_params;
528 vprint("Parameters:");
530 /* skip those keys to be removed in the form of "key=" */
531 to = strstr(from, "= ");
533 /* "key=" may be in the end */
534 if (*(from + strlen(from) - 1) == '=')
535 to = from + strlen(from) - 1;
537 /* find " " inward */
540 len = strlen(from) - strlen(to);
541 while ((*(from + len) != ' ') && len)
545 /* no space in the end */
546 vprint("%*.*s", len, len, from);
548 /* If there is no "key=" or "key=" is in the end, stop. */
549 if (!to || strlen(to) == 1)
557 int zfs_is_lustre(char *ds, unsigned int *mount_type)
559 struct lustre_disk_data tmp_ldd;
562 if (osd_zfs_setup == 0)
565 ret = zfs_read_ldd(ds, &tmp_ldd);
566 if ((ret == 0) && (tmp_ldd.ldd_config_ver > 0) &&
567 (strlen(tmp_ldd.ldd_svname) > 0)) {
568 *mount_type = tmp_ldd.ldd_mount_type;
575 static char *zfs_mkfs_opts(struct mkfs_opts *mop, char *str, int len)
579 if (strlen(mop->mo_mkfsopts) != 0)
580 snprintf(str, len, " -o %s", mop->mo_mkfsopts);
581 if (mop->mo_device_kb)
582 snprintf(str, len, " -o quota=%llu",
583 (unsigned long long)mop->mo_device_kb * 1024);
588 static int zfs_create_vdev(struct mkfs_opts *mop, char *vdev)
592 /* Silently ignore reserved vdev names */
593 if ((strncmp(vdev, "disk", 4) == 0) ||
594 (strncmp(vdev, "file", 4) == 0) ||
595 (strncmp(vdev, "mirror", 6) == 0) ||
596 (strncmp(vdev, "raidz", 5) == 0) ||
597 (strncmp(vdev, "spare", 5) == 0) ||
598 (strncmp(vdev, "log", 3) == 0) ||
599 (strncmp(vdev, "cache", 5) == 0))
603 * Verify a file exists at the provided absolute path. If it doesn't
604 * and mo_device_kb is set attempt to create a file vdev to be used.
605 * Relative paths will be passed directly to 'zpool create' which
606 * will check multiple multiple locations under /dev/.
608 if (vdev[0] == '/') {
609 ret = access(vdev, F_OK);
616 fprintf(stderr, "Unable to access required vdev "
617 "for pool %s (%d)\n", vdev, ret);
621 if (mop->mo_device_kb == 0) {
623 fprintf(stderr, "Unable to create vdev due to "
624 "missing --device-size=#N(KB) parameter\n");
628 ret = file_create(vdev, mop->mo_device_kb);
631 fprintf(stderr, "Unable to create vdev %s (%d)\n",
640 int zfs_make_lustre(struct mkfs_opts *mop)
645 char *mkfs_cmd = NULL;
646 char *mkfs_tmp = NULL;
647 char *ds = mop->mo_device;
648 int pool_exists = 0, ret;
650 if (osd_check_zfs_setup() == 0)
653 /* no automatic index with zfs backend */
654 if (mop->mo_ldd.ldd_flags & LDD_F_NEED_INDEX) {
656 fprintf(stderr, "The target index must be specified with "
661 ret = zfs_check_hostid(mop);
669 mkfs_cmd = malloc(PATH_MAX);
670 if (mkfs_cmd == NULL) {
675 mkfs_tmp = malloc(PATH_MAX);
676 if (mkfs_tmp == NULL) {
681 /* Due to zfs_prepare_lustre() check the '/' must exist */
682 strchr(pool, '/')[0] = '\0';
684 /* If --reformat was given attempt to destroy the previous dataset */
685 if ((mop->mo_flags & MO_FORCEFORMAT) &&
686 ((zhp = zfs_open(g_zfs, ds, ZFS_TYPE_FILESYSTEM)) != NULL)) {
688 ret = zfs_destroy(zhp, 0);
691 fprintf(stderr, "Failed destroy zfs dataset %s (%d)\n",
700 * Create the zpool if the vdevs have been specified and the pool
701 * does not already exists. The pool creation itself will be done
702 * with the zpool command rather than the zpool_create() library call
703 * so the existing zpool error handling can be leveraged.
705 php = zpool_open(g_zfs, pool);
708 zpool_set_prop(php, "canmount", "off");
712 if ((mop->mo_pool_vdevs != NULL) && (pool_exists == 0)) {
714 memset(mkfs_cmd, 0, PATH_MAX);
715 snprintf(mkfs_cmd, PATH_MAX,
716 "zpool create -f -O canmount=off %s", pool);
718 /* Append the vdev config and create file vdevs as required */
719 while (*mop->mo_pool_vdevs != NULL) {
720 strscat(mkfs_cmd, " ", PATH_MAX);
721 strscat(mkfs_cmd, *mop->mo_pool_vdevs, PATH_MAX);
723 ret = zfs_create_vdev(mop, *mop->mo_pool_vdevs);
727 mop->mo_pool_vdevs++;
730 vprint("mkfs_cmd = %s\n", mkfs_cmd);
731 ret = run_command(mkfs_cmd, PATH_MAX);
734 fprintf(stderr, "Unable to create pool %s (%d)\n",
741 * Set Options on ZPOOL
743 * ALL - canmount=off (set above)
744 * 0.7.0 - multihost=on
745 * 0.7.0 - feature@userobj_accounting=enabled
747 php = zpool_open(g_zfs, pool);
749 zpool_set_prop(php, "multihost", "on");
750 zpool_set_prop(php, "feature@userobj_accounting", "enabled");
755 * Create the ZFS filesystem with any required mkfs options:
756 * - canmount=off is set to prevent zfs automounting
758 memset(mkfs_cmd, 0, PATH_MAX);
759 snprintf(mkfs_cmd, PATH_MAX,
760 "zfs create -o canmount=off %s %s",
761 zfs_mkfs_opts(mop, mkfs_tmp, PATH_MAX), ds);
763 vprint("mkfs_cmd = %s\n", mkfs_cmd);
764 ret = run_command(mkfs_cmd, PATH_MAX);
767 fprintf(stderr, "Unable to create filesystem %s (%d)\n",
773 * Attempt to set dataset properties to reasonable defaults
774 * to optimize performance, unless the values were specified
775 * at the mkfs command line. Some ZFS pools or ZFS versions
776 * do not support these properties. We can safely ignore the
777 * errors and continue in those cases.
779 * zfs 0.6.1 - system attribute based xattrs
780 * zfs 0.6.5 - large block support
781 * zfs 0.7.0 - large dnode support
783 * Check if zhp is NULL as a defensive measure. Any dataset
784 * validation errors that would cause zfs_open() to fail
785 * should have been caught earlier.
787 zhp = zfs_open(g_zfs, ds, ZFS_TYPE_FILESYSTEM);
789 /* zfs 0.6.1 - system attribute based xattrs */
790 if (!strstr(mop->mo_mkfsopts, "xattr="))
791 zfs_set_prop_str(zhp, "xattr", "sa");
793 /* zfs 0.7.0 - large dnode support */
794 if (!strstr(mop->mo_mkfsopts, "dnodesize=") &&
795 !strstr(mop->mo_mkfsopts, "dnsize="))
796 zfs_set_prop_str(zhp, "dnodesize", "auto");
798 if (IS_OST(&mop->mo_ldd)) {
799 /* zfs 0.6.5 - large block support */
800 if (!strstr(mop->mo_mkfsopts, "recordsize=") &&
801 !strstr(mop->mo_mkfsopts, "recsize="))
802 zfs_set_prop_str(zhp, "recordsize", "1M");
812 if (mkfs_cmd != NULL)
815 if (mkfs_tmp != NULL)
821 int zfs_enable_quota(struct mkfs_opts *mop)
823 fprintf(stderr, "this option is not only valid for zfs\n");
827 int zfs_prepare_lustre(struct mkfs_opts *mop,
828 char *wanted_mountopts, size_t len)
830 if (osd_check_zfs_setup() == 0)
833 if (zfs_name_valid(mop->mo_device, ZFS_TYPE_FILESYSTEM) == 0) {
835 fprintf(stderr, "Invalid filesystem name %s\n", mop->mo_device);
839 if (strchr(mop->mo_device, '/') == NULL) {
841 fprintf(stderr, "Missing pool in filesystem name %s\n",
849 int zfs_tune_lustre(char *dev, struct mount_opts *mop)
851 if (osd_check_zfs_setup() == 0)
857 int zfs_label_lustre(struct mount_opts *mop)
862 if (osd_check_zfs_setup() == 0)
865 zhp = zfs_open(g_zfs, mop->mo_source, ZFS_TYPE_FILESYSTEM);
869 ret = zfs_set_prop_str(zhp, LDD_SVNAME_PROP, mop->mo_ldd.ldd_svname);
875 int zfs_rename_fsname(struct mkfs_opts *mop, const char *oldname)
877 struct mount_opts opts;
878 char mntpt[] = "/tmp/mntXXXXXX";
882 /* Change the filesystem label. */
883 opts.mo_ldd = mop->mo_ldd;
884 opts.mo_source = mop->mo_device;
885 ret = zfs_label_lustre(&opts);
889 fprintf(stderr, "Can't change filesystem label: %s\n",
894 /* Mount this device temporarily in order to write these files */
895 if (mkdtemp(mntpt) == NULL) {
898 fprintf(stderr, "Can't create temp mount point %s: %s\n",
899 mntpt, strerror(ret));
903 cmd_buf = malloc(PATH_MAX);
909 memset(cmd_buf, 0, PATH_MAX);
910 snprintf(cmd_buf, PATH_MAX - 1, "zfs set mountpoint=%s %s && "
911 "zfs set canmount=on %s && zfs mount %s",
912 mntpt, mop->mo_device, mop->mo_device, mop->mo_device);
913 ret = run_command(cmd_buf, PATH_MAX);
917 fprintf(stderr, "Unable to mount %s (%s)\n",
918 mop->mo_device, strerror(ret));
920 fprintf(stderr, "Is the %s module available?\n",
921 MT_STR(&mop->mo_ldd));
925 ret = lustre_rename_fsname(mop, mntpt, oldname);
926 memset(cmd_buf, 0, PATH_MAX);
927 snprintf(cmd_buf, PATH_MAX - 1, "zfs umount %s && "
928 "zfs set canmount=off %s && zfs set mountpoint=none %s",
929 mop->mo_device, mop->mo_device, mop->mo_device);
930 run_command(cmd_buf, PATH_MAX);
943 g_zfs = libzfs_init();
946 /* Try to load zfs.ko and retry libzfs_init() */
948 ret = system("/sbin/modprobe -q zfs");
951 g_zfs = libzfs_init();
960 fprintf(stderr, "Failed to initialize ZFS library: %d\n", ret);
975 struct module_backfs_ops zfs_ops = {
978 .read_ldd = zfs_read_ldd,
979 .write_ldd = zfs_write_ldd,
980 .erase_ldd = zfs_erase_ldd,
981 .print_ldd_params = zfs_print_ldd_params,
982 .is_lustre = zfs_is_lustre,
983 .make_lustre = zfs_make_lustre,
984 .prepare_lustre = zfs_prepare_lustre,
985 .tune_lustre = zfs_tune_lustre,
986 .label_lustre = zfs_label_lustre,
987 .enable_quota = zfs_enable_quota,
988 .rename_fsname = zfs_rename_fsname,
990 #endif /* PLUGIN_DIR */