From: Sage Weil Date: Wed, 23 Dec 2015 16:32:28 +0000 (-0500) Subject: os/ZFS: move to os/fs X-Git-Tag: v10.0.3~154^2~37 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8fc65e1b40fe66adc17fc8203a409b9379a40ff5;p=ceph.git os/ZFS: move to os/fs Signed-off-by: Sage Weil --- diff --git a/src/os/Makefile.am b/src/os/Makefile.am index abba3fcbd4d9..bd2bac7d2756 100644 --- a/src/os/Makefile.am +++ b/src/os/Makefile.am @@ -99,10 +99,10 @@ noinst_HEADERS += \ os/ObjectStore.h if WITH_LIBZFS -libos_zfs_a_SOURCES = os/ZFS.cc +libos_zfs_a_SOURCES = os/fs/ZFS.cc libos_zfs_a_CXXFLAGS = ${AM_CXXFLAGS} ${LIBZFS_CFLAGS} noinst_LIBRARIES += libos_zfs.a -noinst_HEADERS += os/ZFS.h +noinst_HEADERS += os/fs/ZFS.h endif ceph_bluefs_tool_SOURCES = os/bluestore/bluefs_tool.cc diff --git a/src/os/ZFS.cc b/src/os/ZFS.cc deleted file mode 100644 index 02520796c730..000000000000 --- a/src/os/ZFS.cc +++ /dev/null @@ -1,83 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#define HAVE_IOCTL_IN_SYS_IOCTL_H -#include -#include "ZFS.h" - -const int ZFS::TYPE_FILESYSTEM = ZFS_TYPE_FILESYSTEM; -const int ZFS::TYPE_SNAPSHOT = ZFS_TYPE_SNAPSHOT; -const int ZFS::TYPE_VOLUME = ZFS_TYPE_VOLUME; -const int ZFS::TYPE_DATASET = ZFS_TYPE_DATASET; - -ZFS::~ZFS() -{ - if (g_zfs) - ::libzfs_fini((libzfs_handle_t*)g_zfs); -} - -int ZFS::init() -{ - g_zfs = ::libzfs_init(); - return g_zfs ? 0 : -EINVAL; -} - -ZFS::Handle *ZFS::open(const char *n, int t) -{ - return (ZFS::Handle*)::zfs_open((libzfs_handle_t*)g_zfs, n, (zfs_type_t)t); -} - -void ZFS::close(ZFS::Handle *h) -{ - ::zfs_close((zfs_handle_t*)h); -} - -const char *ZFS::get_name(ZFS::Handle *h) -{ - return ::zfs_get_name((zfs_handle_t*)h); -} - -ZFS::Handle *ZFS::path_to_zhandle(const char *p, int t) -{ - return ::zfs_path_to_zhandle((libzfs_handle_t*)g_zfs, (char *)p, (zfs_type_t)t); -} - -int ZFS::create(const char *n, int t) -{ - return ::zfs_create((libzfs_handle_t*)g_zfs, n, (zfs_type_t)t, NULL); -} - -int ZFS::snapshot(const char *n, bool r) -{ - return ::zfs_snapshot((libzfs_handle_t*)g_zfs, n, (boolean_t)r, NULL); -} - -int ZFS::rollback(ZFS::Handle *h, ZFS::Handle *snap, bool f) -{ - return ::zfs_rollback((zfs_handle_t*)h, (zfs_handle_t*)snap, (boolean_t)f); -} - -int ZFS::destroy_snaps(ZFS::Handle *h, const char *n, bool d) -{ - return ::zfs_destroy_snaps((zfs_handle_t*)h, (char *)n, (boolean_t)d); -} - -bool ZFS::is_mounted(ZFS::Handle *h, char **p) -{ - return (bool)::zfs_is_mounted((zfs_handle_t*)h, p); -} - -int ZFS::mount(ZFS::Handle *h, const char *o, int f) -{ - return ::zfs_mount((zfs_handle_t*)h, o, f); -} - -int ZFS::umount(ZFS::Handle *h, const char *o, int f) -{ - return ::zfs_unmount((zfs_handle_t*)h, o, f); -} - -int ZFS::iter_snapshots_sorted(ZFS::Handle *h, ZFS::iter_func f, void *d) -{ - return ::zfs_iter_snapshots_sorted((zfs_handle_t*)h, (zfs_iter_f)f, d); -} diff --git a/src/os/ZFS.h b/src/os/ZFS.h deleted file mode 100644 index 3ebe11107b20..000000000000 --- a/src/os/ZFS.h +++ /dev/null @@ -1,39 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#ifndef CEPH_ZFS_H -#define CEPH_ZFS_H - -// Simple wrapper to hide libzfs.h. (it conflicts with standard linux headers) -class ZFS { - void *g_zfs; -public: - - static const int TYPE_FILESYSTEM; - static const int TYPE_SNAPSHOT; - static const int TYPE_VOLUME; - static const int TYPE_POOL; - static const int TYPE_DATASET; - - typedef void Handle; - typedef int (*iter_func)(Handle *, void *); - - static const char *get_name(Handle *); - - ZFS() : g_zfs(NULL) {} - ~ZFS(); - int init(); - Handle *open(const char *, int); - void close(Handle *); - Handle *path_to_zhandle(const char *, int); - int create(const char *, int); - int snapshot(const char *, bool); - int rollback(Handle *, Handle *, bool); - int destroy_snaps(Handle *, const char *, bool); - int iter_snapshots_sorted(Handle *, iter_func, void *); - int mount(Handle *, const char *, int); - int umount(Handle *, const char *, int); - bool is_mounted(Handle *, char **); -}; - -#endif diff --git a/src/os/filestore/ZFSFileStoreBackend.h b/src/os/filestore/ZFSFileStoreBackend.h index 8186d9ca957d..f68b8abd6c12 100644 --- a/src/os/filestore/ZFSFileStoreBackend.h +++ b/src/os/filestore/ZFSFileStoreBackend.h @@ -6,7 +6,7 @@ #ifdef HAVE_LIBZFS #include "GenericFileStoreBackend.h" -#include "ZFS.h" +#include "os/fs/ZFS.h" class ZFSFileStoreBackend : public GenericFileStoreBackend { private: diff --git a/src/os/fs/ZFS.cc b/src/os/fs/ZFS.cc new file mode 100644 index 000000000000..02520796c730 --- /dev/null +++ b/src/os/fs/ZFS.cc @@ -0,0 +1,83 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#define HAVE_IOCTL_IN_SYS_IOCTL_H +#include +#include "ZFS.h" + +const int ZFS::TYPE_FILESYSTEM = ZFS_TYPE_FILESYSTEM; +const int ZFS::TYPE_SNAPSHOT = ZFS_TYPE_SNAPSHOT; +const int ZFS::TYPE_VOLUME = ZFS_TYPE_VOLUME; +const int ZFS::TYPE_DATASET = ZFS_TYPE_DATASET; + +ZFS::~ZFS() +{ + if (g_zfs) + ::libzfs_fini((libzfs_handle_t*)g_zfs); +} + +int ZFS::init() +{ + g_zfs = ::libzfs_init(); + return g_zfs ? 0 : -EINVAL; +} + +ZFS::Handle *ZFS::open(const char *n, int t) +{ + return (ZFS::Handle*)::zfs_open((libzfs_handle_t*)g_zfs, n, (zfs_type_t)t); +} + +void ZFS::close(ZFS::Handle *h) +{ + ::zfs_close((zfs_handle_t*)h); +} + +const char *ZFS::get_name(ZFS::Handle *h) +{ + return ::zfs_get_name((zfs_handle_t*)h); +} + +ZFS::Handle *ZFS::path_to_zhandle(const char *p, int t) +{ + return ::zfs_path_to_zhandle((libzfs_handle_t*)g_zfs, (char *)p, (zfs_type_t)t); +} + +int ZFS::create(const char *n, int t) +{ + return ::zfs_create((libzfs_handle_t*)g_zfs, n, (zfs_type_t)t, NULL); +} + +int ZFS::snapshot(const char *n, bool r) +{ + return ::zfs_snapshot((libzfs_handle_t*)g_zfs, n, (boolean_t)r, NULL); +} + +int ZFS::rollback(ZFS::Handle *h, ZFS::Handle *snap, bool f) +{ + return ::zfs_rollback((zfs_handle_t*)h, (zfs_handle_t*)snap, (boolean_t)f); +} + +int ZFS::destroy_snaps(ZFS::Handle *h, const char *n, bool d) +{ + return ::zfs_destroy_snaps((zfs_handle_t*)h, (char *)n, (boolean_t)d); +} + +bool ZFS::is_mounted(ZFS::Handle *h, char **p) +{ + return (bool)::zfs_is_mounted((zfs_handle_t*)h, p); +} + +int ZFS::mount(ZFS::Handle *h, const char *o, int f) +{ + return ::zfs_mount((zfs_handle_t*)h, o, f); +} + +int ZFS::umount(ZFS::Handle *h, const char *o, int f) +{ + return ::zfs_unmount((zfs_handle_t*)h, o, f); +} + +int ZFS::iter_snapshots_sorted(ZFS::Handle *h, ZFS::iter_func f, void *d) +{ + return ::zfs_iter_snapshots_sorted((zfs_handle_t*)h, (zfs_iter_f)f, d); +} diff --git a/src/os/fs/ZFS.h b/src/os/fs/ZFS.h new file mode 100644 index 000000000000..3ebe11107b20 --- /dev/null +++ b/src/os/fs/ZFS.h @@ -0,0 +1,39 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_ZFS_H +#define CEPH_ZFS_H + +// Simple wrapper to hide libzfs.h. (it conflicts with standard linux headers) +class ZFS { + void *g_zfs; +public: + + static const int TYPE_FILESYSTEM; + static const int TYPE_SNAPSHOT; + static const int TYPE_VOLUME; + static const int TYPE_POOL; + static const int TYPE_DATASET; + + typedef void Handle; + typedef int (*iter_func)(Handle *, void *); + + static const char *get_name(Handle *); + + ZFS() : g_zfs(NULL) {} + ~ZFS(); + int init(); + Handle *open(const char *, int); + void close(Handle *); + Handle *path_to_zhandle(const char *, int); + int create(const char *, int); + int snapshot(const char *, bool); + int rollback(Handle *, Handle *, bool); + int destroy_snaps(Handle *, const char *, bool); + int iter_snapshots_sorted(Handle *, iter_func, void *); + int mount(Handle *, const char *, int); + int umount(Handle *, const char *, int); + bool is_mounted(Handle *, char **); +}; + +#endif