Whamcloud - gitweb
LU-1581 utils: add zfs support to wrappers
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 18 Jun 2012 06:04:41 +0000 (10:04 +0400)
committerOleg Drokin <green@whamcloud.com>
Sat, 7 Jul 2012 17:46:37 +0000 (13:46 -0400)
now mkfs can create lustre server with zfs backend

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: Ibbed024ec918f1ef76b6fc92951143cff04421b6
Reviewed-on: http://review.whamcloud.com/3228
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Hudson
Reviewed-by: Li Wei <liwei@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/Makefile.am
lustre/utils/mount_utils.c
lustre/utils/mount_utils.h

index 1ce9307..a6aeb9f 100644 (file)
@@ -98,6 +98,12 @@ mount_lustre_SOURCES = mount_lustre.c mount_utils.c mount_utils.h
 mount_lustre_SOURCES += mount_utils_ldiskfs.c
 mount_lustre_LDADD := $(LIBPTLCTL)
 mount_lustre_DEPENDENCIES := $(LIBPTLCTL)
+if ZFS_ENABLED
+mount_lustre_SOURCES += mount_utils_zfs.c
+mount_lustre_CPPFLAGS = -DHAVE_IOCTL_IN_UNISTD_H
+mount_lustre_CPPFLAGS += -I /usr/include/libspl -I /usr/include/libzfs
+mount_lustre_LDFLAGS = -pthread -rdynamic -ldl
+endif
 
 mkfs_lustre_SOURCES = mkfs_lustre.c mount_utils.c mount_utils.h
 mkfs_lustre_SOURCES += mount_utils_ldiskfs.c
index 048aee5..4c570a4 100644 (file)
@@ -387,6 +387,11 @@ int osd_write_ldd(struct mkfs_opts *mop)
        case LDD_MT_LDISKFS2:
                ret = ldiskfs_write_ldd(mop);
                break;
+#ifdef HAVE_ZFS_OSD
+       case LDD_MT_ZFS:
+               ret = zfs_write_ldd(mop);
+               break;
+#endif /* HAVE_ZFS_OSD */
        default:
                fatal();
                fprintf(stderr, "unknown fs type %d '%s'\n",
@@ -408,6 +413,11 @@ int osd_read_ldd(char *dev, struct lustre_disk_data *ldd)
        case LDD_MT_LDISKFS2:
                ret = ldiskfs_read_ldd(dev, ldd);
                break;
+#ifdef HAVE_ZFS_OSD
+       case LDD_MT_ZFS:
+               ret = zfs_read_ldd(dev, ldd);
+               break;
+#endif /* HAVE_ZFS_OSD */
        default:
                fatal();
                fprintf(stderr, "unknown fs type %d '%s'\n",
@@ -428,6 +438,12 @@ int osd_is_lustre(char *dev, unsigned *mount_type)
                vprint("found\n");
                return 1;
        }
+#ifdef HAVE_ZFS_OSD
+       if (zfs_is_lustre(dev, mount_type)) {
+               vprint("found\n");
+               return 1;
+       }
+#endif /* HAVE_ZFS_OSD */
 
        vprint("not found\n");
        return 0;
@@ -444,6 +460,11 @@ int osd_make_lustre(struct mkfs_opts *mop)
        case LDD_MT_LDISKFS2:
                ret = ldiskfs_make_lustre(mop);
                break;
+#ifdef HAVE_ZFS_OSD
+       case LDD_MT_ZFS:
+               ret = zfs_make_lustre(mop);
+               break;
+#endif /* HAVE_ZFS_OSD */
        default:
                fatal();
                fprintf(stderr, "unknown fs type %d '%s'\n",
@@ -469,6 +490,13 @@ int osd_prepare_lustre(struct mkfs_opts *mop,
                                             default_mountopts, default_len,
                                             always_mountopts, always_len);
                break;
+#ifdef HAVE_ZFS_OSD
+       case LDD_MT_ZFS:
+               ret = zfs_prepare_lustre(mop,
+                                        default_mountopts, default_len,
+                                        always_mountopts, always_len);
+               break;
+#endif /* HAVE_ZFS_OSD */
        default:
                fatal();
                fprintf(stderr, "unknown fs type %d '%s'\n",
@@ -487,6 +515,13 @@ int osd_init(void)
        ret = ldiskfs_init();
        if (ret)
                return ret;
+#ifdef HAVE_ZFS_OSD
+       ret = zfs_init();
+       /* we want to be able to set up a ldiskfs-based filesystem w/o
+        * the ZFS modules installed, see ORI-425 */
+       if (ret)
+               ret = 0;
+#endif /* HAVE_ZFS_OSD */
 
        return ret;
 }
@@ -494,6 +529,9 @@ int osd_init(void)
 void osd_fini(void)
 {
        ldiskfs_fini();
+#ifdef HAVE_ZFS_OSD
+       zfs_fini();
+#endif /* HAVE_ZFS_OSD */
 }
 
 __u64 get_device_size(char* device)
index 8fb8494..287b2d8 100644 (file)
@@ -135,4 +135,16 @@ int ldiskfs_prepare_lustre(struct mkfs_opts *mop,
 int ldiskfs_init(void);
 void ldiskfs_fini(void);
 
+#ifdef HAVE_ZFS_OSD
+int zfs_write_ldd(struct mkfs_opts *mop);
+int zfs_read_ldd(char *ds,  struct lustre_disk_data *ldd);
+int zfs_is_lustre(char *dev, unsigned *mount_type);
+int zfs_make_lustre(struct mkfs_opts *mop);
+int zfs_prepare_lustre(struct mkfs_opts *mop,
+                      char *default_mountopts, int default_len,
+                      char *always_mountopts, int always_len);
+int zfs_init(void);
+void zfs_fini(void);
+#endif
+
 #endif