From: Sage Weil Date: Thu, 22 Sep 2011 22:07:19 +0000 (-0700) Subject: libceph -> libcephfs X-Git-Tag: v0.36~49^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fba541e4e85ee17bf3c9c1f97b69922d4e3cce70;p=ceph.git libceph -> libcephfs Signed-off-by: Sage Weil --- diff --git a/ceph.spec.in b/ceph.spec.in index 40d8f201ed94..4cce04ef7c07 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -178,7 +178,7 @@ fi %{_bindir}/ceph-coverage %{_bindir}/obsync %{_initrddir}/ceph -%{_libdir}/libceph.so.* +%{_libdir}/libcephfs.so.* %{_libdir}/librados.so.* %{_libdir}/librbd.so.* %{_libdir}/rados-classes/libcls_rbd.so.* @@ -234,7 +234,7 @@ fi %files devel %defattr(-,root,root,-) %doc COPYING -%{_includedir}/ceph/libceph.h +%{_includedir}/cephfs/libcephfs.h %{_includedir}/crush/crush.h %{_includedir}/crush/hash.h %{_includedir}/crush/mapper.h diff --git a/debian/.gitignore b/debian/.gitignore index 2860422a96fb..1409714d5029 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -10,9 +10,9 @@ /*.debhelper /ceph /files -/libceph1-dbg -/libceph-dev -/libceph1 +/libcephfs1-dbg +/libcephfs-dev +/libcephfs1 /librados2-dbg /librados-dev /librados2 diff --git a/debian/control b/debian/control index eb583e77a5d7..184f93c8f8e7 100644 --- a/debian/control +++ b/debian/control @@ -12,7 +12,7 @@ Standards-Version: 3.9.1 Package: ceph Architecture: linux-any Depends: ${shlibs:Depends}, ${misc:Depends}, hdparm, binutils -Recommends: ceph-client-tools, ceph-fuse, libceph1, librados2, librbd1, btrfs-tools, gceph +Recommends: ceph-client-tools, ceph-fuse, libcephfs1, librados2, librbd1, btrfs-tools, gceph Description: distributed storage and file system Ceph is a distributed storage and network file system designed to provide excellent performance, reliability, and scalability. @@ -186,9 +186,9 @@ Description: RADOS block device client library (development files) This package contains development files needed for building applications that link against librbd1. -Package: libceph1 -Conflicts: libceph -Replaces: libceph +Package: libcephfs1 +Conflicts: libcephfs +Replaces: libcephfs Architecture: linux-any Section: libs Depends: ${shlibs:Depends}, ${misc:Depends} @@ -198,25 +198,25 @@ Description: Ceph distributed file system client library shared library allowing applications to access a Ceph distributed file system via a POSIX-like interface. -Package: libceph1-dbg +Package: libcephfs1-dbg Architecture: linux-any Section: debug Priority: extra -Depends: libceph1 (= ${binary:Version}), ${misc:Depends} -Description: debugging symbols for libceph1 +Depends: libcephfs1 (= ${binary:Version}), ${misc:Depends} +Description: debugging symbols for libcephfs1 Ceph is a distributed network file system designed to provide excellent performance, reliability, and scalability. This is a shared library allowing applications to access a Ceph distributed file system via a POSIX-like interface. . - This package contains debugging symbols for libceph1. + This package contains debugging symbols for libcephfs1. -Package: libceph-dev +Package: libcephfs-dev Architecture: linux-any Section: libdevel -Depends: ${misc:Depends}, libceph1 (= ${binary:Version}) -Conflicts: libceph1-dev -Replaces: libceph1-dev +Depends: ${misc:Depends}, libcephfs1 (= ${binary:Version}) +Conflicts: libcephfs1-dev +Replaces: libcephfs1-dev Description: Ceph distributed file system client library (development files) Ceph is a distributed network file system designed to provide excellent performance, reliability, and scalability. This is a @@ -224,7 +224,7 @@ Description: Ceph distributed file system client library (development files) file system via a POSIX-like interface. . This package contains development files needed for building applications that - link against libceph. + link against libcephfs. Package: librgw1 Conflicts: librgw, librgw1 diff --git a/debian/libceph-dev.install b/debian/libceph-dev.install index 9951a2b343ce..902fb950cc15 100644 --- a/debian/libceph-dev.install +++ b/debian/libceph-dev.install @@ -1,4 +1,4 @@ -usr/lib/libceph.so -usr/lib/libceph.a -usr/lib/libceph.la -usr/include/ceph/libceph.h +usr/lib/libcephfs.so +usr/lib/libcephfs.a +usr/lib/libcephfs.la +usr/include/cephfs/libcephfs.h diff --git a/debian/libceph1.install b/debian/libceph1.install index 7008bb642225..a5266dfbca3e 100644 --- a/debian/libceph1.install +++ b/debian/libceph1.install @@ -1,2 +1,2 @@ -usr/lib/libceph.so.* +usr/lib/libcephfs.so.* diff --git a/debian/rules b/debian/rules index ad1782b3d1fa..e604c2e0930b 100755 --- a/debian/rules +++ b/debian/rules @@ -106,7 +106,7 @@ binary-arch: build install dh_strip -pceph-client-tools --dbg-package=ceph-client-tools-dbg dh_strip -plibrados2 --dbg-package=librados2-dbg dh_strip -plibrbd1 --dbg-package=librbd1-dbg - dh_strip -plibceph1 --dbg-package=libceph1-dbg + dh_strip -plibcephfs1 --dbg-package=libcephfs1-dbg dh_strip -pradosgw --dbg-package=radosgw-dbg dh_strip -pgceph --dbg-package=gceph-dbg dh_strip -plibrgw1 --dbg-package=librgw1-dbg diff --git a/doc/architecture.rst b/doc/architecture.rst index e8f8b6d874d8..2bd5c55cc713 100644 --- a/doc/architecture.rst +++ b/doc/architecture.rst @@ -173,7 +173,7 @@ better than a single server could. Client ====== -.. todo:: cephfs, ceph-fuse, librados, libceph, librbd +.. todo:: cephfs, ceph-fuse, librados, libcephfs, librbd .. todo:: Summarize how much Ceph trusts the client, for what parts (security vs reliability). diff --git a/doc/dev/libs.rst b/doc/dev/libs.rst index bdebdb3b0004..203dd38b06dd 100644 --- a/doc/dev/libs.rst +++ b/doc/dev/libs.rst @@ -8,7 +8,7 @@ make executables and other libraries. - libcommon: a collection of utilities which are available to nearly every ceph library and executable. In general, libcommon should not contain global variables, because it is intended to be linked into libraries such as - libceph.so. + libcephfs.so. - libglobal: a collection of utilities focused on the needs of Ceph daemon programs. In here you will find pidfile management functions, signal diff --git a/doc/ops/install/mkcephfs.rst b/doc/ops/install/mkcephfs.rst index 3645383b2f9a..58a6da3c9006 100644 --- a/doc/ops/install/mkcephfs.rst +++ b/doc/ops/install/mkcephfs.rst @@ -55,9 +55,9 @@ Run these commands on all nodes:: .. todo:: For older distributions, you may need to make sure your apt-get may read .bz2 compressed files. This works for Debian Lenny 5.0.3: ``apt-get install bzip2`` .. todo:: Ponder packages; ceph.deb currently pulls in gceph (ceph.deb - Recommends: ceph-client-tools ceph-fuse libceph1 librados2 librbd1 + Recommends: ceph-client-tools ceph-fuse libcephfs1 librados2 librbd1 btrfs-tools gceph) (other interesting: ceph-client-tools ceph-fuse - libceph-dev librados-dev librbd-dev obsync python-ceph radosgw) + libcephfs-dev librados-dev librbd-dev obsync python-ceph radosgw) Red Hat / CentOS / Fedora diff --git a/src/Makefile.am b/src/Makefile.am index ef5e17a66f8b..2eaf84e3076c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -199,16 +199,16 @@ test_librgw_build_LDADD = -lexpat -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS) test_librgw_build_CXXFLAGS = $(AM_CXXFLAGS) bin_DEBUGPROGRAMS += test_librgw_build -test_libceph_build_SOURCES = test/test_libcommon_build.cc $(libcommon_files) \ - $(libceph_la_SOURCES) $(libosdc_la_SOURCES) -test_libceph_build_LDADD = -lexpat -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS) -test_libceph_build_CXXFLAGS = $(AM_CXXFLAGS) -bin_DEBUGPROGRAMS += test_libceph_build +test_libcephfs_build_SOURCES = test/test_libcommon_build.cc $(libcommon_files) \ + $(libcephfs_la_SOURCES) $(libosdc_la_SOURCES) +test_libcephfs_build_LDADD = -lexpat -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS) +test_libcephfs_build_CXXFLAGS = $(AM_CXXFLAGS) +bin_DEBUGPROGRAMS += test_libcephfs_build endif if WITH_HADOOPCLIENT test_libhadoopcephfs_build_SOURCES = test/test_libcommon_build.cc \ - $(libhadoopcephfs_la_SOURCES) $(libceph_la_SOURCES) \ + $(libhadoopcephfs_la_SOURCES) $(libcephfs_la_SOURCES) \ $(libosdc_la_SOURCES) $(libcommon_files) test_libhadoopcephfs_build_LDADD = -lexpat -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS) test_libhadoopcephfs_build_CXXFLAGS = $(AM_CXXFLAGS) @@ -221,21 +221,21 @@ lib_LTLIBRARIES = noinst_LTLIBRARIES = noinst_LIBRARIES = -# libceph -libceph_la_SOURCES = \ - libceph.cc \ +# libcephfs +libcephfs_la_SOURCES = \ + libcephfs.cc \ client/Client.cc \ client/Inode.cc \ client/MetaRequest.cc -libceph_la_CFLAGS= ${CRYPTO_CFLAGS} ${AM_CFLAGS} -libceph_la_CXXFLAGS= ${CRYPTO_CXXFLAGS} ${AM_CXXFLAGS} -libceph_la_LIBADD = libosdc.la -libceph_la_LDFLAGS = -lpthread $(CRYPTO_LIBS) $(EXTRALIBS) \ +libcephfs_la_CFLAGS= ${CRYPTO_CFLAGS} ${AM_CFLAGS} +libcephfs_la_CXXFLAGS= ${CRYPTO_CXXFLAGS} ${AM_CXXFLAGS} +libcephfs_la_LIBADD = libosdc.la +libcephfs_la_LDFLAGS = -lpthread $(CRYPTO_LIBS) $(EXTRALIBS) \ ${AM_LDFLAGS} -version-info 1:0:0 -export-symbols-regex '^ceph_.*' -lib_LTLIBRARIES += libceph.la +lib_LTLIBRARIES += libcephfs.la testceph_SOURCES = client/testceph.cc -testceph_LDADD = libceph.la -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS) +testceph_LDADD = libcephfs.la -lpthread -lm $(CRYPTO_LIBS) $(EXTRALIBS) bin_DEBUGPROGRAMS += testceph testtimers_SOURCES = test/TestTimers.cc @@ -371,7 +371,7 @@ radoslib_LTLIBRARIES = libcls_rbd.la if WITH_HADOOPCLIENT JAVA_BASE = /usr/lib/jvm/java-6-sun libhadoopcephfs_la_SOURCES = client/hadoop/CephFSInterface.cc -libhadoopcephfs_la_LIBADD = libceph.la +libhadoopcephfs_la_LIBADD = libcephfs.la libhadoopcephfs_la_CFLAGS = ${AM_CFLAGS} libhadoopcephfs_la_CXXFLAGS = ${AM_CXXFLAGS} libhadoopcephfs_la_LDFLAGS = ${AM_LDFLAGS} -version-info 1:0:0 -export-symbols-regex 'hadoopcephfs_.*' @@ -435,7 +435,7 @@ UNITTEST_STATIC_LDADD = \ -lpthread unittest_encoding_SOURCES = test/encoding.cc -unittest_encoding_LDADD = libceph.la -lpthread -lm \ +unittest_encoding_LDADD = libcephfs.la -lpthread -lm \ ${UNITTEST_LDADD} unittest_encoding_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} \ -fno-strict-aliasing @@ -443,7 +443,7 @@ check_PROGRAMS += unittest_encoding unittest_base64_SOURCES = test/base64.cc unittest_base64_LDFLAGS = -pthread ${AM_LDFLAGS} -unittest_base64_LDADD = libceph.la -lm ${UNITTEST_LDADD} +unittest_base64_LDADD = libcephfs.la -lm ${UNITTEST_LDADD} unittest_base64_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} check_PROGRAMS += unittest_base64 @@ -459,7 +459,7 @@ unittest_gather_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} check_PROGRAMS += unittest_gather unittest_run_cmd_SOURCES = test/run_cmd.cc -unittest_run_cmd_LDADD = libceph.la ${UNITTEST_LDADD} +unittest_run_cmd_LDADD = libcephfs.la ${UNITTEST_LDADD} unittest_run_cmd_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} check_PROGRAMS += unittest_run_cmd @@ -469,7 +469,7 @@ unittest_signals_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} check_PROGRAMS += unittest_signals unittest_simple_spin_SOURCES = test/simple_spin.cc -unittest_simple_spin_LDADD = libceph.la ${UNITTEST_LDADD} +unittest_simple_spin_LDADD = libcephfs.la ${UNITTEST_LDADD} unittest_simple_spin_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} check_PROGRAMS += unittest_simple_spin @@ -550,11 +550,11 @@ unittest_formatter_LDADD = ${UNITTEST_LDADD} $(LIBGLOBAL_LDA) unittest_formatter_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} check_PROGRAMS += unittest_formatter -unittest_libceph_config_SOURCES = test/libceph_config.cc -unittest_libceph_config_LDFLAGS = -pthread ${AM_LDFLAGS} -unittest_libceph_config_LDADD = libceph.la ${UNITTEST_LDADD} -unittest_libceph_config_CXXFLAGS = ${CRYPTO_CFLAGS} ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} -check_PROGRAMS += unittest_libceph_config +unittest_libcephfs_config_SOURCES = test/libcephfs_config.cc +unittest_libcephfs_config_LDFLAGS = -pthread ${AM_LDFLAGS} +unittest_libcephfs_config_LDADD = libcephfs.la ${UNITTEST_LDADD} +unittest_libcephfs_config_CXXFLAGS = ${CRYPTO_CFLAGS} ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} +check_PROGRAMS += unittest_libcephfs_config unittest_librados_config_SOURCES = test/librados_config.cc unittest_librados_config_LDFLAGS = -pthread ${AM_LDFLAGS} @@ -725,8 +725,8 @@ bash_completion_DATA = $(srcdir)/bash_completion/ceph \ $(srcdir)/bash_completion/rbd \ $(srcdir)/bash_completion/radosgw_admin -libceph_includedir = $(includedir)/ceph -libceph_include_DATA = $(srcdir)/include/ceph/libceph.h +libcephfs_includedir = $(includedir)/cephfs +libcephfs_include_DATA = $(srcdir)/include/cephfs/libcephfs.h librbd_includedir = $(includedir)/rbd librbd_include_DATA = \ @@ -1086,7 +1086,7 @@ noinst_HEADERS = \ include/blobhash.h\ include/buffer.h\ include/byteorder.h\ - include/ceph/libceph.h\ + include/cephfs/libcephfs.h\ include/ceph_frag.h\ include/ceph_fs.h\ include/ceph_hash.h\ diff --git a/src/client/hadoop/CephFSInterface.cc b/src/client/hadoop/CephFSInterface.cc index af7f718d1bb8..1a8beafde650 100644 --- a/src/client/hadoop/CephFSInterface.cc +++ b/src/client/hadoop/CephFSInterface.cc @@ -1,6 +1,6 @@ // -*- mode:c++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- #include "CephFSInterface.h" -#include "include/ceph/libceph.h" +#include "include/cephfs/libcephfs.h" #include "common/ceph_argparse.h" #include "common/config.h" #include "msg/SimpleMessenger.h" diff --git a/src/client/hadoop/HADOOP-ceph.patch b/src/client/hadoop/HADOOP-ceph.patch index 1f3c7a3a919c..388916a7faa3 100644 --- a/src/client/hadoop/HADOOP-ceph.patch +++ b/src/client/hadoop/HADOOP-ceph.patch @@ -87,7 +87,7 @@ Index: src/java/org/apache/hadoop/fs/ceph/CephTalker.java + public CephTalker(Configuration conf, Log log) { + super(conf, log); + System.load(conf.get("fs.ceph.libDir")+"/libhadoopcephfs.so"); -+ System.load(conf.get("fs.ceph.libDir")+"/libceph.so"); ++ System.load(conf.get("fs.ceph.libDir")+"/libcephfs.so"); + } + protected native boolean ceph_initializeClient(String arguments, int block_size); + protected native String ceph_getcwd(); @@ -173,9 +173,9 @@ Index: src/java/org/apache/hadoop/fs/ceph/CephFileSystem.java + * Configuration of the CephFileSystem is handled via a few Hadoop + * Configuration properties:
+ * fs.ceph.monAddr -- the ip address/port of the monitor to connect to.
-+ * fs.ceph.libDir -- the directory that libceph and libhadoopceph are ++ * fs.ceph.libDir -- the directory that libcephfs and libhadoopceph are + * located in. This assumes Hadoop is being run on a linux-style machine -+ * with names like libceph.so. ++ * with names like libcephfs.so. + * fs.ceph.commandLine -- if you prefer you can fill in this property + * just as you would when starting Ceph up from the command line. Specific + * properties override any configuration specified here. @@ -2236,7 +2236,7 @@ Index: src/java/org/apache/hadoop/fs/ceph/package.html +<property> + <name>fs.ceph.libDir</name> + <value>/usr/local/lib</value> -+ <description>The folder holding libceph and libhadoopceph</description> ++ <description>The folder holding libcephfs and libhadoopceph</description> + </property> + +
  • There are also a number of optional Ceph configuration options. diff --git a/src/client/hadoop/ceph/CephFileSystem.java b/src/client/hadoop/ceph/CephFileSystem.java index d081558d1d16..e57442e889ac 100644 --- a/src/client/hadoop/ceph/CephFileSystem.java +++ b/src/client/hadoop/ceph/CephFileSystem.java @@ -52,9 +52,9 @@ import org.apache.hadoop.fs.CreateFlag; * Configuration of the CephFileSystem is handled via a few Hadoop * Configuration properties:
    * fs.ceph.monAddr -- the ip address/port of the monitor to connect to.
    - * fs.ceph.libDir -- the directory that libceph and libhadoopceph are + * fs.ceph.libDir -- the directory that libcephfs and libhadoopceph are * located in. This assumes Hadoop is being run on a linux-style machine - * with names like libceph.so. + * with names like libcephfs.so. * fs.ceph.commandLine -- if you prefer you can fill in this property * just as you would when starting Ceph up from the command line. Specific * properties override any configuration specified here. diff --git a/src/client/hadoop/ceph/CephTalker.java b/src/client/hadoop/ceph/CephTalker.java index 4bda160d19f8..8b52441b60eb 100644 --- a/src/client/hadoop/ceph/CephTalker.java +++ b/src/client/hadoop/ceph/CephTalker.java @@ -34,7 +34,7 @@ class CephTalker extends CephFS { public CephTalker(Configuration conf, Log log) { super(conf, log); System.load(conf.get("fs.ceph.libDir") + "/libhadoopcephfs.so"); - System.load(conf.get("fs.ceph.libDir") + "/libceph.so"); + System.load(conf.get("fs.ceph.libDir") + "/libcephfs.so"); cluster = 0; } diff --git a/src/client/hadoop/ceph/package.html b/src/client/hadoop/ceph/package.html index 058a3ec83f60..8167b1dde920 100644 --- a/src/client/hadoop/ceph/package.html +++ b/src/client/hadoop/ceph/package.html @@ -50,7 +50,7 @@ documentation. <property> <name>fs.ceph.libDir</name> <value>/usr/local/lib</value> - <description>The folder holding libceph and libhadoopceph</description> + <description>The folder holding libcephfs and libhadoopceph</description> </property>
  • There are also a number of optional Ceph configuration options. @@ -98,4 +98,4 @@ By default, Ceph performs writes across the network rather than locally. To forc up an hdfs instance. Just start whatever systems you need and they will automatically make use of the Ceph filesystem once configured as above.
  • - \ No newline at end of file + diff --git a/src/client/hypertable/CephBroker.cc b/src/client/hypertable/CephBroker.cc index 9d610dfb3e39..96fd4830ec21 100644 --- a/src/client/hypertable/CephBroker.cc +++ b/src/client/hypertable/CephBroker.cc @@ -29,7 +29,7 @@ #include "Common/Filesystem.h" #include "Common/System.h" -#include +#include #include #include #include diff --git a/src/client/testceph.cc b/src/client/testceph.cc index 7601b7cef6fb..5e95e902727b 100644 --- a/src/client/testceph.cc +++ b/src/client/testceph.cc @@ -13,7 +13,7 @@ */ #include "common/errno.h" -#include "include/ceph/libceph.h" +#include "include/cephfs/libcephfs.h" #include #include diff --git a/src/common/config.h b/src/common/config.h index 08a6c6b31f58..f0f6c3feb99b 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -45,7 +45,7 @@ extern const char *CEPH_CONF_FILE_DEFAULT; /** This class represents the current Ceph configuration. * * For Ceph daemons, this is the daemon configuration. Log levels, caching - * settings, btrfs settings, and so forth can all be found here. For libceph + * settings, btrfs settings, and so forth can all be found here. For libcephfs * and librados users, this is the configuration associated with their context. * * For information about how this class is loaded from a configuration file, diff --git a/src/include/ceph/libceph.h b/src/include/ceph/libceph.h deleted file mode 100644 index f8dbe7986fbe..000000000000 --- a/src/include/ceph/libceph.h +++ /dev/null @@ -1,169 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2009-2011 New Dream Network - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -#ifndef CEPH_LIB_H -#define CEPH_LIB_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __USE_FILE_OFFSET64 -# error libceph: must define __USE_FILE_OFFSET64 or readdir results will be corrupted -#endif - -struct ceph_mount_info; -struct ceph_dir_result; -struct CephContext; - -const char *ceph_version(int *major, int *minor, int *patch); - -/* initialization */ -int ceph_create(struct ceph_mount_info **cmount, const char * const id); - -/* initialization with an existing configuration */ -int ceph_create_with_context(struct ceph_mount_info **cmount, struct CephContext *conf); - -/* Activate the mount */ -int ceph_mount(struct ceph_mount_info *cmount, const char *root); - -/* Destroy the ceph mount instance */ -void ceph_shutdown(struct ceph_mount_info *cmount); - -/* Config - * - * Functions for manipulating the Ceph configuration at runtime. - */ -int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path_list); - -int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc, const char **argv); - -/* Sets a configuration value from a string. - * Returns 0 on success, error code otherwise. */ -int ceph_conf_set(struct ceph_mount_info *cmount, const char *option, const char *value); - -/* Returns a configuration value as a string. - * If len is positive, that is the maximum number of bytes we'll write into the - * buffer. If len == -1, we'll call malloc() and set *buf. - * Returns 0 on success, error code otherwise. Returns ENAMETOOLONG if the - * buffer is too short. */ -int ceph_conf_get(struct ceph_mount_info *cmount, const char *option, char *buf, size_t len); - -int ceph_statfs(struct ceph_mount_info *cmount, const char *path, struct statvfs *stbuf); - -/* Get the current working directory. - * - * The pointer you get back from this function will continue to be valid until - * the *next* call you make to ceph_getcwd, at which point it will be invalidated. - */ -const char* ceph_getcwd(struct ceph_mount_info *cmount); - -int ceph_chdir(struct ceph_mount_info *cmount, const char *s); - -int ceph_opendir(struct ceph_mount_info *cmount, const char *name, struct ceph_dir_result **dirpp); -int ceph_closedir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp); -struct dirent * ceph_readdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp); -int ceph_readdir_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de); -int ceph_readdirplus_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de, - struct stat *st, int *stmask); -int ceph_getdents(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, char *name, int buflen); -int ceph_getdnames(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, char *name, int buflen); -void ceph_rewinddir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp); -loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp); -void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, loff_t offset); - -int ceph_link(struct ceph_mount_info *cmount, const char *existing, const char *newname); -int ceph_unlink(struct ceph_mount_info *cmount, const char *path); -int ceph_rename(struct ceph_mount_info *cmount, const char *from, const char *to); - -/* dirs */ -int ceph_mkdir(struct ceph_mount_info *cmount, const char *path, mode_t mode); -int ceph_mkdirs(struct ceph_mount_info *cmount, const char *path, mode_t mode); -int ceph_rmdir(struct ceph_mount_info *cmount, const char *path); - -/* symlinks */ -int ceph_readlink(struct ceph_mount_info *cmount, const char *path, char *buf, loff_t size); -int ceph_symlink(struct ceph_mount_info *cmount, const char *existing, const char *newname); - -/* inode stuff */ -int ceph_lstat(struct ceph_mount_info *cmount, const char *path, struct stat *stbuf); - -int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, struct stat *attr, int mask); -int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode); -int ceph_chown(struct ceph_mount_info *cmount, const char *path, uid_t uid, gid_t gid); -int ceph_utime(struct ceph_mount_info *cmount, const char *path, struct utimbuf *buf); -int ceph_truncate(struct ceph_mount_info *cmount, const char *path, loff_t size); - -/* file ops */ -int ceph_mknod(struct ceph_mount_info *cmount, const char *path, mode_t mode, dev_t rdev); -int ceph_open(struct ceph_mount_info *cmount, const char *path, int flags, mode_t mode); -int ceph_close(struct ceph_mount_info *cmount, int fd); -loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd, loff_t offset, int whence); -int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, loff_t size, loff_t offset); -int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf, loff_t size, - loff_t offset); -int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, loff_t size); -int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataonly); -int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf); - -int ceph_sync_fs(struct ceph_mount_info *cmount); - -/* xattr support */ -int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name, - void *value, size_t size); -int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, - void *value, size_t size); -int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size); -int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size); -int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name); -int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name); -int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, - const void *value, size_t size, int flags); -int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, - const void *value, size_t size, int flags); - - - -/* expose file layout */ -int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh); -int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh); -int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh); -int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fd, - loff_t offset, char *buf, int buflen); - -/* set default layout for new files */ -int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount, int stripe); -int ceph_set_default_file_stripe_count(struct ceph_mount_info *cmount, int count); -int ceph_set_default_object_size(struct ceph_mount_info *cmount, int size); -int ceph_set_default_preferred_pg(struct ceph_mount_info *cmount, int osd); -int ceph_set_default_file_replication(struct ceph_mount_info *cmount, int replication); - -/* read from local replicas when possible */ -int ceph_localize_reads(struct ceph_mount_info *cmount, int val); - -/* return osd on local node, if any */ -int ceph_get_local_osd(struct ceph_mount_info *cmount); - -/* Get the CephContext of this mount */ -struct CephContext *ceph_get_mount_context(struct ceph_mount_info *cmount); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h new file mode 100644 index 000000000000..f8dbe7986fbe --- /dev/null +++ b/src/include/cephfs/libcephfs.h @@ -0,0 +1,169 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2009-2011 New Dream Network + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_LIB_H +#define CEPH_LIB_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __USE_FILE_OFFSET64 +# error libceph: must define __USE_FILE_OFFSET64 or readdir results will be corrupted +#endif + +struct ceph_mount_info; +struct ceph_dir_result; +struct CephContext; + +const char *ceph_version(int *major, int *minor, int *patch); + +/* initialization */ +int ceph_create(struct ceph_mount_info **cmount, const char * const id); + +/* initialization with an existing configuration */ +int ceph_create_with_context(struct ceph_mount_info **cmount, struct CephContext *conf); + +/* Activate the mount */ +int ceph_mount(struct ceph_mount_info *cmount, const char *root); + +/* Destroy the ceph mount instance */ +void ceph_shutdown(struct ceph_mount_info *cmount); + +/* Config + * + * Functions for manipulating the Ceph configuration at runtime. + */ +int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path_list); + +int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc, const char **argv); + +/* Sets a configuration value from a string. + * Returns 0 on success, error code otherwise. */ +int ceph_conf_set(struct ceph_mount_info *cmount, const char *option, const char *value); + +/* Returns a configuration value as a string. + * If len is positive, that is the maximum number of bytes we'll write into the + * buffer. If len == -1, we'll call malloc() and set *buf. + * Returns 0 on success, error code otherwise. Returns ENAMETOOLONG if the + * buffer is too short. */ +int ceph_conf_get(struct ceph_mount_info *cmount, const char *option, char *buf, size_t len); + +int ceph_statfs(struct ceph_mount_info *cmount, const char *path, struct statvfs *stbuf); + +/* Get the current working directory. + * + * The pointer you get back from this function will continue to be valid until + * the *next* call you make to ceph_getcwd, at which point it will be invalidated. + */ +const char* ceph_getcwd(struct ceph_mount_info *cmount); + +int ceph_chdir(struct ceph_mount_info *cmount, const char *s); + +int ceph_opendir(struct ceph_mount_info *cmount, const char *name, struct ceph_dir_result **dirpp); +int ceph_closedir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp); +struct dirent * ceph_readdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp); +int ceph_readdir_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de); +int ceph_readdirplus_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de, + struct stat *st, int *stmask); +int ceph_getdents(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, char *name, int buflen); +int ceph_getdnames(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, char *name, int buflen); +void ceph_rewinddir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp); +loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp); +void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, loff_t offset); + +int ceph_link(struct ceph_mount_info *cmount, const char *existing, const char *newname); +int ceph_unlink(struct ceph_mount_info *cmount, const char *path); +int ceph_rename(struct ceph_mount_info *cmount, const char *from, const char *to); + +/* dirs */ +int ceph_mkdir(struct ceph_mount_info *cmount, const char *path, mode_t mode); +int ceph_mkdirs(struct ceph_mount_info *cmount, const char *path, mode_t mode); +int ceph_rmdir(struct ceph_mount_info *cmount, const char *path); + +/* symlinks */ +int ceph_readlink(struct ceph_mount_info *cmount, const char *path, char *buf, loff_t size); +int ceph_symlink(struct ceph_mount_info *cmount, const char *existing, const char *newname); + +/* inode stuff */ +int ceph_lstat(struct ceph_mount_info *cmount, const char *path, struct stat *stbuf); + +int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, struct stat *attr, int mask); +int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode); +int ceph_chown(struct ceph_mount_info *cmount, const char *path, uid_t uid, gid_t gid); +int ceph_utime(struct ceph_mount_info *cmount, const char *path, struct utimbuf *buf); +int ceph_truncate(struct ceph_mount_info *cmount, const char *path, loff_t size); + +/* file ops */ +int ceph_mknod(struct ceph_mount_info *cmount, const char *path, mode_t mode, dev_t rdev); +int ceph_open(struct ceph_mount_info *cmount, const char *path, int flags, mode_t mode); +int ceph_close(struct ceph_mount_info *cmount, int fd); +loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd, loff_t offset, int whence); +int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, loff_t size, loff_t offset); +int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf, loff_t size, + loff_t offset); +int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, loff_t size); +int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataonly); +int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf); + +int ceph_sync_fs(struct ceph_mount_info *cmount); + +/* xattr support */ +int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name, + void *value, size_t size); +int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, + void *value, size_t size); +int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size); +int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size); +int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name); +int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name); +int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, + const void *value, size_t size, int flags); +int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, + const void *value, size_t size, int flags); + + + +/* expose file layout */ +int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh); +int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh); +int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh); +int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fd, + loff_t offset, char *buf, int buflen); + +/* set default layout for new files */ +int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount, int stripe); +int ceph_set_default_file_stripe_count(struct ceph_mount_info *cmount, int count); +int ceph_set_default_object_size(struct ceph_mount_info *cmount, int size); +int ceph_set_default_preferred_pg(struct ceph_mount_info *cmount, int osd); +int ceph_set_default_file_replication(struct ceph_mount_info *cmount, int replication); + +/* read from local replicas when possible */ +int ceph_localize_reads(struct ceph_mount_info *cmount, int val); + +/* return osd on local node, if any */ +int ceph_get_local_osd(struct ceph_mount_info *cmount); + +/* Get the CephContext of this mount */ +struct CephContext *ceph_get_mount_context(struct ceph_mount_info *cmount); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/libceph.cc b/src/libceph.cc deleted file mode 100644 index 54f07ed6a1ab..000000000000 --- a/src/libceph.cc +++ /dev/null @@ -1,616 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2009-2011 New Dream Network - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -#include "client/Client.h" -#include "include/ceph/libceph.h" -#include "common/Mutex.h" -#include "common/ceph_argparse.h" -#include "common/common_init.h" -#include "common/config.h" -#include "common/version.h" -#include "mon/MonClient.h" -#include "include/str_list.h" -#include "messages/MMonMap.h" -#include "msg/SimpleMessenger.h" - -#include -#include -#include -#include - -class ceph_mount_info -{ -public: - ceph_mount_info(uint64_t msgr_nonce_, CephContext *cct_) - : msgr_nonce(msgr_nonce_), - mounted(false), - client(NULL), - monclient(NULL), - messenger(NULL), - cct(cct_) - { - } - - ~ceph_mount_info() - { - try { - shutdown(); - if (cct) { - common_destroy_context(cct); - cct = NULL; - } - } - catch (const std::exception& e) { - // we shouldn't get here, but if we do, we want to know about it. - lderr(cct) << "ceph_mount_info::~ceph_mount_info: caught exception: " - << e.what() << dendl; - } - catch (...) { - // ignore - } - } - - int mount(const std::string &mount_root) - { - if (mounted) - return -EDOM; - - common_init_finish(cct); - - //monmap - monclient = new MonClient(cct); - if (monclient->build_initial_monmap() < 0) { - shutdown(); - return -1000; - } - - //network connection - messenger = new SimpleMessenger(cct); - if (!messenger->register_entity(entity_name_t::CLIENT())) { - messenger->destroy(); - messenger = NULL; - shutdown(); - return -1001; - } - - //at last the client - client = new Client(messenger, monclient); - if (!client) { - shutdown(); - return -1002; - } - - if (messenger->start_with_nonce(msgr_nonce) != 0) { - shutdown(); - return -1003; - } - - client->init(); - - int ret = client->mount(mount_root); - if (ret) { - shutdown(); - return ret; - } - - mounted = true; - return 0; - } - - void shutdown() - { - if (mounted) { - client->unmount(); - mounted = false; - } - if (client) { - client->shutdown(); - delete client; - client = NULL; - } - if (messenger) { - messenger->wait(); - messenger->destroy(); - messenger = NULL; - } - if (monclient) { - delete monclient; - monclient = NULL; - } - } - - int conf_read_file(const char *path_list) - { - std::deque parse_errors; - int ret = cct->_conf->parse_config_files(path_list, &parse_errors, 0); - if (ret) - return ret; - cct->_conf->apply_changes(NULL); - complain_about_parse_errors(cct, &parse_errors); - return 0; - } - - int conf_parse_argv(int argc, const char **argv) - { - int ret; - vector args; - argv_to_vec(argc, argv, args); - ret = cct->_conf->parse_argv(args); - if (ret) - return ret; - cct->_conf->apply_changes(NULL); - return 0; - } - - int conf_set(const char *option, const char *value) - { - int ret = cct->_conf->set_val(option, value); - if (ret) - return ret; - cct->_conf->apply_changes(NULL); - return 0; - } - - int conf_get(const char *option, char *buf, size_t len) - { - char *tmp = buf; - return cct->_conf->get_val(option, &tmp, len); - } - - Client *get_client() - { - return client; - } - - const char *get_cwd() - { - client->getcwd(cwd); - return cwd.c_str(); - } - - CephContext *get_ceph_context() const { - return cct; - } - -private: - uint64_t msgr_nonce; - bool mounted; - Client *client; - MonClient *monclient; - SimpleMessenger *messenger; - CephContext *cct; - std::string cwd; -}; - -extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch) -{ - int major, minor, patch; - const char *v = ceph_version_to_str(); - - int n = sscanf(v, "%d.%d.%d", &major, &minor, &patch); - if (pmajor) - *pmajor = (n >= 1) ? major : 0; - if (pminor) - *pminor = (n >= 2) ? minor : 0; - if (ppatch) - *ppatch = (n >= 3) ? patch : 0; - return VERSION; -} - -extern "C" int ceph_create_with_context(struct ceph_mount_info **cmount, CephContext *cct) -{ - // Function-static variables are thread-safe in gcc and in the forthcoming C++ standard - static int nonce_seed = 0; - - uint64_t nonce = (uint64_t)++nonce_seed * 1000000ull + (uint64_t)getpid(); - *cmount = new struct ceph_mount_info(nonce, cct); - return 0; -} - -extern "C" int ceph_create(struct ceph_mount_info **cmount, const char * const id) -{ - CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT); - if (id) { - iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id); - } - - CephContext *cct = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0); - cct->_conf->parse_env(); // environment variables coverride - cct->_conf->apply_changes(NULL); - return ceph_create_with_context(cmount, cct); -} - -extern "C" void ceph_shutdown(struct ceph_mount_info *cmount) -{ - cmount->shutdown(); -} - -extern "C" int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path) -{ - return cmount->conf_read_file(path); -} - -extern "C" int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc, - const char **argv) -{ - return cmount->conf_parse_argv(argc, argv); -} - -extern "C" int ceph_conf_set(struct ceph_mount_info *cmount, const char *option, - const char *value) -{ - return cmount->conf_set(option, value); -} - -extern "C" int ceph_conf_get(struct ceph_mount_info *cmount, const char *option, - char *buf, size_t len) -{ - return cmount->conf_get(option, buf, len); -} - -extern "C" int ceph_mount(struct ceph_mount_info *cmount, const char *root) -{ - std::string mount_root; - if (root) - mount_root = root; - return cmount->mount(mount_root); -} - -extern "C" int ceph_statfs(struct ceph_mount_info *cmount, const char *path, - struct statvfs *stbuf) -{ - return cmount->get_client()->statfs(path, stbuf); -} - -extern "C" int ceph_get_local_osd(struct ceph_mount_info *cmount) -{ - return cmount->get_client()->get_local_osd(); -} - -extern "C" const char* ceph_getcwd(struct ceph_mount_info *cmount) -{ - return cmount->get_cwd(); -} - -extern "C" int ceph_chdir (struct ceph_mount_info *cmount, const char *s) -{ - return cmount->get_client()->chdir(s); -} - -extern "C" int ceph_opendir(struct ceph_mount_info *cmount, - const char *name, struct ceph_dir_result **dirpp) -{ - return cmount->get_client()->opendir(name, (dir_result_t **)dirpp); -} - -extern "C" int ceph_closedir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp) -{ - return cmount->get_client()->closedir((dir_result_t*)dirp); -} - -extern "C" struct dirent * ceph_readdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp) -{ - return cmount->get_client()->readdir((dir_result_t*)dirp); -} - -extern "C" int ceph_readdir_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de) -{ - return cmount->get_client()->readdir_r((dir_result_t*)dirp, de); -} - -extern "C" int ceph_readdirplus_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, - struct dirent *de, struct stat *st, int *stmask) -{ - return cmount->get_client()->readdirplus_r((dir_result_t*)dirp, de, st, stmask); -} - -extern "C" int ceph_getdents(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, - char *buf, int buflen) -{ - return cmount->get_client()->getdents((dir_result_t*)dirp, buf, buflen); -} - -extern "C" int ceph_getdnames(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, - char *buf, int buflen) -{ - return cmount->get_client()->getdnames((dir_result_t*)dirp, buf, buflen); -} - -extern "C" void ceph_rewinddir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp) -{ - cmount->get_client()->rewinddir((dir_result_t*)dirp); -} - -extern "C" loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp) -{ - return cmount->get_client()->telldir((dir_result_t*)dirp); -} - -extern "C" void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, loff_t offset) -{ - cmount->get_client()->seekdir((dir_result_t*)dirp, offset); -} - -extern "C" int ceph_link (struct ceph_mount_info *cmount, const char *existing, - const char *newname) -{ - return cmount->get_client()->link(existing, newname); -} - -extern "C" int ceph_unlink(struct ceph_mount_info *cmount, const char *path) -{ - return cmount->get_client()->unlink(path); -} - -extern "C" int ceph_rename(struct ceph_mount_info *cmount, const char *from, - const char *to) -{ - return cmount->get_client()->rename(from, to); -} - -// dirs -extern "C" int ceph_mkdir(struct ceph_mount_info *cmount, const char *path, mode_t mode) -{ - return cmount->get_client()->mkdir(path, mode); -} - -extern "C" int ceph_mkdirs(struct ceph_mount_info *cmount, const char *path, mode_t mode) -{ - return cmount->get_client()->mkdirs(path, mode); -} - -extern "C" int ceph_rmdir(struct ceph_mount_info *cmount, const char *path) -{ - return cmount->get_client()->rmdir(path); -} - -// symlinks -extern "C" int ceph_readlink(struct ceph_mount_info *cmount, const char *path, - char *buf, loff_t size) -{ - return cmount->get_client()->readlink(path, buf, size); -} - -extern "C" int ceph_symlink(struct ceph_mount_info *cmount, const char *existing, - const char *newname) -{ - return cmount->get_client()->symlink(existing, newname); -} - -// inode stuff -extern "C" int ceph_lstat(struct ceph_mount_info *cmount, const char *path, - struct stat *stbuf) -{ - return cmount->get_client()->lstat(path, stbuf); -} - -extern "C" int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, - struct stat *attr, int mask) -{ - return cmount->get_client()->setattr(relpath, attr, mask); -} - -// *xattr() calls supporting samba/vfs -extern "C" int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size) -{ - return cmount->get_client()->getxattr(path, name, value, size); -} - -extern "C" int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size) -{ - return cmount->get_client()->lgetxattr(path, name, value, size); -} - -extern "C" int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size) -{ - return cmount->get_client()->listxattr(path, list, size); -} - -extern "C" int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size) -{ - return cmount->get_client()->llistxattr(path, list, size); -} - -extern "C" int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name) -{ - return cmount->get_client()->removexattr(path, name); -} - -extern "C" int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name) -{ - return cmount->get_client()->lremovexattr(path, name); -} - -extern "C" int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags) -{ - return cmount->get_client()->setxattr(path, name, value, size, flags); -} - -extern "C" int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags) -{ - return cmount->get_client()->lsetxattr(path, name, value, size, flags); -} -/* end xattr support */ - -extern "C" int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode) -{ - return cmount->get_client()->chmod(path, mode); -} -extern "C" int ceph_chown(struct ceph_mount_info *cmount, const char *path, - uid_t uid, gid_t gid) -{ - return cmount->get_client()->chown(path, uid, gid); -} - -extern "C" int ceph_utime(struct ceph_mount_info *cmount, const char *path, - struct utimbuf *buf) -{ - return cmount->get_client()->utime(path, buf); -} - -extern "C" int ceph_truncate(struct ceph_mount_info *cmount, const char *path, - loff_t size) -{ - return cmount->get_client()->truncate(path, size); -} - -// file ops -extern "C" int ceph_mknod(struct ceph_mount_info *cmount, const char *path, - mode_t mode, dev_t rdev) -{ - return cmount->get_client()->mknod(path, mode, rdev); -} - -extern "C" int ceph_open(struct ceph_mount_info *cmount, const char *path, - int flags, mode_t mode) -{ - return cmount->get_client()->open(path, flags, mode); -} - -extern "C" int ceph_close(struct ceph_mount_info *cmount, int fd) -{ - return cmount->get_client()->close(fd); -} - -extern "C" loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd, - loff_t offset, int whence) -{ - return cmount->get_client()->lseek(fd, offset, whence); -} - -extern "C" int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, - loff_t size, loff_t offset) -{ - return cmount->get_client()->read(fd, buf, size, offset); -} - -extern "C" int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf, - loff_t size, loff_t offset) -{ - return cmount->get_client()->write(fd, buf, size, offset); -} - -extern "C" int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, loff_t size) -{ - return cmount->get_client()->ftruncate(fd, size); -} - -extern "C" int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataonly) -{ - return cmount->get_client()->fsync(fd, syncdataonly); -} - -extern "C" int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf) -{ - return cmount->get_client()->fstat(fd, stbuf); -} - -extern "C" int ceph_sync_fs(struct ceph_mount_info *cmount) -{ - return cmount->get_client()->sync_fs(); -} - - -extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh) -{ - struct ceph_file_layout l; - int r = cmount->get_client()->describe_layout(fh, &l); - if (r < 0) - return r; - return l.fl_stripe_unit; -} - -extern "C" int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh) -{ - struct ceph_file_layout l; - int r = cmount->get_client()->describe_layout(fh, &l); - if (r < 0) - return r; - return l.fl_pg_pool; -} - -extern "C" int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh) -{ - struct ceph_file_layout l; - int r = cmount->get_client()->describe_layout(fh, &l); - if (r < 0) - return r; - int rep = cmount->get_client()->get_pool_replication(l.fl_pg_pool); - return rep; -} - -extern "C" int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount, - int stripe) -{ - cmount->get_client()->set_default_file_stripe_unit(stripe); - return 0; -} - -extern "C" int ceph_set_default_file_stripe_count(struct ceph_mount_info *cmount, - int count) -{ - cmount->get_client()->set_default_file_stripe_unit(count); - return 0; -} - -extern "C" int ceph_set_default_object_size(struct ceph_mount_info *cmount, int size) -{ - cmount->get_client()->set_default_object_size(size); - return 0; -} - -extern "C" int ceph_set_default_file_replication(struct ceph_mount_info *cmount, - int replication) -{ - cmount->get_client()->set_default_file_replication(replication); - return 0; -} - -extern "C" int ceph_set_default_preferred_pg(struct ceph_mount_info *cmount, int osd) -{ - cmount->get_client()->set_default_preferred_pg(osd); - return 0; -} - -extern "C" int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fh, - loff_t offset, char *buf, int buflen) -{ - string address; - int r = cmount->get_client()->get_file_stripe_address(fh, offset, address); - if (r < 0) - return r; - int len = address.size()+1; - if (len > buflen) { - if (buflen == 0) - return len; - return -ERANGE; - } - len = address.copy(buf, len, 0); - buf[len] = '\0'; // write a null char to terminate c-style string - return 0; -} - -extern "C" int ceph_localize_reads(struct ceph_mount_info *cmount, int val) -{ - if (!val) - cmount->get_client()->clear_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS); - else - cmount->get_client()->set_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS); - return 0; -} - -extern "C" CephContext *ceph_get_mount_context(struct ceph_mount_info *cmount) -{ - return cmount->get_ceph_context(); -} diff --git a/src/libcephfs.cc b/src/libcephfs.cc new file mode 100644 index 000000000000..153348cfb51c --- /dev/null +++ b/src/libcephfs.cc @@ -0,0 +1,616 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2009-2011 New Dream Network + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#include "client/Client.h" +#include "include/cephfs/libcephfs.h" +#include "common/Mutex.h" +#include "common/ceph_argparse.h" +#include "common/common_init.h" +#include "common/config.h" +#include "common/version.h" +#include "mon/MonClient.h" +#include "include/str_list.h" +#include "messages/MMonMap.h" +#include "msg/SimpleMessenger.h" + +#include +#include +#include +#include + +class ceph_mount_info +{ +public: + ceph_mount_info(uint64_t msgr_nonce_, CephContext *cct_) + : msgr_nonce(msgr_nonce_), + mounted(false), + client(NULL), + monclient(NULL), + messenger(NULL), + cct(cct_) + { + } + + ~ceph_mount_info() + { + try { + shutdown(); + if (cct) { + common_destroy_context(cct); + cct = NULL; + } + } + catch (const std::exception& e) { + // we shouldn't get here, but if we do, we want to know about it. + lderr(cct) << "ceph_mount_info::~ceph_mount_info: caught exception: " + << e.what() << dendl; + } + catch (...) { + // ignore + } + } + + int mount(const std::string &mount_root) + { + if (mounted) + return -EDOM; + + common_init_finish(cct); + + //monmap + monclient = new MonClient(cct); + if (monclient->build_initial_monmap() < 0) { + shutdown(); + return -1000; + } + + //network connection + messenger = new SimpleMessenger(cct); + if (!messenger->register_entity(entity_name_t::CLIENT())) { + messenger->destroy(); + messenger = NULL; + shutdown(); + return -1001; + } + + //at last the client + client = new Client(messenger, monclient); + if (!client) { + shutdown(); + return -1002; + } + + if (messenger->start_with_nonce(msgr_nonce) != 0) { + shutdown(); + return -1003; + } + + client->init(); + + int ret = client->mount(mount_root); + if (ret) { + shutdown(); + return ret; + } + + mounted = true; + return 0; + } + + void shutdown() + { + if (mounted) { + client->unmount(); + mounted = false; + } + if (client) { + client->shutdown(); + delete client; + client = NULL; + } + if (messenger) { + messenger->wait(); + messenger->destroy(); + messenger = NULL; + } + if (monclient) { + delete monclient; + monclient = NULL; + } + } + + int conf_read_file(const char *path_list) + { + std::deque parse_errors; + int ret = cct->_conf->parse_config_files(path_list, &parse_errors, 0); + if (ret) + return ret; + cct->_conf->apply_changes(NULL); + complain_about_parse_errors(cct, &parse_errors); + return 0; + } + + int conf_parse_argv(int argc, const char **argv) + { + int ret; + vector args; + argv_to_vec(argc, argv, args); + ret = cct->_conf->parse_argv(args); + if (ret) + return ret; + cct->_conf->apply_changes(NULL); + return 0; + } + + int conf_set(const char *option, const char *value) + { + int ret = cct->_conf->set_val(option, value); + if (ret) + return ret; + cct->_conf->apply_changes(NULL); + return 0; + } + + int conf_get(const char *option, char *buf, size_t len) + { + char *tmp = buf; + return cct->_conf->get_val(option, &tmp, len); + } + + Client *get_client() + { + return client; + } + + const char *get_cwd() + { + client->getcwd(cwd); + return cwd.c_str(); + } + + CephContext *get_ceph_context() const { + return cct; + } + +private: + uint64_t msgr_nonce; + bool mounted; + Client *client; + MonClient *monclient; + SimpleMessenger *messenger; + CephContext *cct; + std::string cwd; +}; + +extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch) +{ + int major, minor, patch; + const char *v = ceph_version_to_str(); + + int n = sscanf(v, "%d.%d.%d", &major, &minor, &patch); + if (pmajor) + *pmajor = (n >= 1) ? major : 0; + if (pminor) + *pminor = (n >= 2) ? minor : 0; + if (ppatch) + *ppatch = (n >= 3) ? patch : 0; + return VERSION; +} + +extern "C" int ceph_create_with_context(struct ceph_mount_info **cmount, CephContext *cct) +{ + // Function-static variables are thread-safe in gcc and in the forthcoming C++ standard + static int nonce_seed = 0; + + uint64_t nonce = (uint64_t)++nonce_seed * 1000000ull + (uint64_t)getpid(); + *cmount = new struct ceph_mount_info(nonce, cct); + return 0; +} + +extern "C" int ceph_create(struct ceph_mount_info **cmount, const char * const id) +{ + CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT); + if (id) { + iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id); + } + + CephContext *cct = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0); + cct->_conf->parse_env(); // environment variables coverride + cct->_conf->apply_changes(NULL); + return ceph_create_with_context(cmount, cct); +} + +extern "C" void ceph_shutdown(struct ceph_mount_info *cmount) +{ + cmount->shutdown(); +} + +extern "C" int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *path) +{ + return cmount->conf_read_file(path); +} + +extern "C" int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc, + const char **argv) +{ + return cmount->conf_parse_argv(argc, argv); +} + +extern "C" int ceph_conf_set(struct ceph_mount_info *cmount, const char *option, + const char *value) +{ + return cmount->conf_set(option, value); +} + +extern "C" int ceph_conf_get(struct ceph_mount_info *cmount, const char *option, + char *buf, size_t len) +{ + return cmount->conf_get(option, buf, len); +} + +extern "C" int ceph_mount(struct ceph_mount_info *cmount, const char *root) +{ + std::string mount_root; + if (root) + mount_root = root; + return cmount->mount(mount_root); +} + +extern "C" int ceph_statfs(struct ceph_mount_info *cmount, const char *path, + struct statvfs *stbuf) +{ + return cmount->get_client()->statfs(path, stbuf); +} + +extern "C" int ceph_get_local_osd(struct ceph_mount_info *cmount) +{ + return cmount->get_client()->get_local_osd(); +} + +extern "C" const char* ceph_getcwd(struct ceph_mount_info *cmount) +{ + return cmount->get_cwd(); +} + +extern "C" int ceph_chdir (struct ceph_mount_info *cmount, const char *s) +{ + return cmount->get_client()->chdir(s); +} + +extern "C" int ceph_opendir(struct ceph_mount_info *cmount, + const char *name, struct ceph_dir_result **dirpp) +{ + return cmount->get_client()->opendir(name, (dir_result_t **)dirpp); +} + +extern "C" int ceph_closedir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp) +{ + return cmount->get_client()->closedir((dir_result_t*)dirp); +} + +extern "C" struct dirent * ceph_readdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp) +{ + return cmount->get_client()->readdir((dir_result_t*)dirp); +} + +extern "C" int ceph_readdir_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, struct dirent *de) +{ + return cmount->get_client()->readdir_r((dir_result_t*)dirp, de); +} + +extern "C" int ceph_readdirplus_r(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, + struct dirent *de, struct stat *st, int *stmask) +{ + return cmount->get_client()->readdirplus_r((dir_result_t*)dirp, de, st, stmask); +} + +extern "C" int ceph_getdents(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, + char *buf, int buflen) +{ + return cmount->get_client()->getdents((dir_result_t*)dirp, buf, buflen); +} + +extern "C" int ceph_getdnames(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, + char *buf, int buflen) +{ + return cmount->get_client()->getdnames((dir_result_t*)dirp, buf, buflen); +} + +extern "C" void ceph_rewinddir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp) +{ + cmount->get_client()->rewinddir((dir_result_t*)dirp); +} + +extern "C" loff_t ceph_telldir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp) +{ + return cmount->get_client()->telldir((dir_result_t*)dirp); +} + +extern "C" void ceph_seekdir(struct ceph_mount_info *cmount, struct ceph_dir_result *dirp, loff_t offset) +{ + cmount->get_client()->seekdir((dir_result_t*)dirp, offset); +} + +extern "C" int ceph_link (struct ceph_mount_info *cmount, const char *existing, + const char *newname) +{ + return cmount->get_client()->link(existing, newname); +} + +extern "C" int ceph_unlink(struct ceph_mount_info *cmount, const char *path) +{ + return cmount->get_client()->unlink(path); +} + +extern "C" int ceph_rename(struct ceph_mount_info *cmount, const char *from, + const char *to) +{ + return cmount->get_client()->rename(from, to); +} + +// dirs +extern "C" int ceph_mkdir(struct ceph_mount_info *cmount, const char *path, mode_t mode) +{ + return cmount->get_client()->mkdir(path, mode); +} + +extern "C" int ceph_mkdirs(struct ceph_mount_info *cmount, const char *path, mode_t mode) +{ + return cmount->get_client()->mkdirs(path, mode); +} + +extern "C" int ceph_rmdir(struct ceph_mount_info *cmount, const char *path) +{ + return cmount->get_client()->rmdir(path); +} + +// symlinks +extern "C" int ceph_readlink(struct ceph_mount_info *cmount, const char *path, + char *buf, loff_t size) +{ + return cmount->get_client()->readlink(path, buf, size); +} + +extern "C" int ceph_symlink(struct ceph_mount_info *cmount, const char *existing, + const char *newname) +{ + return cmount->get_client()->symlink(existing, newname); +} + +// inode stuff +extern "C" int ceph_lstat(struct ceph_mount_info *cmount, const char *path, + struct stat *stbuf) +{ + return cmount->get_client()->lstat(path, stbuf); +} + +extern "C" int ceph_setattr(struct ceph_mount_info *cmount, const char *relpath, + struct stat *attr, int mask) +{ + return cmount->get_client()->setattr(relpath, attr, mask); +} + +// *xattr() calls supporting samba/vfs +extern "C" int ceph_getxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size) +{ + return cmount->get_client()->getxattr(path, name, value, size); +} + +extern "C" int ceph_lgetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, void *value, size_t size) +{ + return cmount->get_client()->lgetxattr(path, name, value, size); +} + +extern "C" int ceph_listxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size) +{ + return cmount->get_client()->listxattr(path, list, size); +} + +extern "C" int ceph_llistxattr(struct ceph_mount_info *cmount, const char *path, char *list, size_t size) +{ + return cmount->get_client()->llistxattr(path, list, size); +} + +extern "C" int ceph_removexattr(struct ceph_mount_info *cmount, const char *path, const char *name) +{ + return cmount->get_client()->removexattr(path, name); +} + +extern "C" int ceph_lremovexattr(struct ceph_mount_info *cmount, const char *path, const char *name) +{ + return cmount->get_client()->lremovexattr(path, name); +} + +extern "C" int ceph_setxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags) +{ + return cmount->get_client()->setxattr(path, name, value, size, flags); +} + +extern "C" int ceph_lsetxattr(struct ceph_mount_info *cmount, const char *path, const char *name, const void *value, size_t size, int flags) +{ + return cmount->get_client()->lsetxattr(path, name, value, size, flags); +} +/* end xattr support */ + +extern "C" int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode_t mode) +{ + return cmount->get_client()->chmod(path, mode); +} +extern "C" int ceph_chown(struct ceph_mount_info *cmount, const char *path, + uid_t uid, gid_t gid) +{ + return cmount->get_client()->chown(path, uid, gid); +} + +extern "C" int ceph_utime(struct ceph_mount_info *cmount, const char *path, + struct utimbuf *buf) +{ + return cmount->get_client()->utime(path, buf); +} + +extern "C" int ceph_truncate(struct ceph_mount_info *cmount, const char *path, + loff_t size) +{ + return cmount->get_client()->truncate(path, size); +} + +// file ops +extern "C" int ceph_mknod(struct ceph_mount_info *cmount, const char *path, + mode_t mode, dev_t rdev) +{ + return cmount->get_client()->mknod(path, mode, rdev); +} + +extern "C" int ceph_open(struct ceph_mount_info *cmount, const char *path, + int flags, mode_t mode) +{ + return cmount->get_client()->open(path, flags, mode); +} + +extern "C" int ceph_close(struct ceph_mount_info *cmount, int fd) +{ + return cmount->get_client()->close(fd); +} + +extern "C" loff_t ceph_lseek(struct ceph_mount_info *cmount, int fd, + loff_t offset, int whence) +{ + return cmount->get_client()->lseek(fd, offset, whence); +} + +extern "C" int ceph_read(struct ceph_mount_info *cmount, int fd, char *buf, + loff_t size, loff_t offset) +{ + return cmount->get_client()->read(fd, buf, size, offset); +} + +extern "C" int ceph_write(struct ceph_mount_info *cmount, int fd, const char *buf, + loff_t size, loff_t offset) +{ + return cmount->get_client()->write(fd, buf, size, offset); +} + +extern "C" int ceph_ftruncate(struct ceph_mount_info *cmount, int fd, loff_t size) +{ + return cmount->get_client()->ftruncate(fd, size); +} + +extern "C" int ceph_fsync(struct ceph_mount_info *cmount, int fd, int syncdataonly) +{ + return cmount->get_client()->fsync(fd, syncdataonly); +} + +extern "C" int ceph_fstat(struct ceph_mount_info *cmount, int fd, struct stat *stbuf) +{ + return cmount->get_client()->fstat(fd, stbuf); +} + +extern "C" int ceph_sync_fs(struct ceph_mount_info *cmount) +{ + return cmount->get_client()->sync_fs(); +} + + +extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh) +{ + struct ceph_file_layout l; + int r = cmount->get_client()->describe_layout(fh, &l); + if (r < 0) + return r; + return l.fl_stripe_unit; +} + +extern "C" int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh) +{ + struct ceph_file_layout l; + int r = cmount->get_client()->describe_layout(fh, &l); + if (r < 0) + return r; + return l.fl_pg_pool; +} + +extern "C" int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh) +{ + struct ceph_file_layout l; + int r = cmount->get_client()->describe_layout(fh, &l); + if (r < 0) + return r; + int rep = cmount->get_client()->get_pool_replication(l.fl_pg_pool); + return rep; +} + +extern "C" int ceph_set_default_file_stripe_unit(struct ceph_mount_info *cmount, + int stripe) +{ + cmount->get_client()->set_default_file_stripe_unit(stripe); + return 0; +} + +extern "C" int ceph_set_default_file_stripe_count(struct ceph_mount_info *cmount, + int count) +{ + cmount->get_client()->set_default_file_stripe_unit(count); + return 0; +} + +extern "C" int ceph_set_default_object_size(struct ceph_mount_info *cmount, int size) +{ + cmount->get_client()->set_default_object_size(size); + return 0; +} + +extern "C" int ceph_set_default_file_replication(struct ceph_mount_info *cmount, + int replication) +{ + cmount->get_client()->set_default_file_replication(replication); + return 0; +} + +extern "C" int ceph_set_default_preferred_pg(struct ceph_mount_info *cmount, int osd) +{ + cmount->get_client()->set_default_preferred_pg(osd); + return 0; +} + +extern "C" int ceph_get_file_stripe_address(struct ceph_mount_info *cmount, int fh, + loff_t offset, char *buf, int buflen) +{ + string address; + int r = cmount->get_client()->get_file_stripe_address(fh, offset, address); + if (r < 0) + return r; + int len = address.size()+1; + if (len > buflen) { + if (buflen == 0) + return len; + return -ERANGE; + } + len = address.copy(buf, len, 0); + buf[len] = '\0'; // write a null char to terminate c-style string + return 0; +} + +extern "C" int ceph_localize_reads(struct ceph_mount_info *cmount, int val) +{ + if (!val) + cmount->get_client()->clear_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS); + else + cmount->get_client()->set_filer_flags(CEPH_OSD_FLAG_LOCALIZE_READS); + return 0; +} + +extern "C" CephContext *ceph_get_mount_context(struct ceph_mount_info *cmount) +{ + return cmount->get_ceph_context(); +} diff --git a/src/test/daemon_config.cc b/src/test/daemon_config.cc index 0eae90af3e0a..6a09e0943910 100644 --- a/src/test/daemon_config.cc +++ b/src/test/daemon_config.cc @@ -14,7 +14,7 @@ #include "common/ceph_argparse.h" #include "common/config.h" -#include "include/ceph/libceph.h" +#include "include/cephfs/libcephfs.h" #include "include/rados/librados.h" #include "test/unit.h" diff --git a/src/test/libceph_config.cc b/src/test/libceph_config.cc index aac7dabeff63..c5e184f59c4f 100644 --- a/src/test/libceph_config.cc +++ b/src/test/libceph_config.cc @@ -13,7 +13,7 @@ */ #include "gtest/gtest.h" -#include "include/ceph/libceph.h" +#include "include/cephfs/libcephfs.h" #include #include