.*.cmd
.*.d
.*.flags
+.libs
.tmp_versions
.Xrefs
*~
*.dSYM
*.i
*.ko
+*.la
+*.lo
*.mod.c
*.o
*.orig
/config.h
/config.h.in
/INSTALL
+/libtool
/lustre.spec
/lustre-dkms.spec
/lustre*.tar.gz
ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I $PWD/$dir/autoconf"
done
+libtoolize -q
aclocal -I $PWD/config $ACLOCAL_FLAGS
autoheader
automake -a -c
/config.sub
/depcomp
/install-sh
+/libtool.m4
+/ltmain.sh
+/ltoptions.m4
+/ltsugar.m4
+/ltversion.m4
+/lt~obsolete.m4
/missing
AC_MSG_RESULT([$zfslib])
ZFS_LIBZFS_INCLUDE=${zfslib}
+ ZFS_LIBZFS_LDFLAGS=-lzfs
AC_SUBST(ZFS_LIBZFS_INCLUDE)
+ AC_SUBST(ZFS_LIBZFS_LDFLAGS)
])
AC_DEFUN([LB_CONFIG_ZFS], [
AM_MAINTAINER_MODE([enable])
AC_PROG_CC
+AC_PROG_LIBTOOL
AM_PROG_AS
Obsoletes: lustre-lite, lustre-lite-utils, lustre-ldap nfs-utils-lustre
Provides: lustre-lite = %{version}, lustre-lite-utils = %{version}
Requires: %{name}-modules = %{version}
+BuildRequires: libtool
%if %{with servers}
Requires: lustre-osd
%endif
CONFIGURE_ARGS="$CONFIGURE_ARGS --disable-modules"
%endif
+%if %{without zfs}
+CONFIGURE_ARGS="$CONFIGURE_ARGS --without-zfs"
+%endif
+
# if %%kdir was given, make sure it's not in the configure arguments
if [ -n "%kdir" ]; then
CONFIGURE_ARGS=$(echo $CONFIGURE_ARGS | sed -e 's/"\?--with-linux=[^ ][^ ]* \?//')
echo '%{_datadir}/lustre/snmp/mibs' >>lustre.files
fi
+find $RPM_BUILD_ROOT%{_libdir}/@PACKAGE@/ -name \*.la -delete
+
%if %{with lustre_tests}
echo '%{_libdir}/lustre/tests/*' >>lustre-tests.files
echo '%{_bindir}/mcreate' >>lustre-tests.files
%defattr(-,root,root)
%{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/ldiskfs.ko
%{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/osd_ldiskfs.ko
+%{_libdir}/@PACKAGE@/mount_osd_ldiskfs.so
%if %{defined rpm_post_base}
%attr(0555, root, root) %{rpm_post_base}-osd-ldiskfs.sh
%endif
%files osd-zfs
%defattr(-,root,root)
%{?rootdir}/lib/modules/%{kversion}/%{kmoddir}/kernel/fs/@PACKAGE@/osd_zfs.ko
+%{_libdir}/@PACKAGE@/mount_osd_zfs.so
%if %{defined rpm_post_base}
%attr(0555, root, root) %{rpm_post_base}-osd-zfs.sh
%endif
/*.xml
/Makefile.in
/XMLCONFIG
+/badarea_io
/check_fhandle_syscalls
/checkfiemap
/checkstat
AM_CPPFLAGS=$(LLCPPFLAGS) -DLUSTRE_UTILS=1 -D_FILE_OFFSET_BITS=64
AM_LDFLAGS := -L$(top_builddir)/lnet/utils
+MNTMODLDFLAGS := -rdynamic -ldl
+MNTMODCFLAGS := -DPLUGIN_DIR=\"${pkglibdir}\"
+
LIBPTLCTL := $(top_builddir)/lnet/utils/libptlctl.a \
$(top_builddir)/libcfs/libcfs/libcfsutil.a \
$(top_builddir)/libcfs/libcfs/libcfs.a
bin_SCRIPTS = $(bin_scripts)
sbin_SCRIPTS = $(sbin_scripts)
+pkglib_LTLIBRARIES =
lib_LIBRARIES = liblustreapi.a
if LDISKFS_ENABLED
lib_LIBRARIES += libiam.a
lr_reader_SOURCES = lr_reader.c
+if UTILS
+
+if ZFS_ENABLED
+pkglib_LTLIBRARIES += mount_osd_zfs.la
+
+mount_osd_zfs_la_SOURCES = mount_utils_zfs.c
+mount_osd_zfs_la_CPPFLAGS = -DHAVE_IOCTL_IN_UNISTD_H
+mount_osd_zfs_la_CPPFLAGS += $(ZFS_LIBZFS_INCLUDE)
+mount_osd_zfs_la_LDFLAGS = -pthread $(ZFS_LIBZFS_LDFLAGS)
+mount_osd_zfs_la_LDFLAGS += -shared -export-dynamic -module -avoid-version
+endif
+
+if LDISKFS_ENABLED
+pkglib_LTLIBRARIES += mount_osd_ldiskfs.la
+
+mount_osd_ldiskfs_la_SOURCES = mount_utils_ldiskfs.c
+mount_osd_ldiskfs_la_LDFLAGS = -shared -export-dynamic -module -avoid-version
+mount_osd_ldiskfs_LDADD = libiam.a
+endif
+
mount_lustre_SOURCES = mount_lustre.c mount_utils.c mount_utils.h
-mount_lustre_CPPFLAGS = $(AM_CPPFLAGS)
+mount_lustre_CPPFLAGS = $(AM_CPPFLAGS) ${MNTMODCFLAGS}
mount_lustre_LDADD := $(LIBPTLCTL) $(SELINUX)
mount_lustre_DEPENDENCIES := $(LIBPTLCTL)
-if LDISKFS_ENABLED
-mount_lustre_SOURCES += mount_utils_ldiskfs.c
-endif
-if ZFS_ENABLED
-mount_lustre_SOURCES += mount_utils_zfs.c
-mount_lustre_CPPFLAGS += -DHAVE_IOCTL_IN_UNISTD_H
-mount_lustre_CPPFLAGS += $(ZFS_LIBZFS_INCLUDE)
-mount_lustre_LDFLAGS = -pthread -rdynamic -ldl
-endif
+mount_lustre_LDFLAGS = ${MNTMODLDFLAGS}
mkfs_lustre_SOURCES = mkfs_lustre.c mount_utils.c mount_utils.h
-mkfs_lustre_CPPFLAGS = -UTUNEFS $(AM_CPPFLAGS)
+mkfs_lustre_CPPFLAGS = -UTUNEFS $(AM_CPPFLAGS) ${MNTMODCFLAGS}
mkfs_lustre_LDADD := $(LIBPTLCTL)
mkfs_lustre_DEPENDENCIES := $(LIBPTLCTL)
-if LDISKFS_ENABLED
-mkfs_lustre_SOURCES += mount_utils_ldiskfs.c
-mkfs_lustre_LDADD += libiam.a
-mkfs_lustre_DEPENDENCIES += $(LIBPTLCTL)
-endif
-if ZFS_ENABLED
-mkfs_lustre_SOURCES += mount_utils_zfs.c
-mkfs_lustre_CPPFLAGS += -DHAVE_IOCTL_IN_UNISTD_H
-mkfs_lustre_CPPFLAGS += $(ZFS_LIBZFS_INCLUDE)
-mkfs_lustre_LDFLAGS = -pthread -rdynamic -ldl
-endif
+mkfs_lustre_LDFLAGS = ${MNTMODLDFLAGS}
tunefs_lustre_SOURCES = mkfs_lustre.c mount_utils.c mount_utils.h
-tunefs_lustre_CPPFLAGS = -DTUNEFS $(AM_CPPFLAGS)
+tunefs_lustre_CPPFLAGS = -DTUNEFS $(AM_CPPFLAGS) ${MNTMODCFLAGS}
tunefs_lustre_LDADD := $(mkfs_lustre_LDADD)
tunefs_lustre_DEPENDENCIES := $(mkfs_lustre_DEPENDENCIES)
-if LDISKFS_ENABLED
-tunefs_lustre_SOURCES += mount_utils_ldiskfs.c
-endif
-if ZFS_ENABLED
-tunefs_lustre_SOURCES += mount_utils_zfs.c
-tunefs_lustre_CPPFLAGS += -DHAVE_IOCTL_IN_UNISTD_H
-tunefs_lustre_CPPFLAGS += $(ZFS_LIBZFS_INCLUDE)
-tunefs_lustre_LDFLAGS = -pthread -rdynamic -ldl
-endif
+tunefs_lustre_LDFLAGS = ${MNTMODLDFLAGS}
l_getidentity_SOURCES = l_getidentity.c
l_getidentity_LDADD := $(LIBPTLCTL)
wiretest_SOURCES = wiretest.c
+endif
+
EXTRA_DIST = $(sbin_scripts) $(bin_scripts)
# NOTE: this should only be run on i386.
#include <sys/stat.h>
#include <sys/utsname.h>
#include <linux/loop.h>
+#include <dlfcn.h>
extern char *progname;
extern int verbose;
#define vprint(fmt, arg...) if (verbose > 0) printf(fmt, ##arg)
#define verrprint(fmt, arg...) if (verbose >= 0) fprintf(stderr, fmt, ##arg)
+static struct module_backfs_ops *backfs_ops[LDD_MT_LAST];
+
void fatal(void)
{
verbose = 0;
return 0;
}
+#define DLSYM(prefix, sym, func) \
+ do { \
+ char _fname[64]; \
+ snprintf(_fname, sizeof(_fname), "%s_%s", prefix, #func); \
+ sym->func = (typeof(sym->func))dlsym(sym->dl_handle, _fname); \
+ } while (0)
+
+/**
+ * Load plugin for a given mount_type from ${pkglibdir}/mount_osd_FSTYPE.so and
+ * return struct of function pointers (will be freed in unloack_backfs_module).
+ *
+ * \param[in] mount_type Mount type to load module for.
+ * \retval Value of backfs_ops struct
+ * \retval NULL if no module exists
+ */
+struct module_backfs_ops *load_backfs_module(enum ldd_mount_type mount_type)
+{
+ void *handle;
+ char *error, filename[512], fsname[512], *name;
+ struct module_backfs_ops *ops;
+
+ /* This deals with duplicate ldd_mount_types resolving to same OSD layer
+ * plugin (e.g. ext3/ldiskfs/ldiskfs2 all being ldiskfs) */
+ strncpy(fsname, mt_type(mount_type), sizeof(fsname));
+ name = fsname + sizeof("osd-") - 1;
+
+ /* change osd- to osd_ */
+ fsname[sizeof("osd-") - 2] = '_';
+
+ snprintf(filename, sizeof(filename), PLUGIN_DIR"/mount_%s.so", fsname);
+
+ handle = dlopen(filename, RTLD_LAZY);
+ if (handle == NULL)
+ /* Do not clutter up console with missing types */
+ return NULL;
+
+ ops = malloc(sizeof(*ops));
+ if (ops == NULL) {
+ dlclose(handle);
+ return NULL;
+ }
+
+ ops->dl_handle = handle;
+ dlerror(); /* Clear any existing error */
+
+ DLSYM(name, ops, init);
+ DLSYM(name, ops, fini);
+ DLSYM(name, ops, read_ldd);
+ DLSYM(name, ops, write_ldd);
+ DLSYM(name, ops, is_lustre);
+ DLSYM(name, ops, make_lustre);
+ DLSYM(name, ops, prepare_lustre);
+ DLSYM(name, ops, tune_lustre);
+ DLSYM(name, ops, label_lustre);
+ DLSYM(name, ops, enable_quota);
+
+ error = dlerror();
+ if (error != NULL) {
+ fatal();
+ fprintf(stderr, "%s\n", error);
+ dlclose(handle);
+ free(ops);
+ return NULL;
+ }
+ return ops;
+}
+
+/**
+ * Unload plugin and free backfs_ops structure. Must be called the same number
+ * of times as load_backfs_module is.
+ */
+void unload_backfs_module(struct module_backfs_ops *ops)
+{
+ if (ops == NULL)
+ return;
+
+ dlclose(ops->dl_handle);
+ free(ops);
+}
+
+/* Return true if backfs_ops has operations for the given mount_type. */
+int backfs_mount_type_okay(enum ldd_mount_type mount_type)
+{
+ if (unlikely(mount_type >= LDD_MT_LAST || mount_type < 0)) {
+ fatal();
+ fprintf(stderr, "fs type out of range %d\n", mount_type);
+ return 0;
+ }
+ if (backfs_ops[mount_type] == NULL) {
+ fatal();
+ fprintf(stderr, "unhandled fs type %d '%s'\n",
+ mount_type, mt_str(mount_type));
+ return 0;
+ }
+ return 1;
+}
+
/* Write the server config files */
int osd_write_ldd(struct mkfs_opts *mop)
{
struct lustre_disk_data *ldd = &mop->mo_ldd;
int ret;
- switch (ldd->ldd_mount_type) {
-#ifdef HAVE_LDISKFS_OSD
- case LDD_MT_LDISKFS:
- case LDD_MT_LDISKFS2:
- ret = ldiskfs_write_ldd(mop);
- break;
-#endif /* HAVE_LDISKFS_OSD */
-#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",
- ldd->ldd_mount_type, MT_STR(ldd));
+ if (backfs_mount_type_okay(ldd->ldd_mount_type))
+ ret = backfs_ops[ldd->ldd_mount_type]->write_ldd(mop);
+
+ else
ret = EINVAL;
- break;
- }
return ret;
}
{
int ret;
- switch (ldd->ldd_mount_type) {
-#ifdef HAVE_LDISKFS_OSD
- case LDD_MT_LDISKFS:
- case LDD_MT_LDISKFS2:
- ret = ldiskfs_read_ldd(dev, ldd);
- break;
-#endif /* HAVE_LDISKFS_OSD */
-#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",
- ldd->ldd_mount_type, MT_STR(ldd));
+ if (backfs_mount_type_okay(ldd->ldd_mount_type))
+ ret = backfs_ops[ldd->ldd_mount_type]->read_ldd(dev, ldd);
+
+ else
ret = EINVAL;
- break;
- }
return ret;
}
/* Was this device formatted for Lustre */
int osd_is_lustre(char *dev, unsigned *mount_type)
{
+ int i;
+
vprint("checking for existing Lustre data: ");
-#ifdef HAVE_LDISKFS_OSD
- if (ldiskfs_is_lustre(dev, mount_type)) {
- vprint("found\n");
- return 1;
- }
-#endif /* HAVE_LDISKFS_OSD */
-#ifdef HAVE_ZFS_OSD
- if (zfs_is_lustre(dev, mount_type)) {
- vprint("found\n");
- return 1;
+ for (i = 0; i < LDD_MT_LAST; ++i) {
+ if (backfs_ops[i] != NULL &&
+ backfs_ops[i]->is_lustre(dev, mount_type)) {
+ vprint("found\n");
+ return 1;
+ }
}
-#endif /* HAVE_ZFS_OSD */
vprint("not found\n");
return 0;
struct lustre_disk_data *ldd = &mop->mo_ldd;
int ret;
- switch (ldd->ldd_mount_type) {
-#ifdef HAVE_LDISKFS_OSD
- case LDD_MT_LDISKFS:
- case LDD_MT_LDISKFS2:
- ret = ldiskfs_make_lustre(mop);
- break;
-#endif /* HAVE_LDISKFS_OSD */
-#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",
- ldd->ldd_mount_type, MT_STR(ldd));
+ if (backfs_mount_type_okay(ldd->ldd_mount_type))
+ ret = backfs_ops[ldd->ldd_mount_type]->make_lustre(mop);
+
+ else
ret = EINVAL;
- break;
- }
return ret;
}
struct lustre_disk_data *ldd = &mop->mo_ldd;
int ret;
- switch (ldd->ldd_mount_type) {
-#ifdef HAVE_LDISKFS_OSD
- case LDD_MT_LDISKFS:
- case LDD_MT_LDISKFS2:
- ret = ldiskfs_prepare_lustre(mop,
- default_mountopts, default_len,
- always_mountopts, always_len);
- break;
-#endif /* HAVE_LDISKFS_OSD */
-#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",
- ldd->ldd_mount_type, MT_STR(ldd));
+ if (backfs_mount_type_okay(ldd->ldd_mount_type))
+ ret = backfs_ops[ldd->ldd_mount_type]->prepare_lustre(mop,
+ default_mountopts, default_len,
+ always_mountopts, always_len);
+
+ else
ret = EINVAL;
- break;
- }
return ret;
}
struct lustre_disk_data *ldd = &mop->mo_ldd;
int ret;
- switch (ldd->ldd_mount_type) {
-#ifdef HAVE_LDISKFS_OSD
- case LDD_MT_LDISKFS:
- case LDD_MT_LDISKFS2:
- ret = ldiskfs_tune_lustre(dev, mop);
- break;
-#endif /* HAVE_LDISKFS_OSD */
-#ifdef HAVE_ZFS_OSD
- case LDD_MT_ZFS:
- ret = zfs_tune_lustre(dev, mop);
- break;
-#endif /* HAVE_ZFS_OSD */
- default:
- fatal();
- fprintf(stderr, "unknown fs type %d '%s'\n",
- ldd->ldd_mount_type, MT_STR(ldd));
+ if (backfs_mount_type_okay(ldd->ldd_mount_type))
+ ret = backfs_ops[ldd->ldd_mount_type]->tune_lustre(dev, mop);
+
+ else
ret = EINVAL;
- break;
- }
return ret;
}
struct lustre_disk_data *ldd = &mop->mo_ldd;
int ret;
- switch (ldd->ldd_mount_type) {
-#ifdef HAVE_LDISKFS_OSD
- case LDD_MT_LDISKFS:
- case LDD_MT_LDISKFS2:
- ret = ldiskfs_label_lustre(mop);
- break;
-#endif /* HAVE_LDISKFS_OSD */
-#ifdef HAVE_ZFS_OSD
- case LDD_MT_ZFS:
- ret = zfs_label_lustre(mop);
- break;
-#endif /* HAVE_ZFS_OSD */
- default:
- fatal();
- fprintf(stderr, "unknown fs type %d '%s'\n",
- ldd->ldd_mount_type, MT_STR(ldd));
+ if (backfs_mount_type_okay(ldd->ldd_mount_type))
+ ret = backfs_ops[ldd->ldd_mount_type]->label_lustre(mop);
+
+ else
ret = EINVAL;
- break;
- }
return ret;
}
struct lustre_disk_data *ldd = &mop->mo_ldd;
int ret;
- switch (ldd->ldd_mount_type) {
-#ifdef HAVE_LDISKFS_OSD
- case LDD_MT_EXT3:
- case LDD_MT_LDISKFS:
- case LDD_MT_LDISKFS2:
- ret = ldiskfs_enable_quota(mop);
- break;
-#endif /* HAVE_LDISKFS_OSD */
-#ifdef HAVE_ZFS_OSD
- case LDD_MT_ZFS:
- fprintf(stderr, "this option is only valid for ldiskfs\n");
- ret = EINVAL;
- break;
-#endif /* HAVE_ZFS_OSD */
- default:
- fatal();
- fprintf(stderr, "unknown fs type %d '%s'\n",
- ldd->ldd_mount_type, MT_STR(ldd));
+ if (backfs_mount_type_okay(ldd->ldd_mount_type))
+ ret = backfs_ops[ldd->ldd_mount_type]->enable_quota(mop);
+
+ else
ret = EINVAL;
- break;
- }
return ret;
}
int osd_init(void)
{
- int ret = 0;
+ int i, ret = 0;
-#ifdef HAVE_LDISKFS_OSD
- ret = ldiskfs_init();
- if (ret)
- return ret;
-#endif /* HAVE_LDISKFS_OSD */
-#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 */
+ for (i = 0; i < LDD_MT_LAST; ++i) {
+ backfs_ops[i] = load_backfs_module(i);
+ if (backfs_ops[i] != NULL)
+ ret = backfs_ops[i]->init();
+ if (ret)
+ break;
+ }
return ret;
}
void osd_fini(void)
{
-#ifdef HAVE_LDISKFS_OSD
- ldiskfs_fini();
-#endif /* HAVE_LDISKFS_OSD */
-#ifdef HAVE_ZFS_OSD
- zfs_fini();
-#endif /* HAVE_ZFS_OSD */
+ int i;
+
+ for (i = 0; i < LDD_MT_LAST; ++i) {
+ if (backfs_ops[i] != NULL) {
+ backfs_ops[i]->fini();
+ unload_backfs_module(backfs_ops[i]);
+ backfs_ops[i] = NULL;
+ }
+ }
}
__u64 get_device_size(char* device)
void trim_mountfsoptions(char *s);
__u64 get_device_size(char* device);
-int is_block(char *devname);
-void disp_old_e2fsprogs_msg(const char *feature, int make_backfs);
-int make_lustre_backfs(struct mkfs_opts *mop);
-int write_local_files(struct mkfs_opts *mop);
-int read_local_files(struct mkfs_opts *mop);
-int is_lustre_target(struct mkfs_opts *mop);
-
/* loopback helper functions */
int file_create(char *path, __u64 size);
int loop_format(struct mkfs_opts *mop);
int osd_init(void);
void osd_fini(void);
-int ldiskfs_write_ldd(struct mkfs_opts *mop);
-int ldiskfs_read_ldd(char *dev, struct lustre_disk_data *ldd);
-int ldiskfs_is_lustre(char *dev, unsigned *mount_type);
-int ldiskfs_make_lustre(struct mkfs_opts *mop);
-int ldiskfs_prepare_lustre(struct mkfs_opts *mop,
- char *default_mountopts, int default_len,
- char *always_mountopts, int always_len);
-int ldiskfs_tune_lustre(char *dev, struct mount_opts *mop);
-int ldiskfs_label_lustre(struct mount_opts *mop);
-int ldiskfs_enable_quota(struct mkfs_opts *mop);
-int ldiskfs_init(void);
-void ldiskfs_fini(void);
+struct module_backfs_ops {
+ int (*init)(void);
+ void (*fini)(void);
+ int (*read_ldd)(char *ds, struct lustre_disk_data *ldd);
+ int (*write_ldd)(struct mkfs_opts *mop);
+ int (*is_lustre)(char *dev, enum ldd_mount_type *mount_type);
+ int (*make_lustre)(struct mkfs_opts *mop);
+ int (*prepare_lustre)(struct mkfs_opts *mop,
+ char *default_mountopts, int default_len,
+ char *always_mountopts, int always_len);
+ int (*tune_lustre)(char *dev, struct mount_opts *mop);
+ int (*label_lustre)(struct mount_opts *mop);
+ int (*enable_quota)(struct mkfs_opts *mop);
+ void *dl_handle;
+};
-#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_tune_lustre(char *dev, struct mount_opts *mop);
-int zfs_label_lustre(struct mount_opts *mop);
-int zfs_init(void);
-void zfs_fini(void);
-#endif
+struct module_backfs_ops *load_backfs_module(enum ldd_mount_type mount_type);
+void unload_backfs_ops(struct module_backfs_ops *ops);
#endif
* Concatenate context of the temporary mount point iff selinux is enabled
*/
#ifdef HAVE_SELINUX
-void append_context_for_mount(char *mntpt, struct mkfs_opts *mop)
+static void append_context_for_mount(char *mntpt, struct mkfs_opts *mop)
{
security_context_t fcontext;
}
#endif
+/* return canonicalized absolute pathname, even if the target file does not
+ * exist, unlike realpath */
+static char *absolute_path(char *devname)
+{
+ char buf[PATH_MAX + 1] = "";
+ char *path;
+ char *ptr;
+ int len;
+
+ path = malloc(sizeof(buf));
+ if (path == NULL)
+ return NULL;
+
+ if (devname[0] != '/') {
+ if (getcwd(buf, sizeof(buf) - 1) == NULL) {
+ free(path);
+ return NULL;
+ }
+ len = snprintf(path, sizeof(buf), "%s/%s", buf, devname);
+ if (len >= sizeof(buf)) {
+ free(path);
+ return NULL;
+ }
+ } else {
+ len = snprintf(path, sizeof(buf), "%s", devname);
+ if (len >= sizeof(buf)) {
+ free(path);
+ return NULL;
+ }
+ }
+
+ /* truncate filename before calling realpath */
+ ptr = strrchr(path, '/');
+ if (ptr == NULL) {
+ free(path);
+ return NULL;
+ }
+ *ptr = '\0';
+ if (buf != realpath(path, buf)) {
+ free(path);
+ return NULL;
+ }
+ /* add the filename back */
+ len = snprintf(path, PATH_MAX, "%s/%s", buf, ptr+1);
+ if (len >= PATH_MAX) {
+ free(path);
+ return NULL;
+ }
+ return path;
+}
+
+/* Determine if a device is a block device (as opposed to a file) */
+static int is_block(char *devname)
+{
+ struct stat st;
+ int ret = 0;
+ char *devpath;
+
+ devpath = absolute_path(devname);
+ if (devpath == NULL) {
+ fprintf(stderr, "%s: failed to resolve path to %s\n",
+ progname, devname);
+ return -1;
+ }
+
+ ret = access(devname, F_OK);
+ if (ret != 0) {
+ if (strncmp(devpath, "/dev/", 5) == 0) {
+ /* nobody sane wants to create a loopback file under
+ * /dev. Let's just report the device doesn't exist */
+ fprintf(stderr, "%s: %s apparently does not exist\n",
+ progname, devpath);
+ ret = -1;
+ goto out;
+ }
+ ret = 0;
+ goto out;
+ }
+ ret = stat(devpath, &st);
+ if (ret != 0) {
+ fprintf(stderr, "%s: cannot stat %s\n", progname, devpath);
+ goto out;
+ }
+ ret = S_ISBLK(st.st_mode);
+out:
+ free(devpath);
+ return ret;
+}
+
+static int is_feature_enabled(const char *feature, const char *devpath)
+{
+ char cmd[PATH_MAX];
+ FILE *fp;
+ char enabled_features[4096] = "";
+ int ret = 1;
+
+ snprintf(cmd, sizeof(cmd), "%s -R features %s 2>&1",
+ DEBUGFS, devpath);
+
+ /* Using popen() instead of run_command() since debugfs does
+ * not return proper error code if command is not supported */
+ fp = popen(cmd, "r");
+ if (!fp) {
+ fprintf(stderr, "%s: %s\n", progname, strerror(errno));
+ return 0;
+ }
+
+ ret = fread(enabled_features, 1, sizeof(enabled_features) - 1, fp);
+ enabled_features[ret] = '\0';
+ pclose(fp);
+
+ if (strstr(enabled_features, feature))
+ return 1;
+ return 0;
+}
+
/* Write the server config files */
int ldiskfs_write_ldd(struct mkfs_opts *mop)
{
/* Display the need for the latest e2fsprogs to be installed. make_backfs
* indicates if the caller is make_lustre_backfs() or not. */
-void disp_old_e2fsprogs_msg(const char *feature, int make_backfs)
+static void disp_old_e2fsprogs_msg(const char *feature, int make_backfs)
{
static int msg_displayed;
return 0;
}
-int read_file(const char *path, char *buf, int size)
+static int read_file(const char *path, char *buf, int size)
{
FILE *fd;
return 0;
}
-int write_file(const char *path, const char *buf)
+static int write_file(const char *path, const char *buf)
{
FILE *fd;
return 0;
}
-int set_blockdev_scheduler(const char *path, const char *scheduler)
+static int set_blockdev_scheduler(const char *path, const char *scheduler)
{
char buf[PATH_MAX], *c;
int rc;
/* This is to tune the kernel for good SCSI performance.
* For that we set the value of /sys/block/{dev}/queue/max_sectors_kb
* to the value of /sys/block/{dev}/queue/max_hw_sectors_kb */
-int set_blockdev_tunables(char *source, struct mount_opts *mop)
+static int set_blockdev_tunables(char *source, struct mount_opts *mop)
{
glob_t glob_info = { 0 };
struct stat stat_buf;
return rc;
}
-/* return canonicalized absolute pathname, even if the target file does not
- * exist, unlike realpath */
-static char *absolute_path(char *devname)
-{
- char buf[PATH_MAX + 1];
- char *path;
- char *ptr;
-
- path = malloc(PATH_MAX + 1);
- if (path == NULL)
- return NULL;
-
- if (devname[0] != '/') {
- if (getcwd(buf, sizeof(buf) - 1) == NULL) {
- free(path);
- return NULL;
- }
- strcat(buf, "/");
- if (strlen(devname) > sizeof(buf)-strlen(buf)-1) {
- free(path);
- return NULL;
- }
- strncat(buf, devname, sizeof(buf)-strlen(buf)-1);
- } else {
- if (strlen(devname) > sizeof(buf)-1) {
- free(path);
- return NULL;
- }
- strncpy(buf, devname, sizeof(buf));
- }
- /* truncate filename before calling realpath */
- ptr = strrchr(buf, '/');
- if (ptr == NULL) {
- free(path);
- return NULL;
- }
- *ptr = '\0';
- if (path != realpath(buf, path)) {
- free(path);
- return NULL;
- }
- /* add the filename back */
- strcat(path, "/");
- strcat(path, ptr + 1);
- return path;
-}
-
-/* Determine if a device is a block device (as opposed to a file) */
-int is_block(char* devname)
-{
- struct stat st;
- int ret = 0;
- char *devpath;
-
- devpath = absolute_path(devname);
- if (devpath == NULL) {
- fprintf(stderr, "%s: failed to resolve path to %s\n",
- progname, devname);
- return -1;
- }
-
- ret = access(devname, F_OK);
- if (ret != 0) {
- if (strncmp(devpath, "/dev/", 5) == 0) {
- /* nobody sane wants to create a loopback file under
- * /dev. Let's just report the device doesn't exist */
- fprintf(stderr, "%s: %s apparently does not exist\n",
- progname, devpath);
- ret = -1;
- goto out;
- }
- ret = 0;
- goto out;
- }
- ret = stat(devpath, &st);
- if (ret != 0) {
- fprintf(stderr, "%s: cannot stat %s\n", progname, devpath);
- goto out;
- }
- ret = S_ISBLK(st.st_mode);
-out:
- free(devpath);
- return ret;
-}
-
-static int is_feature_enabled(const char *feature, const char *devpath)
-{
- char cmd[PATH_MAX];
- FILE *fp;
- char enabled_features[4096] = "";
- int ret = 1;
-
- snprintf(cmd, sizeof(cmd), "%s -R features %s 2>&1",
- DEBUGFS, devpath);
-
- /* Using popen() instead of run_command() since debugfs does
- * not return proper error code if command is not supported */
- fp = popen(cmd, "r");
- if (!fp) {
- fprintf(stderr, "%s: %s\n", progname, strerror(errno));
- return 0;
- }
-
- ret = fread(enabled_features, 1, sizeof(enabled_features) - 1, fp);
- enabled_features[ret] = '\0';
- pclose(fp);
-
- if (strstr(enabled_features, feature))
- return 1;
- return 0;
-}
-
/* Enable quota accounting */
int ldiskfs_enable_quota(struct mkfs_opts *mop)
{
#include <stdio.h>
#include <string.h>
#include <libzfs.h>
-#include <dlfcn.h>
/* Persistent mount data is stored in these user attributes */
#define LDD_PREFIX "lustre:"
static libzfs_handle_t *g_zfs;
-/* dynamic linking handles for libzfs & libnvpair */
-static void *handle_libzfs;
-static void *handle_nvpair;
-
-/* symbol table looked up with dlsym */
-struct zfs_symbols {
- libzfs_handle_t *(*libzfs_init)(void);
- void (*libzfs_fini)(libzfs_handle_t *);
- int (*libzfs_load_module)(char *);
- zfs_handle_t* (*zfs_open)(libzfs_handle_t *, const char *, int);
- int (*zfs_destroy)(zfs_handle_t *, boolean_t);
- void (*zfs_close)(zfs_handle_t *);
- int (*zfs_prop_set)(zfs_handle_t*, const char*, const char*);
- nvlist_t* (*zfs_get_user_props) (zfs_handle_t *);
- int (*zfs_name_valid)(const char *, zfs_type_t);
- zpool_handle_t* (*zpool_open)(libzfs_handle_t *, const char *);
- void (*zpool_close)(zpool_handle_t *zhp);
- int (*nvlist_lookup_string)(nvlist_t*, const char*, char**);
- int (*nvlist_lookup_nvlist)(nvlist_t *, const char *, nvlist_t **);
- nvpair_t * (*nvlist_next_nvpair)(nvlist_t *, nvpair_t *);
- char * (*nvpair_name)(nvpair_t *);
-};
-
-static struct zfs_symbols sym;
void zfs_fini(void);
-#define DLSYM(handle, func) \
- do { \
- sym.func = (typeof(sym.func))dlsym(handle, #func); \
- } while(0)
-
-/* populate the symbol table after a successful call to dlopen() */
-static int zfs_populate_symbols(void)
-{
- char *error;
-
- dlerror(); /* Clear any existing error */
-
- DLSYM(handle_libzfs, libzfs_init);
-#define libzfs_init (*sym.libzfs_init)
- DLSYM(handle_libzfs, libzfs_fini);
-#define libzfs_fini (*sym.libzfs_fini)
- DLSYM(handle_libzfs, libzfs_load_module);
-#define libzfs_load_module (*sym.libzfs_load_module)
- DLSYM(handle_libzfs, zfs_open);
-#define zfs_open (*sym.zfs_open)
- DLSYM(handle_libzfs, zfs_destroy);
-#define zfs_destroy (*sym.zfs_destroy)
- DLSYM(handle_libzfs, zfs_close);
-#define zfs_close (*sym.zfs_close)
- DLSYM(handle_libzfs, zfs_prop_set);
-#define zfs_prop_set (*sym.zfs_prop_set)
- DLSYM(handle_libzfs, zfs_get_user_props);
-#define zfs_get_user_props (*sym.zfs_get_user_props)
- DLSYM(handle_libzfs, zfs_name_valid);
-#define zfs_name_valid (*sym.zfs_name_valid)
- DLSYM(handle_libzfs, zpool_open);
-#define zpool_open (*sym.zpool_open)
- DLSYM(handle_libzfs, zpool_close);
-#define zpool_close (*sym.zpool_close)
- DLSYM(handle_nvpair, nvlist_lookup_string);
-#define nvlist_lookup_string (*sym.nvlist_lookup_string)
- DLSYM(handle_nvpair, nvlist_lookup_nvlist);
-#define nvlist_lookup_nvlist (*sym.nvlist_lookup_nvlist)
- DLSYM(handle_nvpair, nvlist_next_nvpair);
-#define nvlist_next_nvpair (*sym.nvlist_next_nvpair)
- DLSYM(handle_nvpair, nvpair_name);
-#define nvpair_name (*sym.nvpair_name)
-
- error = dlerror();
- if (error != NULL) {
- fatal();
- fprintf(stderr, "%s\n", error);
- return EINVAL;
- }
- return 0;
-}
-
static int zfs_set_prop_int(zfs_handle_t *zhp, char *prop, void *val)
{
char str[64];
return ret;
}
+int zfs_enable_quota(struct mkfs_opts *mop)
+{
+ fprintf(stderr, "this option is not only valid for zfs\n");
+ return ENOSYS;
+}
+
int zfs_prepare_lustre(struct mkfs_opts *mop,
char *default_mountopts, int default_len,
char *always_mountopts, int always_len)
* spamming ldiskfs users. An error message will still be printed if
* someone tries to do some real work involving a ZFS backend */
- handle_libzfs = dlopen("libzfs.so.1", RTLD_LAZY);
- if (handle_libzfs == NULL)
- return EINVAL;
-
- handle_nvpair = dlopen("libnvpair.so.1", RTLD_LAZY);
- if (handle_nvpair == NULL) {
- ret = EINVAL;
- goto out;
- }
-
- ret = zfs_populate_symbols();
- if (ret)
- goto out;
-
if (libzfs_load_module("zfs") != 0) {
/* The ZFS modules are not installed */
ret = EINVAL;
libzfs_fini(g_zfs);
g_zfs = NULL;
}
- if (handle_nvpair) {
- dlclose(handle_nvpair);
- handle_nvpair = NULL;
- }
- if (handle_libzfs) {
- dlclose(handle_libzfs);
- handle_libzfs = NULL;
- }
-
osd_zfs_setup = 0;
}
-agent_PROGRAMS = lustresnmp.so
+agent_LTLIBRARIES = lustresnmp.la
mib_DATA = Lustre-MIB.txt
-lustresnmp_so_SOURCES = \
+lustresnmp_la_SOURCES = \
lustre-snmp.c \
lustre-snmp.h \
lustre-snmp-trap.c \
lustre-snmp-util.c \
lustre-snmp-util.h
-lustresnmp_so_LDADD := $(NET_SNMP_LIBS)
-lustresnmp_so_CFLAGS := -fPIC $(NET_SNMP_CFLAGS)
-lustresnmp_so_LDFLAGS = -fPIC -shared
+lustresnmp_la_LIBADD := $(NET_SNMP_LIBS)
+lustresnmp_la_CFLAGS := -fPIC $(NET_SNMP_CFLAGS)
+lustresnmp_la_LDFLAGS = -fPIC -shared -module -avoid-version
SUBDIRS =
DIST_SUBDIRS = autoconf