Whamcloud - gitweb
LU-8713 utils: Try loading zfs.ko during zfs_init 10/23210/4
authorNathaniel Clark <nathaniel.l.clark@intel.com>
Mon, 17 Oct 2016 16:26:22 +0000 (12:26 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 25 Oct 2016 02:22:51 +0000 (02:22 +0000)
Newer version of zfs (0.6.5.8 and 0.7.0) do not autoload zfs module at
boot nor do they load it during libzfs_init(), so try loading it
during initialization.

Signed-off-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Change-Id: I44765b0c2b7ea8b1c8c6d45a9107842b17623dbc
Reviewed-on: http://review.whamcloud.com/23210
Tested-by: Jenkins
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/mount_utils_zfs.c

index 592f18d..755c218 100644 (file)
@@ -664,12 +664,23 @@ int zfs_init(void)
 
        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;
 }