├── mingw_include ├── netdb.h ├── poll.h ├── sys │ ├── uio.h │ ├── vfs.h │ ├── cdefs.h │ ├── mman.h │ ├── statvfs.h │ └── socket.h ├── arpa │ └── inet.h ├── netinet │ ├── ip.h │ ├── tcp.h │ └── in.h └── uuid │ └── uuid.h ├── dokan └── dokan.lib ├── libboost_system-mgw51-mt-1_63.a ├── ceph_ver.h ├── myapi ├── myapi.def ├── makefile ├── sources └── myapi.c ├── ceph.conf ├── common ├── errno.h ├── dout.cc ├── arch.h ├── sctp_crc32.h ├── page.cc ├── ceph_frag.cc ├── armor.h ├── SimpleRNG.h ├── environment.h ├── secret.h ├── errno.cc ├── RefCountedObj.cc ├── likely.h ├── BackTrace.h ├── hex.h ├── Clock.h ├── static_assert.h ├── ceph_crypto.cc ├── version.h ├── compiler_extensions.h ├── types.cc ├── ceph_crypto.h ├── strtol.h ├── debug.h ├── lockdep.h ├── config_obs.h ├── Semaphore.h ├── version.cc ├── environment.cc ├── hex.cc ├── Clock.cc ├── io_priority.h ├── PrebufferedStreambuf.h ├── crc32c.cc ├── code_environment.h ├── Thread.h ├── io_priority.cc ├── sync_filesystem.h ├── signal.h ├── histogram.cc ├── escape.h └── tracked_int_ptr.hpp ├── crush ├── types.h ├── mapper.h ├── hash.h ├── sample.txt └── CrushWrapper.i ├── include ├── color.h ├── page.h ├── unordered_set.h ├── rados │ ├── page.h │ ├── memory.h │ ├── rados_types.h │ ├── crc32c.h │ ├── librgw.h │ └── rados_types.hpp ├── unordered_map.h ├── ceph_hash.h ├── memory.h ├── hash_namespace.h ├── stringify.h ├── err.h ├── addr_parsing.h ├── triple.h ├── rbd │ └── features.h ├── crc32c.h ├── intarith.h ├── error.h ├── on_exit.h ├── str_list.h ├── blobhash.h ├── compat.h ├── bitmapper.h ├── uuid.h ├── hash.h └── Distribution.h ├── .gitignore ├── client ├── Dir.h ├── Dentry.cc ├── Fh.h ├── ClientSnapRealm.cc ├── Dentry.h ├── Trace.h ├── ioctl.h ├── ClientSnapRealm.h ├── MetaSession.cc └── MetaSession.h ├── json_spirit ├── json_spirit.h ├── Makefile.am ├── json_spirit_writer_options.h └── json_spirit_error_position.h ├── global ├── global_context.cc ├── global_context.h ├── pidfile.h └── signal_handler.h ├── messages ├── MGatherCaps.h ├── MPing.h ├── MMonGetMap.h ├── MGenericMessage.h ├── MPGStatsAck.h ├── MMonGlobalID.h ├── MMDSFindIno.h ├── MClientQuota.h ├── MStatfsReply.h ├── MExportCapsAck.h ├── MMDSFindInoReply.h ├── MOSDAlive.h ├── MMDSOpenIno.h ├── MExportCaps.h ├── MExportDirNotifyAck.h ├── MLogAck.h ├── MExportDirCancel.h ├── MStatfs.h ├── MMonMap.h ├── MRemoveSnaps.h ├── MMonSubscribeAck.h ├── MExportDirAck.h ├── MInodeFileCaps.h ├── MCommand.h ├── MOSDPGTemp.h ├── MExportDirFinish.h ├── MCommandReply.h ├── MDentryUnlink.h ├── MExportDirPrepAck.h ├── MMDSResolveAck.h ├── MOSDPGMissing.h ├── MGetPoolStatsReply.h ├── MMonJoin.h ├── MGetPoolStats.h ├── MMonCommandAck.h ├── MMDSOpenInoReply.h ├── MOSDECSubOpRead.h ├── MMonCommand.h ├── MMonGetVersion.h ├── MLog.h ├── MOSDECSubOpReadReply.h ├── MOSDECSubOpWriteReply.h ├── MExportDir.h ├── MHeartbeat.h ├── MMDSLoadTargets.h └── MAuth.h ├── log ├── SubsystemMap.cc ├── Entry.h ├── EntryQueue.h └── SubsystemMap.h ├── auth ├── none │ ├── AuthNoneProtocol.h │ ├── AuthNoneAuthorizeHandler.h │ ├── AuthNoneServiceHandler.h │ ├── AuthNoneSessionHandler.h │ ├── AuthNoneAuthorizeHandler.cc │ └── AuthNoneClientHandler.h ├── AuthServiceHandler.cc ├── unknown │ ├── AuthUnknownProtocol.h │ ├── AuthUnknownAuthorizeHandler.h │ ├── AuthUnknownAuthorizeHandler.cc │ ├── AuthUnknownServiceHandler.h │ ├── AuthUnknownSessionHandler.h │ └── AuthUnknownClientHandler.h ├── cephx │ ├── CephxAuthorizeHandler.h │ ├── CephxSessionHandler.h │ ├── CephxServiceHandler.h │ └── CephxAuthorizeHandler.cc ├── AuthClientHandler.cc ├── AuthMethodList.h ├── AuthServiceHandler.h ├── RotatingKeyRing.h └── AuthAuthorizeHandler.cc ├── msg ├── async │ ├── net_handler.h │ └── EventEpoll.h ├── simple │ ├── Accepter.h │ └── PipeConnection.h └── Messenger.cc └── osdc └── WritebackHandler.h /mingw_include/netdb.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mingw_include/poll.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mingw_include/sys/uio.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mingw_include/sys/vfs.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mingw_include/arpa/inet.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mingw_include/netinet/ip.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mingw_include/netinet/tcp.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mingw_include/sys/cdefs.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mingw_include/sys/mman.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mingw_include/sys/statvfs.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dokan/dokan.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ceph/ceph-dokan/master/dokan/dokan.lib -------------------------------------------------------------------------------- /libboost_system-mgw51-mt-1_63.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ceph/ceph-dokan/master/libboost_system-mgw51-mt-1_63.a -------------------------------------------------------------------------------- /ceph_ver.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_VERSION_H 2 | #define CEPH_VERSION_H 3 | 4 | #define CEPH_GIT_VER 088fcbdd3046210be23fd1bcc32de0892f3f7205 5 | #define CEPH_GIT_NICE_VER "0.94.2" 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /myapi/myapi.def: -------------------------------------------------------------------------------- 1 | 2 | LIBRARY myapi 3 | 4 | EXPORTS 5 | 6 | MyConvertSecurityDescriptorToStringSecurityDescriptor 7 | MyConvertStringSecurityDescriptorToSecurityDescriptor 8 | 9 | -------------------------------------------------------------------------------- /ceph.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | auth cluster required = none 3 | auth service required = none 4 | auth client required = none 5 | log_file = 1.log 6 | 7 | [mon] 8 | [mon.0] 9 | mon addr = 10.0.0.183:6789 10 | -------------------------------------------------------------------------------- /common/errno.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_ERRNO_H 2 | #define CEPH_ERRNO_H 3 | 4 | #include 5 | 6 | /* Return a given error code as a string */ 7 | std::string cpp_strerror(int err); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /mingw_include/sys/socket.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include // for struct sockaddr_storage 3 | #define _SS_MAXSIZE 128 /* Maximum size. */ 4 | #define SHUT_RDWR SD_BOTH 5 | #define MSG_NOSIGNAL 6 | -------------------------------------------------------------------------------- /common/dout.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void dout_emergency(const char * const str) 5 | { 6 | std::cerr << str; 7 | std::cerr.flush(); 8 | } 9 | 10 | void dout_emergency(const std::string &str) 11 | { 12 | std::cerr << str; 13 | std::cerr.flush(); 14 | } 15 | -------------------------------------------------------------------------------- /common/arch.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_ARCH_H 2 | #define CEPH_ARCH_H 3 | 4 | static const char *get_arch() 5 | { 6 | #if defined(__i386__) 7 | return "i386"; 8 | #elif defined(__x86_64__) 9 | return "x86-64"; 10 | #else 11 | return "unknown"; 12 | #endif 13 | } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /common/sctp_crc32.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_COMMON_SCTP_CRC32_H 2 | #define CEPH_COMMON_SCTP_CRC32_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | extern uint32_t ceph_crc32c_sctp(uint32_t crc, unsigned char const *data, unsigned length); 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /mingw_include/netinet/in.h: -------------------------------------------------------------------------------- 1 | #ifndef _WIN32_WINNT 2 | #undef _WIN32_WINNT 3 | #define _WIN32_WINNT 0x0501 4 | #endif 5 | 6 | #include 7 | #include 8 | 9 | #define NS_INADDRSZ 4 10 | #define NS_IN6ADDRSZ 16 11 | #define NS_INT16SZ 2 12 | 13 | int inet_pton(int af, const char *src, char *dst); 14 | -------------------------------------------------------------------------------- /mingw_include/uuid/uuid.h: -------------------------------------------------------------------------------- 1 | #undef uuid_t 2 | typedef unsigned char uuid_t[16]; 3 | 4 | int uuid_parse(const char *in, uuid_t uu); 5 | void uuid_unparse(const uuid_t uu, char *out); 6 | int uuid_compare(const uuid_t uu1, const uuid_t uu2); 7 | int uuid_is_null(const uuid_t uu); 8 | 9 | #define uuid_generate(uuid) return 10 | 11 | -------------------------------------------------------------------------------- /crush/types.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_CRUSH_TYPES_H 2 | #define CEPH_CRUSH_TYPES_H 3 | 4 | #ifdef KERNEL 5 | # define free(x) kfree(x) 6 | #else 7 | # include 8 | #endif 9 | 10 | 11 | #include /* just for int types */ 12 | 13 | #ifndef BUG_ON 14 | # define BUG_ON(x) assert(!(x)) 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /myapi/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the driver components of the Windows NT DDK 5 | # 6 | 7 | !INCLUDE $(NTMAKEENV)\makefile.def 8 | 9 | C_DEFINES = /DUNICODE 10 | -------------------------------------------------------------------------------- /myapi/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=myapi 2 | TARGETTYPE=DYNLINK 3 | 4 | C_DEFINES=$(C_DEFINES) -DUNICODE -D_UNICODE 5 | 6 | TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \ 7 | $(SDK_LIB_PATH)\user32.lib \ 8 | $(SDK_LIB_PATH)\advapi32.lib 9 | 10 | USE_MSVCRT=1 11 | 12 | SOURCES=myapi.c 13 | 14 | UMTYPE=windows 15 | 16 | 17 | -------------------------------------------------------------------------------- /include/color.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_COLOR_H 2 | #define CEPH_COLOR_H 3 | 4 | #define TEXT_NORMAL "\033[0m" 5 | /*#define TEXT_HAZARD "\033[5;31m"*/ 6 | #define TEXT_RED "\033[0;31m" 7 | #define TEXT_GREEN "\033[0;32m" 8 | #define TEXT_YELLOW "\033[0;33m" 9 | #define TEXT_BLUE "\033[0;34m" 10 | #define TEXT_MAGENTA "\033[0;35m" 11 | #define TEXT_CYAN "\033[0;36m" 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | 15 | # Fortran module files 16 | *.mod 17 | 18 | # Compiled Static libraries 19 | *.lai 20 | *.la 21 | *.a 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | -------------------------------------------------------------------------------- /include/page.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_PAGE_H 2 | #define CEPH_PAGE_H 3 | 4 | namespace ceph { 5 | // these are in common/page.cc 6 | extern unsigned _page_size; 7 | extern unsigned long _page_mask; 8 | extern unsigned _page_shift; 9 | } 10 | 11 | #endif 12 | 13 | 14 | #define CEPH_PAGE_SIZE ceph::_page_size 15 | #define CEPH_PAGE_MASK ceph::_page_mask 16 | #define CEPH_PAGE_SHIFT ceph::_page_shift 17 | 18 | 19 | -------------------------------------------------------------------------------- /include/unordered_set.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_UNORDERED_SET_H 2 | #define CEPH_UNORDERED_SET_H 3 | 4 | #include 5 | 6 | #ifdef _LIBCPP_VERSION 7 | 8 | #include 9 | 10 | namespace ceph { 11 | using std::unordered_set; 12 | } 13 | 14 | #else 15 | 16 | #include 17 | 18 | namespace ceph { 19 | using std::tr1::unordered_set; 20 | } 21 | 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /common/page.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace ceph { 4 | 5 | // page size crap, see page.h 6 | int _get_bits_of(int v) { 7 | int n = 0; 8 | while (v) { 9 | n++; 10 | v = v >> 1; 11 | } 12 | return n; 13 | } 14 | 15 | unsigned _page_size = 4096; 16 | unsigned long _page_mask = ~(unsigned long)(_page_size - 1); 17 | unsigned _page_shift = _get_bits_of(_page_size); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /include/rados/page.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_PAGE_H 2 | #define CEPH_PAGE_H 3 | 4 | namespace ceph { 5 | // these are in common/page.cc 6 | extern unsigned _page_size; 7 | extern unsigned long _page_mask; 8 | extern unsigned _page_shift; 9 | } 10 | 11 | #endif 12 | 13 | 14 | #define CEPH_PAGE_SIZE ceph::_page_size 15 | #define CEPH_PAGE_MASK ceph::_page_mask 16 | #define CEPH_PAGE_SHIFT ceph::_page_shift 17 | 18 | 19 | -------------------------------------------------------------------------------- /common/ceph_frag.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Ceph 'frag' type 3 | */ 4 | #include "include/types.h" 5 | 6 | int ceph_frag_compare(__u32 a, __u32 b) 7 | { 8 | unsigned va = ceph_frag_value(a); 9 | unsigned vb = ceph_frag_value(b); 10 | if (va < vb) 11 | return -1; 12 | if (va > vb) 13 | return 1; 14 | va = ceph_frag_bits(a); 15 | vb = ceph_frag_bits(b); 16 | if (va < vb) 17 | return -1; 18 | if (va > vb) 19 | return 1; 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /client/Dir.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_CLIENT_DIR_H 2 | #define CEPH_CLIENT_DIR_H 3 | 4 | struct Inode; 5 | 6 | class Dir { 7 | public: 8 | Inode *parent_inode; // my inode 9 | ceph::unordered_map dentries; 10 | xlist dentry_list; 11 | uint64_t release_count; 12 | uint64_t ordered_count; 13 | 14 | Dir(Inode* in) : release_count(0), ordered_count(0) { parent_inode = in; } 15 | 16 | bool is_empty() { return dentries.empty(); } 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /include/unordered_map.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_UNORDERED_MAP_H 2 | #define CEPH_UNORDERED_MAP_H 3 | 4 | #include 5 | 6 | #ifdef _LIBCPP_VERSION 7 | 8 | #include 9 | 10 | namespace ceph { 11 | using std::unordered_map; 12 | using std::unordered_multimap; 13 | } 14 | 15 | #else 16 | 17 | #include 18 | 19 | namespace ceph { 20 | using std::tr1::unordered_map; 21 | using std::tr1::unordered_multimap; 22 | } 23 | 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/ceph_hash.h: -------------------------------------------------------------------------------- 1 | #ifndef FS_CEPH_HASH_H 2 | #define FS_CEPH_HASH_H 3 | 4 | #define CEPH_STR_HASH_LINUX 0x1 /* linux dcache hash */ 5 | #define CEPH_STR_HASH_RJENKINS 0x2 /* robert jenkins' */ 6 | 7 | extern unsigned ceph_str_hash_linux(const char *s, unsigned len); 8 | extern unsigned ceph_str_hash_rjenkins(const char *s, unsigned len); 9 | 10 | extern unsigned ceph_str_hash(int type, const char *s, unsigned len); 11 | extern const char *ceph_str_hash_name(int type); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /include/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_MEMORY_H 2 | #define CEPH_MEMORY_H 3 | 4 | #include 5 | 6 | #ifdef _LIBCPP_VERSION 7 | 8 | #include 9 | 10 | namespace ceph { 11 | using std::shared_ptr; 12 | using std::weak_ptr; 13 | using std::static_pointer_cast; 14 | } 15 | 16 | #else 17 | 18 | #include 19 | 20 | namespace ceph { 21 | using std::tr1::shared_ptr; 22 | using std::tr1::weak_ptr; 23 | using std::tr1::static_pointer_cast; 24 | } 25 | 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /json_spirit/json_spirit.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT 2 | #define JSON_SPIRIT 3 | 4 | // Copyright John W. Wilkinson 2007 - 2011 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt 6 | 7 | // json spirit version 4.05 8 | 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 10 | # pragma once 11 | #endif 12 | 13 | #include "json_spirit_value.h" 14 | #include "json_spirit_reader.h" 15 | #include "json_spirit_writer.h" 16 | #include "json_spirit_utils.h" 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /common/armor.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_ARMOR_H 2 | #define CEPH_ARMOR_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | int ceph_armor(char *dst, const char *dst_end, 9 | const char *src, const char *end); 10 | 11 | int ceph_armor_linebreak(char *dst, const char *dst_end, 12 | const char *src, const char *end, 13 | int line_width); 14 | int ceph_unarmor(char *dst, const char *dst_end, 15 | const char *src, const char *end); 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /crush/mapper.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_CRUSH_MAPPER_H 2 | #define CEPH_CRUSH_MAPPER_H 3 | 4 | /* 5 | * CRUSH functions for find rules and then mapping an input to an 6 | * output set. 7 | * 8 | * LGPL2 9 | */ 10 | 11 | #include "crush.h" 12 | 13 | extern int crush_find_rule(const struct crush_map *map, int ruleset, int type, int size); 14 | extern int crush_do_rule(const struct crush_map *map, 15 | int ruleno, 16 | int x, int *result, int result_max, 17 | const __u32 *weights, int weight_max, 18 | int *scratch); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /include/rados/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_MEMORY_H 2 | #define CEPH_MEMORY_H 3 | 4 | #include 5 | 6 | #ifdef _LIBCPP_VERSION 7 | 8 | #include 9 | 10 | namespace ceph { 11 | using std::shared_ptr; 12 | using std::weak_ptr; 13 | using std::static_pointer_cast; 14 | } 15 | 16 | #else 17 | 18 | #include 19 | 20 | namespace ceph { 21 | using std::tr1::shared_ptr; 22 | using std::tr1::weak_ptr; 23 | using std::tr1::static_pointer_cast; 24 | } 25 | 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/hash_namespace.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_HASH_NAMESPACE_H 2 | #define CEPH_HASH_NAMESPACE_H 3 | 4 | #include 5 | 6 | #ifdef _LIBCPP_VERSION 7 | 8 | #include 9 | 10 | #define CEPH_HASH_NAMESPACE_START namespace std { 11 | #define CEPH_HASH_NAMESPACE_END } 12 | #define CEPH_HASH_NAMESPACE std 13 | 14 | #else 15 | 16 | #include 17 | 18 | #define CEPH_HASH_NAMESPACE_START namespace std { namespace tr1 { 19 | #define CEPH_HASH_NAMESPACE_END }} 20 | #define CEPH_HASH_NAMESPACE std::tr1 21 | 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/stringify.h: -------------------------------------------------------------------------------- 1 | #ifndef __CEPH_STRINGIFY_H 2 | #define __CEPH_STRINGIFY_H 3 | 4 | #include 5 | #include 6 | 7 | template 8 | inline std::string stringify(const T& a) { 9 | std::ostringstream ss; 10 | ss << a; 11 | return ss.str(); 12 | } 13 | 14 | template 15 | T joinify(const A &begin, const A &end, const T &t) 16 | { 17 | T result; 18 | for (A it = begin; it != end; it++) { 19 | if (!result.empty()) 20 | result.append(t); 21 | result.append(*it); 22 | } 23 | return result; 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/rados/rados_types.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_RADOS_TYPES_H 2 | #define CEPH_RADOS_TYPES_H 3 | 4 | #include 5 | 6 | /** 7 | * @struct obj_watch_t 8 | * One item from list_watchers 9 | */ 10 | struct obj_watch_t { 11 | char addr[256]; 12 | int64_t watcher_id; 13 | uint64_t cookie; 14 | uint32_t timeout_seconds; 15 | }; 16 | 17 | /** 18 | * @defines 19 | * 20 | * Pass as nspace argument to rados_ioctx_set_namespace() 21 | * before calling rados_nobjects_list_open() to return 22 | * all objects in all namespaces. 23 | */ 24 | #define LIBRADOS_ALL_NSPACES "\001" 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /crush/hash.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_CRUSH_HASH_H 2 | #define CEPH_CRUSH_HASH_H 3 | 4 | #define CRUSH_HASH_RJENKINS1 0 5 | 6 | #define CRUSH_HASH_DEFAULT CRUSH_HASH_RJENKINS1 7 | 8 | extern const char *crush_hash_name(int type); 9 | 10 | extern __u32 crush_hash32(int type, __u32 a); 11 | extern __u32 crush_hash32_2(int type, __u32 a, __u32 b); 12 | extern __u32 crush_hash32_3(int type, __u32 a, __u32 b, __u32 c); 13 | extern __u32 crush_hash32_4(int type, __u32 a, __u32 b, __u32 c, __u32 d); 14 | extern __u32 crush_hash32_5(int type, __u32 a, __u32 b, __u32 c, __u32 d, 15 | __u32 e); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/err.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_ERR_H 2 | #define CEPH_ERR_H 3 | 4 | /* 5 | * adapted from linux 2.6.24 include/linux/err.h 6 | */ 7 | #define MAX_ERRNO 4095 8 | #define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO) 9 | 10 | #include 11 | 12 | /* this generates a warning in c++; caller can do the cast manually 13 | static inline void *ERR_PTR(long error) 14 | { 15 | return (void *) error; 16 | } 17 | */ 18 | 19 | static inline long PTR_ERR(const void *ptr) 20 | { 21 | return (long) ptr; 22 | } 23 | 24 | static inline long IS_ERR(const void *ptr) 25 | { 26 | return IS_ERR_VALUE((unsigned long)ptr); 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /common/SimpleRNG.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #ifndef __CEPH_COMMON_SIMPLERNG_H_ 5 | #define __CEPH_COMMON_SIMPLERNG_H_ 6 | 7 | /* 8 | * rand() is not thread-safe. random_r family segfaults. 9 | * boost::random::* have build issues. 10 | */ 11 | class SimpleRNG { 12 | unsigned m_z, m_w; 13 | 14 | public: 15 | SimpleRNG(int seed) : m_z(seed), m_w(123) {} 16 | 17 | unsigned operator()() { 18 | m_z = 36969 * (m_z & 65535) + (m_z >> 16); 19 | m_w = 18000 * (m_w & 65535) + (m_w >> 16); 20 | return (m_z << 16) + m_w; 21 | } 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/addr_parsing.h: -------------------------------------------------------------------------------- 1 | /* 2 | * addr_parsing.h 3 | * 4 | * Created on: Sep 14, 2010 5 | * Author: gregf 6 | * contains functions used by Ceph to convert named addresses 7 | * (eg ceph.com) into IP addresses (ie 127.0.0.1). 8 | */ 9 | 10 | #ifndef ADDR_PARSING_H_ 11 | #define ADDR_PARSING_H_ 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | int safe_cat(char **pstr, int *plen, int pos, const char *str2); 18 | 19 | /* 20 | * returns a string allocated by malloc; caller must free 21 | */ 22 | char *resolve_addrs(const char *orig_str); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif /* ADDR_PARSING_H_ */ 29 | -------------------------------------------------------------------------------- /common/environment.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_COMMON_ENVIRONMENT_H 16 | #define CEPH_COMMON_ENVIRONMENT_H 17 | 18 | extern bool get_env_bool(const char *key); 19 | extern int get_env_int(const char *key); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /common/secret.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_SECRET_H 2 | #define CEPH_SECRET_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | int read_secret_from_file(const char *filename, char *secret, size_t max_len); 9 | 10 | /* 11 | * Attempts to add the secret to the kernel, but falls back to 12 | * the old secret= option if the kernel is too old. 13 | */ 14 | int get_secret_option(const char *secret, const char *key_name, 15 | char *secret_option, size_t secret_option_len); 16 | 17 | int set_kernel_secret(const char *secret, const char *key_name); 18 | 19 | int is_kernel_secret(const char *key_name); 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /json_spirit/Makefile.am: -------------------------------------------------------------------------------- 1 | libjson_spirit_la_SOURCES = \ 2 | json_spirit/json_spirit_reader.cpp \ 3 | json_spirit/json_spirit_writer.cpp 4 | libjson_spirit_la_LIBADD = $(BOOST_THREAD_LIBS) 5 | noinst_LTLIBRARIES += libjson_spirit.la 6 | 7 | noinst_HEADERS += \ 8 | json_spirit/json_spirit.h \ 9 | json_spirit/json_spirit_error_position.h \ 10 | json_spirit/json_spirit_reader.h \ 11 | json_spirit/json_spirit_reader_template.h \ 12 | json_spirit/json_spirit_stream_reader.h \ 13 | json_spirit/json_spirit_utils.h \ 14 | json_spirit/json_spirit_value.h \ 15 | json_spirit/json_spirit_writer.h \ 16 | json_spirit/json_spirit_writer_options.h \ 17 | json_spirit/json_spirit_writer_template.h 18 | 19 | -------------------------------------------------------------------------------- /common/errno.cc: -------------------------------------------------------------------------------- 1 | #include "common/errno.h" 2 | #include "acconfig.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | std::string cpp_strerror(int err) 10 | { 11 | char buf[128]; 12 | char *errmsg; 13 | 14 | if (err < 0) 15 | err = -err; 16 | std::ostringstream oss; 17 | buf[0] = '\0'; 18 | 19 | // strerror_r returns char * on Linux, and does not always fill buf 20 | //by ketor #ifdef STRERROR_R_CHAR_P 21 | // errmsg = strerror_r(err, buf, sizeof(buf)); 22 | //#else 23 | // strerror_r(err, buf, sizeof(buf)); 24 | // errmsg = buf; 25 | //#endif 26 | 27 | oss << "(" << err << ") " /*by ketor << errmsg*/; 28 | 29 | return oss.str(); 30 | } 31 | -------------------------------------------------------------------------------- /common/RefCountedObj.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "common/RefCountedObj.h" 16 | 17 | void intrusive_ptr_add_ref(RefCountedObject *p) { 18 | p->get(); 19 | } 20 | void intrusive_ptr_release(RefCountedObject *p) { 21 | p->put(); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /common/likely.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2010 Dreamhost 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_LIKELY_DOT_H 16 | #define CEPH_LIKELY_DOT_H 17 | 18 | /* 19 | * Likely / Unlikely macros 20 | */ 21 | #define likely(x) __builtin_expect((x),1) 22 | #define unlikely(x) __builtin_expect((x),0) 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /global/global_context.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "common/ceph_context.h" 16 | #include "global/global_context.h" 17 | 18 | /* 19 | * Global variables for use from process context. 20 | */ 21 | CephContext *g_ceph_context = NULL; 22 | md_config_t *g_conf = NULL; 23 | -------------------------------------------------------------------------------- /messages/MGatherCaps.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_MGATHERCAPS_H 2 | #define CEPH_MGATHERCAPS_H 3 | 4 | #include "msg/Message.h" 5 | 6 | 7 | class MGatherCaps : public Message { 8 | public: 9 | inodeno_t ino; 10 | 11 | MGatherCaps() : 12 | Message(MSG_MDS_GATHERCAPS) {} 13 | private: 14 | ~MGatherCaps() {} 15 | 16 | public: 17 | const char *get_type_name() const { return "gather_caps"; } 18 | void print(ostream& o) const { 19 | o << "gather_caps(" << ino << ")"; 20 | } 21 | 22 | void encode_payload(uint64_t features) { 23 | ::encode(ino, payload); 24 | } 25 | void decode_payload() { 26 | bufferlist::iterator p = payload.begin(); 27 | ::decode(ino, p); 28 | } 29 | 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/BackTrace.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_BACKTRACE_H 2 | #define CEPH_BACKTRACE_H 3 | 4 | #include 5 | //#include 6 | #include 7 | 8 | namespace ceph { 9 | 10 | struct BackTrace { 11 | const static int max = 100; 12 | 13 | int skip; 14 | void *array[max]; 15 | size_t size; 16 | char **strings; 17 | 18 | BackTrace(int s) : skip(s) { 19 | //size = backtrace(array, max); 20 | //strings = backtrace_symbols(array, size); 21 | size = 0; 22 | } 23 | ~BackTrace() { 24 | //free(strings); 25 | } 26 | 27 | BackTrace(const BackTrace& other); 28 | const BackTrace& operator=(const BackTrace& other); 29 | 30 | void print(std::ostream& out); 31 | }; 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /common/hex.h: -------------------------------------------------------------------------------- 1 | 2 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 3 | // vim: ts=8 sw=2 smarttab 4 | /* 5 | * Ceph - scalable distributed file system 6 | * 7 | * Copyright (C) 2011 New Dream Network 8 | * 9 | * This is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License version 2.1, as published by the Free Software 12 | * Foundation. See file COPYING. 13 | * 14 | */ 15 | 16 | #ifndef CEPH_COMMON_HEX_H 17 | #define CEPH_COMMON_HEX_H 18 | 19 | #include 20 | 21 | extern void hex2str(const char *s, int len, char *buf, int dest_len); 22 | 23 | extern std::string hexdump(std::string msg, const char *s, int len); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /common/Clock.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_CLOCK_H 16 | #define CEPH_CLOCK_H 17 | 18 | #include "include/utime.h" 19 | 20 | #include 21 | 22 | class CephContext; 23 | 24 | extern utime_t ceph_clock_now(CephContext *cct); 25 | extern time_t ceph_clock_gettime(CephContext *cct); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /global/global_context.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_GLOBAL_CONTEXT_H 16 | #define CEPH_GLOBAL_CONTEXT_H 17 | 18 | #include "common/ceph_context.h" 19 | 20 | #include 21 | #include 22 | 23 | struct md_config_t; 24 | 25 | extern CephContext *g_ceph_context; 26 | extern md_config_t *g_conf; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/triple.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_TRIPLE_H 16 | #define CEPH_TRIPLE_H 17 | 18 | template 19 | class triple { 20 | public: 21 | A first; 22 | B second; 23 | C third; 24 | 25 | triple() {} 26 | triple(A f, B s, C t) : first(f), second(s), third(t) {} 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /include/rbd/features.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_RBD_FEATURES_H 2 | #define CEPH_RBD_FEATURES_H 3 | 4 | #define RBD_FEATURE_LAYERING (1<<0) 5 | #define RBD_FEATURE_STRIPINGV2 (1<<1) 6 | #define RBD_FEATURE_EXCLUSIVE_LOCK (1<<2) 7 | #define RBD_FEATURE_OBJECT_MAP (1<<3) 8 | 9 | #define RBD_FEATURES_INCOMPATIBLE (RBD_FEATURE_LAYERING | \ 10 | RBD_FEATURE_STRIPINGV2) 11 | 12 | #define RBD_FEATURES_RW_INCOMPATIBLE (RBD_FEATURES_INCOMPATIBLE | \ 13 | RBD_FEATURE_EXCLUSIVE_LOCK | \ 14 | RBD_FEATURE_OBJECT_MAP) 15 | 16 | #define RBD_FEATURES_ALL (RBD_FEATURE_LAYERING | \ 17 | RBD_FEATURE_STRIPINGV2 | \ 18 | RBD_FEATURE_EXCLUSIVE_LOCK | \ 19 | RBD_FEATURE_OBJECT_MAP) 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /log/SubsystemMap.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "SubsystemMap.h" 3 | 4 | namespace ceph { 5 | namespace log { 6 | 7 | void SubsystemMap::add(unsigned subsys, std::string name, int log, int gather) 8 | { 9 | if (subsys >= m_subsys.size()) 10 | m_subsys.resize(subsys + 1); 11 | m_subsys[subsys].name = name; 12 | m_subsys[subsys].log_level = log; 13 | m_subsys[subsys].gather_level = gather; 14 | if (name.length() > m_max_name_len) 15 | m_max_name_len = name.length(); 16 | } 17 | 18 | void SubsystemMap::set_log_level(unsigned subsys, int log) 19 | { 20 | assert(subsys < m_subsys.size()); 21 | m_subsys[subsys].log_level = log; 22 | } 23 | 24 | void SubsystemMap::set_gather_level(unsigned subsys, int gather) 25 | { 26 | assert(subsys < m_subsys.size()); 27 | m_subsys[subsys].gather_level = gather; 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/static_assert.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_COMMON_STATIC_ASSERT 16 | #define CEPH_COMMON_STATIC_ASSERT 17 | 18 | /* Create a compiler error if condition is false. 19 | * Also produce a result of value 0 and type size_t. 20 | * This expression can be used anywhere, even in structure initializers. 21 | */ 22 | #define STATIC_ASSERT(x) (sizeof(int[((x)==0) ? -1 : 0])) 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /client/Dentry.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #include "include/types.h" 5 | #include "include/utime.h" 6 | 7 | #include "Dentry.h" 8 | #include "Dir.h" 9 | #include "Inode.h" 10 | 11 | #include "common/Formatter.h" 12 | 13 | void Dentry::dump(Formatter *f) const 14 | { 15 | f->dump_string("name", name); 16 | f->dump_stream("dir") << dir->parent_inode->ino; 17 | if (inode) 18 | f->dump_stream("ino") << inode->ino; 19 | f->dump_int("ref", ref); 20 | f->dump_unsigned("offset", offset); 21 | if (lease_mds >= 0) { 22 | f->dump_int("lease_mds", lease_mds); 23 | f->dump_stream("lease_ttl") << lease_ttl; 24 | f->dump_int("lease_gen", lease_gen); 25 | f->dump_int("lease_seq", lease_seq); 26 | } 27 | f->dump_int("cap_shared_gen", cap_shared_gen); 28 | } 29 | -------------------------------------------------------------------------------- /client/Fh.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_CLIENT_FH_H 2 | #define CEPH_CLIENT_FH_H 3 | 4 | #include "common/Readahead.h" 5 | #include "include/types.h" 6 | 7 | struct Inode; 8 | class Cond; 9 | class ceph_lock_state_t; 10 | 11 | // file handle for any open file state 12 | 13 | struct Fh { 14 | Inode *inode; 15 | loff_t pos; 16 | int mds; // have to talk to mds we opened with (for now) 17 | int mode; // the mode i opened the file with 18 | 19 | int flags; 20 | bool pos_locked; // pos is currently in use 21 | list pos_waiters; // waiters for pos 22 | 23 | Readahead readahead; 24 | 25 | // file lock 26 | ceph_lock_state_t *fcntl_locks; 27 | ceph_lock_state_t *flock_locks; 28 | 29 | Fh() : inode(0), pos(0), mds(0), mode(0), flags(0), pos_locked(false), 30 | readahead(), fcntl_locks(NULL), flock_locks(NULL) {} 31 | }; 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /messages/MPing.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MPING_H 17 | #define CEPH_MPING_H 18 | 19 | #include "msg/Message.h" 20 | 21 | class MPing : public Message { 22 | public: 23 | MPing() : Message(CEPH_MSG_PING) {} 24 | private: 25 | ~MPing() {} 26 | 27 | public: 28 | void decode_payload() { } 29 | void encode_payload(uint64_t features) { } 30 | const char *get_type_name() const { return "ping"; } 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /include/crc32c.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_CRC32C_H 2 | #define CEPH_CRC32C_H 3 | 4 | #include 5 | #include 6 | 7 | typedef uint32_t (*ceph_crc32c_func_t)(uint32_t crc, unsigned char const *data, unsigned length); 8 | 9 | /* 10 | * this is a static global with the chosen crc32c implementation for 11 | * the given architecture. 12 | */ 13 | extern ceph_crc32c_func_t ceph_crc32c_func; 14 | 15 | extern ceph_crc32c_func_t ceph_choose_crc32(void); 16 | 17 | /** 18 | * calculate crc32c 19 | * 20 | * Note: if the data pointer is NULL, we calculate a crc value as if 21 | * it were zero-filled. 22 | * 23 | * @param crc initial value 24 | * @param data pointer to data buffer 25 | * @param length length of buffer 26 | */ 27 | static inline uint32_t ceph_crc32c(uint32_t crc, unsigned char const *data, unsigned length) 28 | { 29 | return ceph_crc32c_func(crc, data, length); 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/ceph_crypto.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2010-2011 Dreamhost 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "common/config.h" 16 | #include "common/ceph_context.h" 17 | #include "ceph_crypto.h" 18 | #include "auth/Crypto.h" 19 | 20 | #include 21 | #include 22 | 23 | 24 | #ifdef USE_CRYPTOPP 25 | void ceph::crypto::init(CephContext *cct) 26 | { 27 | } 28 | 29 | void ceph::crypto::shutdown() 30 | { 31 | } 32 | 33 | // nothing 34 | //by ketor ceph::crypto::HMACSHA1::~HMACSHA1() 35 | //{ 36 | //} 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /common/version.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_COMMON_VERSION_H 16 | #define CEPH_COMMON_VERSION_H 17 | 18 | #include 19 | 20 | // Return a string describing the Ceph version 21 | const char *ceph_version_to_str(void); 22 | 23 | // Return a string describing the git version 24 | const char *git_version_to_str(void); 25 | 26 | // Return a formatted string describing the ceph and git versions 27 | std::string const pretty_version_to_str(void); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /global/pidfile.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_COMMON_PIDFILE_H 16 | #define CEPH_COMMON_PIDFILE_H 17 | 18 | struct md_config_t; 19 | 20 | // Write a pidfile with the current pid, using the configuration in the 21 | // provided conf structure. 22 | int pidfile_write(const md_config_t *conf); 23 | 24 | // Remove the pid file that was previously written by pidfile_write. 25 | // This is safe to call in a signal handler context. 26 | int pidfile_remove(void); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /common/compiler_extensions.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_COMPILER_EXTENSIONS_H 16 | #define CEPH_COMPILER_EXTENSIONS_H 17 | 18 | /* We should be able to take advantage of nice nonstandard features of gcc 19 | * and other compilers, but still maintain portability. 20 | */ 21 | 22 | #ifdef __GNUC__ 23 | // GCC 24 | #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 25 | #else 26 | // some other compiler - just make it a no-op 27 | #define WARN_UNUSED_RESULT 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/rados/crc32c.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_CRC32C_H 2 | #define CEPH_CRC32C_H 3 | 4 | #include 5 | #include 6 | 7 | typedef uint32_t (*ceph_crc32c_func_t)(uint32_t crc, unsigned char const *data, unsigned length); 8 | 9 | /* 10 | * this is a static global with the chosen crc32c implementation for 11 | * the given architecture. 12 | */ 13 | extern ceph_crc32c_func_t ceph_crc32c_func; 14 | 15 | extern ceph_crc32c_func_t ceph_choose_crc32(void); 16 | 17 | /** 18 | * calculate crc32c 19 | * 20 | * Note: if the data pointer is NULL, we calculate a crc value as if 21 | * it were zero-filled. 22 | * 23 | * @param crc initial value 24 | * @param data pointer to data buffer 25 | * @param length length of buffer 26 | */ 27 | static inline uint32_t ceph_crc32c(uint32_t crc, unsigned char const *data, unsigned length) 28 | { 29 | return ceph_crc32c_func(crc, data, length); 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /common/types.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2014 Cloudwatt 7 | * 8 | * Author: Loic Dachary 9 | * 10 | * This library is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License as published by the Free Software Foundation; either 13 | * version 2.1 of the License, or (at your option) any later version. 14 | * 15 | */ 16 | #ifndef __CEPH_TYPES_H 17 | #define __CEPH_TYPES_H 18 | 19 | #include 20 | 21 | #ifndef UINT8_MAX 22 | #define UINT8_MAX (255) 23 | #endif 24 | 25 | const shard_id_t shard_id_t::NO_SHARD(UINT8_MAX); 26 | 27 | ostream &operator<<(ostream &lhs, const shard_id_t &rhs) 28 | { 29 | return lhs << (unsigned)rhs.id; 30 | } 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /messages/MMonGetMap.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MMONGETMAP_H 16 | #define CEPH_MMONGETMAP_H 17 | 18 | #include "msg/Message.h" 19 | 20 | #include "include/types.h" 21 | 22 | class MMonGetMap : public Message { 23 | public: 24 | MMonGetMap() : Message(CEPH_MSG_MON_GET_MAP) { } 25 | private: 26 | ~MMonGetMap() {} 27 | 28 | public: 29 | const char *get_type_name() const { return "mon_getmap"; } 30 | 31 | void encode_payload(uint64_t features) { } 32 | void decode_payload() { } 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /common/ceph_crypto.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_CRYPTO_H 2 | #define CEPH_CRYPTO_H 3 | 4 | #include "acconfig.h" 5 | 6 | #define CEPH_CRYPTO_MD5_DIGESTSIZE 16 7 | #define CEPH_CRYPTO_HMACSHA1_DIGESTSIZE 20 8 | #define CEPH_CRYPTO_SHA1_DIGESTSIZE 20 9 | #define CEPH_CRYPTO_SHA256_DIGESTSIZE 32 10 | 11 | #ifdef USE_CRYPTOPP 12 | # define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 13 | #include 14 | 15 | namespace ceph { 16 | namespace crypto { 17 | void init(CephContext *cct); 18 | void shutdown(); 19 | 20 | //by ketor using CryptoPP::Weak::MD5; 21 | //using CryptoPP::SHA1; 22 | //using CryptoPP::SHA256; 23 | // 24 | //class HMACSHA1: public CryptoPP::HMAC { 25 | //public: 26 | // HMACSHA1 (const byte *key, size_t length) 27 | //: CryptoPP::HMAC(key, length) 28 | //{ 29 | //} 30 | // ~HMACSHA1(); 31 | //}; 32 | } 33 | } 34 | 35 | #else 36 | # error "No supported crypto implementation found." 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /common/strtol.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_COMMON_STRTOL_H 16 | #define CEPH_COMMON_STRTOL_H 17 | 18 | #include 19 | extern "C" { 20 | #include 21 | } 22 | 23 | long long strict_strtoll(const char *str, int base, std::string *err); 24 | 25 | int strict_strtol(const char *str, int base, std::string *err); 26 | 27 | double strict_strtod(const char *str, std::string *err); 28 | 29 | float strict_strtof(const char *str, std::string *err); 30 | 31 | uint64_t strict_sistrtoll(const char *str, std::string *err); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /common/debug.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_DEBUG_H 16 | #define CEPH_DEBUG_H 17 | 18 | #include "common/dout.h" 19 | 20 | /* Global version of the stuff in common/dout.h 21 | */ 22 | 23 | #define dout(v) ldout((g_ceph_context), v) 24 | 25 | #define pdout(v, p) lpdout((g_ceph_context), v, p) 26 | 27 | #define dlog_p(sub, v) ldlog_p1((g_ceph_context), sub, v) 28 | 29 | #define generic_dout(v) lgeneric_dout((g_ceph_context), v) 30 | 31 | #define derr lderr((g_ceph_context)) 32 | 33 | #define generic_derr lgeneric_derr((g_ceph_context)) 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /common/lockdep.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2008-2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_LOCKDEP_H 16 | #define CEPH_LOCKDEP_H 17 | 18 | class CephContext; 19 | 20 | extern int g_lockdep; 21 | 22 | extern void lockdep_register_ceph_context(CephContext *cct); 23 | extern void lockdep_unregister_ceph_context(CephContext *cct); 24 | extern int lockdep_register(const char *n); 25 | extern int lockdep_will_lock(const char *n, int id); 26 | extern int lockdep_locked(const char *n, int id, bool force_backtrace=false); 27 | extern int lockdep_will_unlock(const char *n, int id); 28 | extern int lockdep_dump_locks(); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/intarith.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_INTARITH_H 16 | #define CEPH_INTARITH_H 17 | 18 | #ifndef MIN 19 | # define MIN(a,b) ((a) < (b) ? (a):(b)) 20 | #endif 21 | 22 | #ifndef MAX 23 | # define MAX(a,b) ((a) > (b) ? (a):(b)) 24 | #endif 25 | 26 | #ifndef DIV_ROUND_UP 27 | # define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) 28 | #endif 29 | 30 | #ifndef ROUND_UP_TO 31 | # define ROUND_UP_TO(n, d) ((n)%(d) ? ((n)+(d)-(n)%(d)) : (n)) 32 | #endif 33 | 34 | #ifndef SHIFT_ROUND_UP 35 | # define SHIFT_ROUND_UP(x,y) (((x)+(1<<(y))-1) >> (y)) 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /common/config_obs.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_CONFIG_OBS_H 16 | #define CEPH_CONFIG_OBS_H 17 | 18 | #include 19 | #include 20 | 21 | struct md_config_t; 22 | 23 | class md_config_obs_t { 24 | public: 25 | virtual ~md_config_obs_t(); 26 | virtual const char** get_tracked_conf_keys() const = 0; 27 | virtual void handle_conf_change(const struct md_config_t *conf, 28 | const std::set &changed) = 0; 29 | virtual void handle_subsys_change(const struct md_config_t *conf, 30 | const std::set& changed) { } 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /auth/none/AuthNoneProtocol.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_AUTHNONEPROTOCOL_H 16 | #define CEPH_AUTHNONEPROTOCOL_H 17 | 18 | #include "../Auth.h" 19 | 20 | struct AuthNoneAuthorizer : public AuthAuthorizer { 21 | AuthNoneAuthorizer() : AuthAuthorizer(CEPH_AUTH_NONE) { } 22 | bool build_authorizer(const EntityName &ename, uint64_t global_id) { 23 | __u8 struct_v = 1; 24 | ::encode(struct_v, bl); 25 | ::encode(ename, bl); 26 | ::encode(global_id, bl); 27 | return 0; 28 | } 29 | bool verify_reply(bufferlist::iterator& reply) { return true; } 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /auth/AuthServiceHandler.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "AuthServiceHandler.h" 16 | #include "cephx/CephxServiceHandler.h" 17 | #include "none/AuthNoneServiceHandler.h" 18 | #include "AuthMethodList.h" 19 | #include "common/config.h" 20 | 21 | #define dout_subsys ceph_subsys_auth 22 | 23 | 24 | AuthServiceHandler *get_auth_service_handler(int type, CephContext *cct, KeyServer *ks) 25 | { 26 | switch (type) { 27 | case CEPH_AUTH_CEPHX: 28 | return new CephxServiceHandler(cct, ks); 29 | case CEPH_AUTH_NONE: 30 | return new AuthNoneServiceHandler(cct); 31 | } 32 | return NULL; 33 | } 34 | -------------------------------------------------------------------------------- /common/Semaphore.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_Sem_Posix__H 17 | #define CEPH_Sem_Posix__H 18 | 19 | class Semaphore 20 | { 21 | Mutex m; 22 | Cond c; 23 | int count; 24 | 25 | public: 26 | 27 | Semaphore() : m("Semaphore::m") 28 | { 29 | count = 0; 30 | } 31 | 32 | void Put() 33 | { 34 | m.Lock(); 35 | count++; 36 | c.Signal(); 37 | m.Unlock(); 38 | } 39 | 40 | void Get() 41 | { 42 | m.Lock(); 43 | while(count <= 0) { 44 | c.Wait(m); 45 | } 46 | count--; 47 | m.Unlock(); 48 | } 49 | }; 50 | 51 | #endif // !_Mutex_Posix_ 52 | -------------------------------------------------------------------------------- /auth/unknown/AuthUnknownProtocol.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_AUTHUNKNOWNPROTOCOL_H 16 | #define CEPH_AUTHUNKNOWNPROTOCOL_H 17 | 18 | #include "../Auth.h" 19 | 20 | struct AuthUnknownAuthorizer : public AuthAuthorizer { 21 | AuthUnknownAuthorizer() : AuthAuthorizer(CEPH_AUTH_UNKNOWN) { } 22 | bool build_authorizer(const EntityName &ename, uint64_t global_id) { 23 | __u8 struct_v = 1; 24 | ::encode(struct_v, bl); 25 | ::encode(ename, bl); 26 | ::encode(global_id, bl); 27 | return 0; 28 | } 29 | bool verify_reply(bufferlist::iterator& reply) { return true; } 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/rados/librgw.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_LIBRGW_H 16 | #define CEPH_LIBRGW_H 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | class CephContext; 23 | typedef CephContext* librgw_t; 24 | int librgw_create(librgw_t *rgw, const char * const id); 25 | int librgw_acl_bin2xml(librgw_t rgw, const char *bin, int bin_len, char **xml); 26 | void librgw_free_xml(librgw_t rgw, char *xml); 27 | int librgw_acl_xml2bin(librgw_t rgw, const char *xml, char **bin, int *bin_len); 28 | void librgw_free_bin(librgw_t rgw, char *bin); 29 | void librgw_shutdown(librgw_t rgw); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /common/version.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "acconfig.h" 16 | #include "ceph_ver.h" 17 | #include "common/version.h" 18 | 19 | #include 20 | #include 21 | 22 | #define _STR(x) #x 23 | #define STRINGIFY(x) _STR(x) 24 | 25 | const char *ceph_version_to_str(void) 26 | { 27 | return CEPH_GIT_NICE_VER; 28 | } 29 | 30 | const char *git_version_to_str(void) 31 | { 32 | return STRINGIFY(CEPH_GIT_VER); 33 | } 34 | 35 | std::string const pretty_version_to_str(void) 36 | { 37 | std::ostringstream oss; 38 | oss << "ceph version " << CEPH_GIT_NICE_VER << " (" 39 | << STRINGIFY(CEPH_GIT_VER) << ")"; 40 | return oss.str(); 41 | } 42 | -------------------------------------------------------------------------------- /auth/cephx/CephxAuthorizeHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_CEPHXAUTHORIZEHANDLER_H 16 | #define CEPH_CEPHXAUTHORIZEHANDLER_H 17 | 18 | #include "../AuthAuthorizeHandler.h" 19 | 20 | class CephContext; 21 | 22 | struct CephxAuthorizeHandler : public AuthAuthorizeHandler { 23 | bool verify_authorizer(CephContext *cct, KeyStore *keys, 24 | bufferlist& authorizer_data, bufferlist& authorizer_reply, 25 | EntityName& entity_name, uint64_t& global_id, 26 | AuthCapsInfo& caps_info, CryptoKey& session_key, uint64_t *auid = NULL); 27 | int authorizer_session_crypto(); 28 | }; 29 | 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /include/rados/rados_types.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_RADOS_TYPES_HPP 2 | #define CEPH_RADOS_TYPES_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "rados_types.h" 10 | 11 | namespace librados { 12 | 13 | typedef uint64_t snap_t; 14 | 15 | enum { 16 | SNAP_HEAD = (uint64_t)(-2), 17 | SNAP_DIR = (uint64_t)(-1) 18 | }; 19 | 20 | struct clone_info_t { 21 | snap_t cloneid; 22 | std::vector snaps; // ascending 23 | std::vector< std::pair > overlap; // with next newest 24 | uint64_t size; 25 | clone_info_t() : cloneid(0), size(0) {} 26 | }; 27 | 28 | struct snap_set_t { 29 | std::vector clones; // ascending 30 | snap_t seq; // newest snapid seen by the object 31 | snap_set_t() : seq(0) {} 32 | }; 33 | 34 | /** 35 | * @var all_nspaces 36 | * Pass as nspace argument to IoCtx::set_namespace() 37 | * before calling nobjects_begin() to iterate 38 | * through all objects in all namespaces. 39 | */ 40 | const std::string all_nspaces(LIBRADOS_ALL_NSPACES); 41 | 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /auth/none/AuthNoneAuthorizeHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_AUTHNONEAUTHORIZEHANDLER_H 16 | #define CEPH_AUTHNONEAUTHORIZEHANDLER_H 17 | 18 | #include "../AuthAuthorizeHandler.h" 19 | 20 | class CephContext; 21 | 22 | struct AuthNoneAuthorizeHandler : public AuthAuthorizeHandler { 23 | bool verify_authorizer(CephContext *cct, KeyStore *keys, 24 | bufferlist& authorizer_data, bufferlist& authorizer_reply, 25 | EntityName& entity_name, uint64_t& global_id, 26 | AuthCapsInfo& caps_info, CryptoKey& session_key, uint64_t *auid=NULL); 27 | int authorizer_session_crypto(); 28 | }; 29 | 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /auth/unknown/AuthUnknownAuthorizeHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_AUTHUNKNOWNAUTHORIZEHANDLER_H 16 | #define CEPH_AUTHUNKNOWNAUTHORIZEHANDLER_H 17 | 18 | #include "../AuthAuthorizeHandler.h" 19 | 20 | class CephContext; 21 | 22 | struct AuthUnknownAuthorizeHandler : public AuthAuthorizeHandler { 23 | bool verify_authorizer(CephContext *cct, KeyStore *keys, 24 | bufferlist& authorizer_data, bufferlist& authorizer_reply, 25 | EntityName& entity_name, uint64_t& global_id, 26 | AuthCapsInfo& caps_info, CryptoKey& session_key, uint64_t *auid=NULL); 27 | int authorizer_session_crypto(); 28 | }; 29 | 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /messages/MGenericMessage.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MGENERICMESSAGE_H 17 | #define CEPH_MGENERICMESSAGE_H 18 | 19 | #include "msg/Message.h" 20 | 21 | class MGenericMessage : public Message { 22 | char tname[20]; 23 | //long pcid; 24 | 25 | public: 26 | MGenericMessage(int t=0) : Message(t) { 27 | snprintf(tname, sizeof(tname), "generic%d", get_type()); 28 | } 29 | 30 | //void set_pcid(long pcid) { this->pcid = pcid; } 31 | //long get_pcid() { return pcid; } 32 | 33 | const char *get_type_name() const { return tname; } 34 | 35 | void decode_payload() { } 36 | void encode_payload(uint64_t features) { } 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /auth/AuthClientHandler.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #include 17 | 18 | #include "AuthClientHandler.h" 19 | #include "KeyRing.h" 20 | 21 | #include "messages/MAuth.h" 22 | #include "messages/MAuthReply.h" 23 | 24 | #include "cephx/CephxClientHandler.h" 25 | #include "none/AuthNoneClientHandler.h" 26 | 27 | AuthClientHandler *get_auth_client_handler(CephContext *cct, int proto, 28 | RotatingKeyRing *rkeys) 29 | { 30 | switch (proto) { 31 | case CEPH_AUTH_CEPHX: 32 | return new CephxClientHandler(cct, rkeys); 33 | case CEPH_AUTH_NONE: 34 | return new AuthNoneClientHandler(cct, rkeys); 35 | default: 36 | return NULL; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /auth/AuthMethodList.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_AUTHMETHODLIST_H 16 | #define CEPH_AUTHMETHODLIST_H 17 | 18 | #include "include/int_types.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | class CephContext; 25 | 26 | class AuthMethodList { 27 | std::list<__u32> auth_supported; 28 | public: 29 | AuthMethodList(CephContext *cct, std::string str); 30 | 31 | bool is_supported_auth(int auth_type); 32 | int pick(const std::set<__u32>& supported); 33 | 34 | const std::list<__u32>& get_supported_set() const { 35 | return auth_supported; 36 | } 37 | 38 | void remove_supported_auth(int auth_type); 39 | }; 40 | 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /common/environment.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "common/environment.h" 16 | 17 | #include 18 | #include 19 | 20 | bool get_env_bool(const char *key) 21 | { 22 | const char *val = getenv(key); 23 | if (!val) 24 | return false; 25 | if (strcasecmp(val, "off") == 0) 26 | return false; 27 | if (strcasecmp(val, "no") == 0) 28 | return false; 29 | if (strcasecmp(val, "false") == 0) 30 | return false; 31 | if (strcasecmp(val, "0") == 0) 32 | return false; 33 | return true; 34 | } 35 | 36 | int get_env_int(const char *key) 37 | { 38 | const char *val = getenv(key); 39 | if (!val) 40 | return 0; 41 | int v = atoi(val); 42 | return v; 43 | } 44 | -------------------------------------------------------------------------------- /client/ClientSnapRealm.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #include "ClientSnapRealm.h" 5 | #include "common/Formatter.h" 6 | 7 | void SnapRealm::dump(Formatter *f) const 8 | { 9 | f->dump_stream("ino") << ino; 10 | f->dump_int("nref", nref); 11 | f->dump_stream("created") << created; 12 | f->dump_stream("seq") << seq; 13 | f->dump_stream("parent_ino") << parent; 14 | f->dump_stream("parent_since") << parent_since; 15 | 16 | f->open_array_section("prior_parent_snaps"); 17 | for (vector::const_iterator p = prior_parent_snaps.begin(); p != prior_parent_snaps.end(); ++p) 18 | f->dump_stream("snapid") << *p; 19 | f->close_section(); 20 | f->open_array_section("my_snaps"); 21 | for (vector::const_iterator p = my_snaps.begin(); p != my_snaps.end(); ++p) 22 | f->dump_stream("snapid") << *p; 23 | f->close_section(); 24 | 25 | f->open_array_section("children"); 26 | for (set::const_iterator p = pchildren.begin(); p != pchildren.end(); ++p) 27 | f->dump_stream("child") << (*p)->ino; 28 | f->close_section(); 29 | } 30 | -------------------------------------------------------------------------------- /crush/sample.txt: -------------------------------------------------------------------------------- 1 | 2 | # devices 3 | device 1 osd001 4 | device 2 osd002 5 | device 3 osd003 down # same as offload 1.0 6 | device 4 osd004 offload 0 # 0.0 -> normal, 1.0 -> failed 7 | device 5 osd005 offload 0.1 8 | device 6 osd006 offload 0.1 9 | 10 | # hierarchy 11 | type 0 osd # 'device' is actually the default for 0 12 | type 2 cab 13 | type 3 row 14 | type 10 pool 15 | 16 | cab root { 17 | id -1 # optional 18 | alg tree # required 19 | item osd001 20 | item osd002 weight 600 pos 1 21 | item osd003 weight 600 pos 0 22 | item osd004 weight 600 pos 3 23 | item osd005 weight 600 pos 4 24 | } 25 | 26 | # rules 27 | rule normal { 28 | # these are required. 29 | pool 0 30 | type replicated 31 | min_size 1 32 | max_size 4 33 | # need 1 or more of these. 34 | step take root 35 | step choose firstn 0 type osd 36 | step emit 37 | } 38 | 39 | rule { 40 | pool 1 41 | type erasure 42 | min_size 3 43 | max_size 6 44 | step take root 45 | step choose indep 0 type osd 46 | step emit 47 | } 48 | -------------------------------------------------------------------------------- /msg/async/net_handler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2014 UnitedStack 7 | * 8 | * Author: Haomai Wang 9 | * 10 | * This is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License version 2.1, as published by the Free Software 13 | * Foundation. See file COPYING. 14 | * 15 | */ 16 | 17 | #ifndef CEPH_COMMON_NET_UTILS_H 18 | #define CEPH_COMMON_NET_UTILS_H 19 | #include "common/config.h" 20 | 21 | namespace ceph { 22 | class NetHandler { 23 | private: 24 | int create_socket(int domain, bool reuse_addr=false); 25 | int generic_connect(const entity_addr_t& addr, bool nonblock); 26 | 27 | CephContext *cct; 28 | public: 29 | NetHandler(CephContext *c): cct(c) {} 30 | int set_nonblock(int sd); 31 | void set_socket_options(int sd); 32 | int connect(const entity_addr_t &addr); 33 | int nonblock_connect(const entity_addr_t &addr); 34 | }; 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /common/hex.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2008-2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "common/debug.h" 16 | #include "common/hex.h" 17 | 18 | #include 19 | #include 20 | 21 | void hex2str(const char *s, int len, char *buf, int dest_len) 22 | { 23 | int pos = 0; 24 | for (int i=0; i 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #include "common/Clock.h" 17 | #include "common/ceph_context.h" 18 | #include "common/config.h" 19 | #include "include/utime.h" 20 | 21 | #include 22 | 23 | utime_t ceph_clock_now(CephContext *cct) 24 | { 25 | #if defined(__linux__) 26 | struct timespec tp; 27 | clock_gettime(CLOCK_REALTIME, &tp); 28 | utime_t n(tp); 29 | #else 30 | struct timeval tv; 31 | gettimeofday(&tv, NULL); 32 | utime_t n(&tv); 33 | #endif 34 | if (cct) 35 | n += cct->_conf->clock_offset; 36 | return n; 37 | } 38 | 39 | time_t ceph_clock_gettime(CephContext *cct) 40 | { 41 | time_t ret = time(NULL); 42 | if (cct) 43 | ret += ((time_t)cct->_conf->clock_offset); 44 | return ret; 45 | } 46 | -------------------------------------------------------------------------------- /crush/CrushWrapper.i: -------------------------------------------------------------------------------- 1 | /* File : CrushWrapper.i */ 2 | %module CrushWrapper 3 | %{ 4 | #include "CrushWrapper.h" 5 | %} 6 | 7 | %include typemaps.i 8 | 9 | // This tells SWIG to treat 'int *data' as a special case 10 | %typemap(in) int *items { 11 | AV *tempav; 12 | I32 len; 13 | int i; 14 | SV **tv; 15 | // int view; 16 | 17 | 18 | //printf("typemap\n"); 19 | 20 | if (!SvROK($input)) 21 | croak("$input is not a reference."); 22 | if (SvTYPE(SvRV($input)) != SVt_PVAV) 23 | croak("$input is not an array."); 24 | 25 | tempav = (AV*)SvRV($input); 26 | len = av_len(tempav); 27 | //printf("typemap len: %i\n",len); 28 | $1 = (int *) malloc((len+1)*sizeof(int)); 29 | for (i = 0; i <= len; i++) { 30 | tv = av_fetch(tempav, i, 0); 31 | $1[i] = (int) SvIV(*tv); 32 | 33 | /* 34 | view = SvIV(*tv); 35 | printf("view: %d",view); 36 | printf("\n"); 37 | */ 38 | } 39 | } 40 | 41 | %apply int *items { int *weights }; 42 | %apply double *OUTPUT { double *min, double *max, double *avg }; 43 | 44 | /* Let's just grab the original header file here */ 45 | %include "CrushWrapper.h" 46 | 47 | %clear double *min, double *max, double *avg; 48 | -------------------------------------------------------------------------------- /include/error.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #include 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | #define SYSERROR() syserror("At %s:%d", __FILE__, __LINE__) 23 | 24 | #define ASSERT(c) \ 25 | ((c) || (exiterror("Assertion failed at %s:%d", __FILE__, __LINE__), 1)) 26 | 27 | /* print usage error message and exit */ 28 | extern void userror(const char *use, const char *fmt, ...); 29 | 30 | /* print system error message and exit */ 31 | extern void syserror(const char *fmt, ...); 32 | 33 | /* print error message and exit */ 34 | extern void exiterror(const char *fmt, ...); 35 | 36 | /* print error message */ 37 | extern void error(const char *fmt, ...); 38 | 39 | #ifdef __cplusplus 40 | } // extern "C" 41 | #endif 42 | -------------------------------------------------------------------------------- /common/io_priority.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2012 Red Hat 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_COMMON_IO_PRIORITY_H 16 | #define CEPH_COMMON_IO_PRIORITY_H 17 | 18 | #include 19 | 20 | extern pid_t ceph_gettid(); 21 | 22 | #ifndef IOPRIO_WHO_PROCESS 23 | # define IOPRIO_WHO_PROCESS 1 24 | #endif 25 | #ifndef IOPRIO_PRIO_VALUE 26 | # define IOPRIO_CLASS_SHIFT 13 27 | # define IOPRIO_PRIO_VALUE(class, data) \ 28 | (((class) << IOPRIO_CLASS_SHIFT) | (data)) 29 | #endif 30 | #ifndef IOPRIO_CLASS_RT 31 | # define IOPRIO_CLASS_RT 1 32 | #endif 33 | #ifndef IOPRIO_CLASS_BE 34 | # define IOPRIO_CLASS_BE 2 35 | #endif 36 | #ifndef IOPRIO_CLASS_IDLE 37 | # define IOPRIO_CLASS_IDLE 3 38 | #endif 39 | 40 | extern int ceph_ioprio_set(int whence, int who, int ioprio); 41 | 42 | extern int ceph_ioprio_string_to_class(const std::string& s); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /include/on_exit.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_ON_EXIT_H 2 | #define CEPH_ON_EXIT_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | * Create a static instance at the file level to get callbacks called when the 10 | * process exits via main() or exit(). 11 | */ 12 | 13 | class OnExitManager { 14 | public: 15 | typedef void (*callback_t)(void *arg); 16 | 17 | OnExitManager() { 18 | int ret = pthread_mutex_init(&lock_, NULL); 19 | assert(ret == 0); 20 | } 21 | 22 | ~OnExitManager() { 23 | pthread_mutex_lock(&lock_); 24 | std::vector::iterator it; 25 | for (it = funcs_.begin(); it != funcs_.end(); it++) { 26 | it->func(it->arg); 27 | } 28 | funcs_.clear(); 29 | pthread_mutex_unlock(&lock_); 30 | } 31 | 32 | void add_callback(callback_t func, void *arg) { 33 | pthread_mutex_lock(&lock_); 34 | struct cb callback = { func, arg }; 35 | funcs_.push_back(callback); 36 | pthread_mutex_unlock(&lock_); 37 | } 38 | 39 | private: 40 | struct cb { 41 | callback_t func; 42 | void *arg; 43 | }; 44 | 45 | std::vector funcs_; 46 | pthread_mutex_t lock_; 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /include/str_list.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_STRLIST_H 2 | #define CEPH_STRLIST_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | extern void get_str_list(const std::string& str, 11 | std::list& str_list); 12 | extern void get_str_list(const std::string& str, 13 | const char *delims, 14 | std::list& str_list); 15 | extern void get_str_vec(const std::string& str, 16 | std::vector& str_vec); 17 | extern void get_str_vec(const std::string& str, 18 | const char *delims, 19 | std::vector& str_vec); 20 | extern void get_str_set(const std::string& str, 21 | std::set& str_list); 22 | extern void get_str_set(const std::string& str, 23 | const char *delims, 24 | std::set& str_list); 25 | 26 | inline std::string str_join(const std::vector& v, std::string sep) 27 | { 28 | if (v.empty()) 29 | return std::string(); 30 | std::vector::const_iterator i = v.begin(); 31 | std::string r = *i; 32 | for (++i; i != v.end(); ++i) { 33 | r += sep; 34 | r += *i; 35 | } 36 | return r; 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /auth/unknown/AuthUnknownAuthorizeHandler.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2009-2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "AuthUnknownAuthorizeHandler.h" 16 | #include "common/debug.h" 17 | 18 | #define dout_subsys ceph_subsys_auth 19 | 20 | bool AuthUnknownAuthorizeHandler::verify_authorizer(CephContext *cct, KeyStore *keys, 21 | bufferlist& authorizer_data, bufferlist& authorizer_reply, 22 | EntityName& entity_name, uint64_t& global_id, AuthCapsInfo& caps_info, CryptoKey& session_key, 23 | uint64_t *auid) 24 | { 25 | // For unknown authorizers, there's nothing to verify. They're "OK" by definition. PLR 26 | 27 | return true; 28 | } 29 | 30 | // Return type of crypto used for this session's data; for unknown, no crypt used 31 | 32 | int AuthUnknownAuthorizeHandler::authorizer_session_crypto() 33 | { 34 | return SESSION_CRYPTO_NONE; 35 | } 36 | -------------------------------------------------------------------------------- /messages/MPGStatsAck.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MPGSTATSACK_H 16 | #define CEPH_MPGSTATSACK_H 17 | 18 | #include "osd/osd_types.h" 19 | 20 | class MPGStatsAck : public Message { 21 | public: 22 | map > pg_stat; 23 | 24 | MPGStatsAck() : Message(MSG_PGSTATSACK) {} 25 | 26 | private: 27 | ~MPGStatsAck() {} 28 | 29 | public: 30 | const char *get_type_name() const { return "pg_stats_ack"; } 31 | void print(ostream& out) const { 32 | out << "pg_stats_ack(" << pg_stat.size() << " pgs tid " << get_tid() << ")"; 33 | } 34 | 35 | void encode_payload(uint64_t features) { 36 | ::encode(pg_stat, payload); 37 | } 38 | void decode_payload() { 39 | bufferlist::iterator p = payload.begin(); 40 | ::decode(pg_stat, p); 41 | } 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /msg/simple/Accepter.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MSG_ACCEPTER_H 16 | #define CEPH_MSG_ACCEPTER_H 17 | 18 | #include "msg/msg_types.h" 19 | #include "common/Thread.h" 20 | 21 | class SimpleMessenger; 22 | 23 | /** 24 | * If the SimpleMessenger binds to a specific address, the Accepter runs 25 | * and listens for incoming connections. 26 | */ 27 | class Accepter : public Thread { 28 | SimpleMessenger *msgr; 29 | bool done; 30 | int listen_sd; 31 | uint64_t nonce; 32 | 33 | public: 34 | Accepter(SimpleMessenger *r, uint64_t n) : msgr(r), done(false), listen_sd(-1), nonce(n) {} 35 | 36 | void *entry(); 37 | void stop(); 38 | int bind(const entity_addr_t &bind_addr, const set& avoid_ports); 39 | int rebind(const set& avoid_port); 40 | int start(); 41 | }; 42 | 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /include/blobhash.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | /* 3 | * Ceph - scalable distributed file system 4 | * 5 | * Copyright (C) 2004-2006 Sage Weil 6 | * 7 | * This is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License version 2.1, as published by the Free Software 10 | * Foundation. See file COPYING. 11 | * 12 | */ 13 | 14 | #ifndef CEPH_BLOBHASH_H 15 | #define CEPH_BLOBHASH_H 16 | 17 | #include "hash.h" 18 | 19 | /* 20 | - this is to make some of the STL types work with 64 bit values, string hash keys, etc. 21 | - added when i was using an old STL.. maybe try taking these out and see if things 22 | compile now? 23 | */ 24 | 25 | class blobhash { 26 | public: 27 | uint32_t operator()(const char *p, unsigned len) { 28 | static rjhash H; 29 | uint32_t acc = 0; 30 | while (len >= sizeof(acc)) { 31 | acc ^= *(uint32_t*)p; 32 | p += sizeof(uint32_t); 33 | len -= sizeof(uint32_t); 34 | } 35 | int sh = 0; 36 | while (len) { 37 | acc ^= (uint32_t)*p << sh; 38 | sh += 8; 39 | len--; 40 | p++; 41 | } 42 | return H(acc); 43 | } 44 | }; 45 | 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /messages/MMonGlobalID.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MMONGLOBALID_H 16 | #define CEPH_MMONGLOBALID_H 17 | 18 | #include "messages/PaxosServiceMessage.h" 19 | 20 | struct MMonGlobalID : public PaxosServiceMessage { 21 | uint64_t old_max_id; 22 | MMonGlobalID() : PaxosServiceMessage(MSG_MON_GLOBAL_ID, 0), old_max_id(0) { } 23 | private: 24 | ~MMonGlobalID() {} 25 | 26 | public: 27 | const char *get_type_name() const { return "global_id"; } 28 | void print(ostream& out) const { 29 | out << "global_id (" << old_max_id << ")"; 30 | } 31 | 32 | void decode_payload() { 33 | bufferlist::iterator p = payload.begin(); 34 | paxos_decode(p); 35 | ::decode(old_max_id, p); 36 | } 37 | void encode_payload(uint64_t features) { 38 | paxos_encode(); 39 | ::encode(old_max_id, payload); 40 | } 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Ceph - scalable distributed file system 3 | * 4 | * Copyright (C) 2011 Stanislav Sedov 5 | * 6 | * This is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License version 2.1, as published by the Free Software 9 | * Foundation. See file COPYING. 10 | */ 11 | 12 | #ifndef CEPH_COMPAT_H 13 | #define CEPH_COMPAT_H 14 | 15 | #if defined(__FreeBSD__) 16 | #define ENODATA 61 17 | #define MSG_MORE 0 18 | #endif /* !__FreeBSD__ */ 19 | 20 | #ifndef TEMP_FAILURE_RETRY 21 | #define TEMP_FAILURE_RETRY(expression) ({ \ 22 | typeof(expression) __result; \ 23 | do { \ 24 | __result = (expression); \ 25 | } while (__result == -1 && errno == EINTR); \ 26 | __result; }) 27 | #endif 28 | 29 | #ifdef __cplusplus 30 | # define VOID_TEMP_FAILURE_RETRY(expression) \ 31 | static_cast(TEMP_FAILURE_RETRY(expression)) 32 | #else 33 | # define VOID_TEMP_FAILURE_RETRY(expression) \ 34 | do { (void)TEMP_FAILURE_RETRY(expression); } while (0) 35 | #endif 36 | 37 | #if defined(__FreeBSD__) || defined(__APPLE__) 38 | #define lseek64(fd, offset, whence) lseek(fd, offset, whence) 39 | #endif 40 | 41 | #endif /* !CEPH_COMPAT_H */ 42 | -------------------------------------------------------------------------------- /messages/MMDSFindIno.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MDSFINDINO_H 16 | #define CEPH_MDSFINDINO_H 17 | 18 | #include "msg/Message.h" 19 | #include "include/filepath.h" 20 | 21 | struct MMDSFindIno : public Message { 22 | ceph_tid_t tid; 23 | inodeno_t ino; 24 | 25 | MMDSFindIno() : Message(MSG_MDS_FINDINO) {} 26 | MMDSFindIno(ceph_tid_t t, inodeno_t i) : Message(MSG_MDS_FINDINO), tid(t), ino(i) {} 27 | 28 | const char *get_type_name() const { return "findino"; } 29 | void print(ostream &out) const { 30 | out << "findino(" << tid << " " << ino << ")"; 31 | } 32 | 33 | void encode_payload(uint64_t features) { 34 | ::encode(tid, payload); 35 | ::encode(ino, payload); 36 | } 37 | void decode_payload() { 38 | bufferlist::iterator p = payload.begin(); 39 | ::decode(tid, p); 40 | ::decode(ino, p); 41 | } 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /common/PrebufferedStreambuf.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_COMMON_PREBUFFEREDSTREAMBUF_H 2 | #define CEPH_COMMON_PREBUFFEREDSTREAMBUF_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /** 9 | * streambuf using existing buffer, overflowing into a std::string 10 | * 11 | * A simple streambuf that uses a preallocated buffer for small 12 | * strings, and overflows into a std::string when necessary. If the 13 | * preallocated buffer size is chosen well, we can optimize for the 14 | * common case and overflow to a slower heap-allocated buffer when 15 | * necessary. 16 | */ 17 | class PrebufferedStreambuf 18 | : public std::basic_streambuf::traits_type> 19 | { 20 | char *m_buf; 21 | size_t m_buf_len; 22 | std::string m_overflow; 23 | 24 | typedef std::char_traits traits_ty; 25 | typedef traits_ty::int_type int_type; 26 | typedef traits_ty::pos_type pos_type; 27 | typedef traits_ty::off_type off_type; 28 | 29 | public: 30 | PrebufferedStreambuf(char *buf, size_t len); 31 | 32 | // called when the buffer fills up 33 | int_type overflow(int_type c); 34 | 35 | // called when we read and need more data 36 | int_type underflow(); 37 | 38 | /// return a string copy (inefficiently) 39 | std::string get_str() const; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /include/bitmapper.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_BITMAPPER_H 16 | #define CEPH_BITMAPPER_H 17 | 18 | class bitmapper { 19 | char *_data; 20 | int _len; 21 | 22 | public: 23 | bitmapper() : _data(0), _len(0) { } 24 | bitmapper(char *data, int len) : _data(data), _len(len) { } 25 | 26 | void set_data(char *data, int len) { _data = data; _len = len; } 27 | 28 | int bytes() const { return _len; } 29 | int bits() const { return _len * 8; } 30 | 31 | bool operator[](int b) const { 32 | return get(b); 33 | } 34 | bool get(int b) const { 35 | return _data[b >> 3] & (1 << (b&7)); 36 | } 37 | void set(int b) { 38 | _data[b >> 3] |= 1 << (b&7); 39 | } 40 | void clear(int b) { 41 | _data[b >> 3] &= ~(1 << (b&7)); 42 | } 43 | void toggle(int b) { 44 | _data[b >> 3] ^= 1 << (b&7); 45 | } 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /messages/MClientQuota.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_MCLIENTQUOTA_H 2 | #define CEPH_MCLIENTQUOTA_H 3 | 4 | #include "msg/Message.h" 5 | 6 | struct MClientQuota : public Message { 7 | inodeno_t ino; 8 | nest_info_t rstat; 9 | quota_info_t quota; 10 | 11 | MClientQuota() : 12 | Message(CEPH_MSG_CLIENT_QUOTA), 13 | ino(0) 14 | { 15 | memset(&rstat, 0, sizeof(rstat)); 16 | memset("a, 0, sizeof(quota)); 17 | } 18 | private: 19 | ~MClientQuota() {} 20 | 21 | public: 22 | const char *get_type_name() const { return "client_quota"; } 23 | void print(ostream& out) const { 24 | out << "client_quota("; 25 | out << " [" << ino << "] "; 26 | out << rstat; 27 | out << ")"; 28 | } 29 | 30 | void encode_payload(uint64_t features) { 31 | ::encode(ino, payload); 32 | ::encode(rstat.rctime, payload); 33 | ::encode(rstat.rbytes, payload); 34 | ::encode(rstat.rfiles, payload); 35 | ::encode(rstat.rsubdirs, payload); 36 | ::encode(quota, payload); 37 | } 38 | void decode_payload() { 39 | bufferlist::iterator p = payload.begin(); 40 | ::decode(ino, p); 41 | ::decode(rstat.rctime, p); 42 | ::decode(rstat.rbytes, p); 43 | ::decode(rstat.rfiles, p); 44 | ::decode(rstat.rsubdirs, p); 45 | ::decode(quota, p); 46 | assert(p.end()); 47 | } 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /common/crc32c.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #include "include/crc32c.h" 5 | 6 | //by ketor #include "arch/probe.h" 7 | //#include "arch/intel.h" 8 | #include "common/sctp_crc32.h" 9 | //by ketor #include "common/crc32c_intel_baseline.h" 10 | //#include "common/crc32c_intel_fast.h" 11 | 12 | /* 13 | * choose best implementation based on the CPU architecture. 14 | */ 15 | ceph_crc32c_func_t ceph_choose_crc32(void) 16 | { 17 | // make sure we've probed cpu features; this might depend on the 18 | // link order of this file relative to arch/probe.cc. 19 | //by ketor ceph_arch_probe(); 20 | 21 | // if the CPU supports it, *and* the fast version is compiled in, 22 | // use that. 23 | //by ketor if (ceph_arch_intel_sse42 && ceph_crc32c_intel_fast_exists()) { 24 | // return ceph_crc32c_intel_fast; 25 | // } 26 | 27 | // default 28 | return ceph_crc32c_sctp; 29 | } 30 | 31 | /* 32 | * static global 33 | * 34 | * This is a bit of a no-no for shared libraries, but we don't care. 35 | * It is effectively constant for the executing process as the value 36 | * depends on the CPU architecture. 37 | * 38 | * We initialize it during program init using the magic of C++. 39 | */ 40 | ceph_crc32c_func_t ceph_crc32c_func = ceph_choose_crc32(); 41 | 42 | -------------------------------------------------------------------------------- /include/uuid.h: -------------------------------------------------------------------------------- 1 | #ifndef _CEPH_UUID_H 2 | #define _CEPH_UUID_H 3 | 4 | /* 5 | * Thin C++ wrapper around libuuid. 6 | */ 7 | 8 | #include "encoding.h" 9 | #include 10 | 11 | extern "C" { 12 | #include 13 | #include 14 | } 15 | 16 | struct uuid_d { 17 | uuid_t uuid; 18 | 19 | uuid_d() { 20 | memset(&uuid, 0, sizeof(uuid)); 21 | } 22 | 23 | bool is_zero() const { 24 | return uuid_is_null(uuid); 25 | } 26 | 27 | void generate_random() { 28 | uuid_generate(uuid); 29 | } 30 | 31 | bool parse(const char *s) { 32 | return uuid_parse(s, uuid) == 0; 33 | } 34 | void print(char *s) { 35 | return uuid_unparse(uuid, s); 36 | } 37 | 38 | void encode(bufferlist& bl) const { 39 | ::encode_raw(uuid, bl); 40 | } 41 | void decode(bufferlist::iterator& p) const { 42 | ::decode_raw(uuid, p); 43 | } 44 | }; 45 | WRITE_CLASS_ENCODER(uuid_d) 46 | 47 | inline std::ostream& operator<<(std::ostream& out, const uuid_d& u) { 48 | char b[37]; 49 | uuid_unparse(u.uuid, b); 50 | return out << b; 51 | } 52 | 53 | inline bool operator==(const uuid_d& l, const uuid_d& r) { 54 | return uuid_compare(l.uuid, r.uuid) == 0; 55 | } 56 | inline bool operator!=(const uuid_d& l, const uuid_d& r) { 57 | return uuid_compare(l.uuid, r.uuid) != 0; 58 | } 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /messages/MStatfsReply.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MSTATFSREPLY_H 17 | #define CEPH_MSTATFSREPLY_H 18 | 19 | class MStatfsReply : public Message { 20 | public: 21 | struct ceph_mon_statfs_reply h; 22 | 23 | MStatfsReply() : Message(CEPH_MSG_STATFS_REPLY) {} 24 | MStatfsReply(uuid_d &f, ceph_tid_t t, epoch_t epoch) : Message(CEPH_MSG_STATFS_REPLY) { 25 | memcpy(&h.fsid, f.uuid, sizeof(h.fsid)); 26 | header.tid = t; 27 | h.version = epoch; 28 | } 29 | 30 | const char *get_type_name() const { return "statfs_reply"; } 31 | void print(ostream& out) const { 32 | out << "statfs_reply(" << header.tid << ")"; 33 | } 34 | 35 | void encode_payload(uint64_t features) { 36 | ::encode(h, payload); 37 | } 38 | void decode_payload() { 39 | bufferlist::iterator p = payload.begin(); 40 | ::decode(h, p); 41 | } 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /messages/MExportCapsAck.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MEXPORTCAPSACK_H 17 | #define CEPH_MEXPORTCAPSACK_H 18 | 19 | #include "msg/Message.h" 20 | 21 | 22 | class MExportCapsAck : public Message { 23 | public: 24 | inodeno_t ino; 25 | 26 | MExportCapsAck() : 27 | Message(MSG_MDS_EXPORTCAPSACK) {} 28 | MExportCapsAck(inodeno_t i) : 29 | Message(MSG_MDS_EXPORTCAPSACK), ino(i) {} 30 | private: 31 | ~MExportCapsAck() {} 32 | 33 | public: 34 | const char *get_type_name() const { return "export_caps_ack"; } 35 | void print(ostream& o) const { 36 | o << "export_caps_ack(" << ino << ")"; 37 | } 38 | 39 | virtual void encode_payload(uint64_t features) { 40 | ::encode(ino, payload); 41 | } 42 | virtual void decode_payload() { 43 | bufferlist::iterator p = payload.begin(); 44 | ::decode(ino, p); 45 | } 46 | 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /messages/MMDSFindInoReply.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MDSFINDINOREPLY_H 16 | #define CEPH_MDSFINDINOREPLY_H 17 | 18 | #include "msg/Message.h" 19 | #include "include/filepath.h" 20 | 21 | struct MMDSFindInoReply : public Message { 22 | ceph_tid_t tid; 23 | filepath path; 24 | 25 | MMDSFindInoReply() : Message(MSG_MDS_FINDINOREPLY) {} 26 | MMDSFindInoReply(ceph_tid_t t) : Message(MSG_MDS_FINDINOREPLY), tid(t) {} 27 | 28 | const char *get_type_name() const { return "findinoreply"; } 29 | void print(ostream &out) const { 30 | out << "findinoreply(" << tid << " " << path << ")"; 31 | } 32 | 33 | void encode_payload(uint64_t features) { 34 | ::encode(tid, payload); 35 | ::encode(path, payload); 36 | } 37 | void decode_payload() { 38 | bufferlist::iterator p = payload.begin(); 39 | ::decode(tid, p); 40 | ::decode(path, p); 41 | } 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /myapi/myapi.c: -------------------------------------------------------------------------------- 1 | 2 | #define _UNICODE 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | BOOL MyConvertSecurityDescriptorToStringSecurityDescriptor( 16 | PSECURITY_DESCRIPTOR SecurityDescriptor, 17 | DWORD RequestedStringSDRevision, 18 | SECURITY_INFORMATION SecurityInformation, 19 | LPTSTR *StringSecurityDescriptor, 20 | PULONG StringSecurityDescriptorLen 21 | ) 22 | { 23 | return ConvertSecurityDescriptorToStringSecurityDescriptor( 24 | SecurityDescriptor, 25 | SDDL_REVISION_1, 26 | SecurityInformation, 27 | StringSecurityDescriptor, 28 | StringSecurityDescriptorLen); 29 | } 30 | 31 | BOOL MyConvertStringSecurityDescriptorToSecurityDescriptor( 32 | LPCTSTR StringSecurityDescriptor, 33 | DWORD StringSDRevision, 34 | PSECURITY_DESCRIPTOR *SecurityDescriptor, 35 | PULONG SecurityDescriptorSize 36 | ) 37 | { 38 | return ConvertStringSecurityDescriptorToSecurityDescriptor( 39 | StringSecurityDescriptor, 40 | SDDL_REVISION_1, 41 | SecurityDescriptor, 42 | SecurityDescriptorSize); 43 | } 44 | 45 | BOOL WINAPI DllMain( 46 | HINSTANCE Instance, 47 | DWORD Reason, 48 | LPVOID Reserved) 49 | { 50 | return TRUE; 51 | } 52 | -------------------------------------------------------------------------------- /auth/cephx/CephxSessionHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #include "../AuthSessionHandler.h" 17 | #include "../Auth.h" 18 | 19 | class CephContext; 20 | 21 | class CephxSessionHandler : public AuthSessionHandler { 22 | uint64_t features; 23 | 24 | public: 25 | CephxSessionHandler(CephContext *cct_, CryptoKey session_key, uint64_t features) 26 | : AuthSessionHandler(cct_, CEPH_AUTH_CEPHX, session_key), 27 | features(features) {} 28 | ~CephxSessionHandler() {} 29 | 30 | bool no_security() { 31 | return false; 32 | } 33 | 34 | int sign_message(Message *m); 35 | 36 | int check_message_signature(Message *m) ; 37 | 38 | // Cephx does not currently encrypt messages, so just return 0 if called. PLR 39 | 40 | int encrypt_message(Message *m) { 41 | return 0; 42 | } 43 | 44 | int decrypt_message(Message *m) { 45 | return 0; 46 | } 47 | 48 | }; 49 | 50 | -------------------------------------------------------------------------------- /common/code_environment.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_COMMON_CODE_ENVIRONMENT_H 16 | #define CEPH_COMMON_CODE_ENVIRONMENT_H 17 | 18 | enum code_environment_t { 19 | CODE_ENVIRONMENT_UTILITY = 0, 20 | CODE_ENVIRONMENT_DAEMON = 1, 21 | CODE_ENVIRONMENT_LIBRARY = 2, 22 | CODE_ENVIRONMENT_UTILITY_NODOUT = 3, 23 | }; 24 | 25 | #ifdef __cplusplus 26 | #include 27 | #include 28 | 29 | extern "C" code_environment_t g_code_env; 30 | extern "C" const char *code_environment_to_str(enum code_environment_t e); 31 | std::ostream &operator<<(std::ostream &oss, enum code_environment_t e); 32 | extern "C" int get_process_name(char *buf, int len); 33 | std::string get_process_name_cpp(); 34 | 35 | #else 36 | 37 | extern code_environment_t g_code_env; 38 | const char *code_environment_to_str(enum code_environment_t e); 39 | extern int get_process_name(char *buf, int len); 40 | 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /auth/cephx/CephxServiceHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_CEPHXSERVICEHANDLER_H 16 | #define CEPH_CEPHXSERVICEHANDLER_H 17 | 18 | #include "../AuthServiceHandler.h" 19 | #include "../Auth.h" 20 | 21 | class KeyServer; 22 | 23 | class CephxServiceHandler : public AuthServiceHandler { 24 | KeyServer *key_server; 25 | uint64_t server_challenge; 26 | 27 | public: 28 | CephxServiceHandler(CephContext *cct_, KeyServer *ks) 29 | : AuthServiceHandler(cct_), key_server(ks), server_challenge(0) {} 30 | ~CephxServiceHandler() {} 31 | 32 | int start_session(EntityName& name, bufferlist::iterator& indata, bufferlist& result_bl, AuthCapsInfo& caps); 33 | int handle_request(bufferlist::iterator& indata, bufferlist& result_bl, uint64_t& global_id, AuthCapsInfo& caps, uint64_t *auid = NULL); 34 | void build_cephx_response_header(int request_type, int status, bufferlist& bl); 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /msg/async/EventEpoll.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2014 UnitedStack 7 | * 8 | * Author: Haomai Wang 9 | * 10 | * This is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU Lesser General Public 12 | * License version 2.1, as published by the Free Software 13 | * Foundation. See file COPYING. 14 | * 15 | */ 16 | 17 | #ifndef CEPH_MSG_EVENTEPOLL_H 18 | #define CEPH_MSG_EVENTEPOLL_H 19 | 20 | #include 21 | #include 22 | 23 | #include "Event.h" 24 | 25 | class EpollDriver : public EventDriver { 26 | int epfd; 27 | struct epoll_event *events; 28 | CephContext *cct; 29 | int size; 30 | 31 | public: 32 | EpollDriver(CephContext *c): epfd(-1), events(NULL), cct(c) {} 33 | virtual ~EpollDriver() { 34 | if (epfd != -1) 35 | close(epfd); 36 | 37 | if (events) 38 | free(events); 39 | } 40 | 41 | int init(int nevent); 42 | int add_event(int fd, int cur_mask, int add_mask); 43 | void del_event(int fd, int cur_mask, int del_mask); 44 | int resize_events(int newsize); 45 | int event_wait(vector &fired_events, struct timeval *tp); 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /msg/simple/PipeConnection.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2014 Red Hat 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MSG_PIPECONNECTION_H 16 | #define CEPH_MSG_PIPECONNECTION_H 17 | 18 | #include "msg/Connection.h" 19 | 20 | class Pipe; 21 | 22 | struct PipeConnection : public Connection { 23 | Pipe* pipe; 24 | 25 | friend class boost::intrusive_ptr; 26 | friend class Pipe; 27 | 28 | public: 29 | 30 | PipeConnection(CephContext *cct, Messenger *m) 31 | : Connection(cct, m), 32 | pipe(NULL) { } 33 | 34 | ~PipeConnection(); 35 | 36 | Pipe* get_pipe(); 37 | 38 | bool try_get_pipe(Pipe** p); 39 | 40 | bool clear_pipe(Pipe* old_p); 41 | 42 | void reset_pipe(Pipe* p); 43 | 44 | bool is_connected(); 45 | 46 | int send_message(Message *m); 47 | void send_keepalive(); 48 | void mark_down(); 49 | void mark_disposable(); 50 | 51 | }; /* PipeConnection */ 52 | 53 | typedef boost::intrusive_ptr PipeConnectionRef; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /log/Entry.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #ifndef __CEPH_LOG_ENTRY_H 5 | #define __CEPH_LOG_ENTRY_H 6 | 7 | #include "include/utime.h" 8 | #include "common/PrebufferedStreambuf.h" 9 | #include 10 | #include 11 | 12 | #define CEPH_LOG_ENTRY_PREALLOC 80 13 | 14 | namespace ceph { 15 | namespace log { 16 | 17 | struct Entry { 18 | utime_t m_stamp; 19 | pthread_t m_thread; 20 | short m_prio, m_subsys; 21 | Entry *m_next; 22 | 23 | char m_static_buf[CEPH_LOG_ENTRY_PREALLOC]; 24 | PrebufferedStreambuf m_streambuf; 25 | 26 | Entry() 27 | : m_thread(0), m_prio(0), m_subsys(0), 28 | m_next(NULL), 29 | m_streambuf(m_static_buf, sizeof(m_static_buf)) 30 | { 31 | ; 32 | } 33 | Entry(utime_t s, pthread_t t, short pr, short sub, 34 | const char *msg = NULL) 35 | : m_stamp(s), m_thread(t), m_prio(pr), m_subsys(sub), 36 | m_next(NULL), 37 | m_streambuf(m_static_buf, sizeof(m_static_buf)) 38 | { 39 | if (msg) { 40 | ostream os(&m_streambuf); 41 | os << msg; 42 | } 43 | } 44 | 45 | void set_str(const std::string &s) { 46 | ostream os(&m_streambuf); 47 | os << s; 48 | } 49 | 50 | std::string get_str() const { 51 | return m_streambuf.get_str(); 52 | } 53 | }; 54 | 55 | } 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /auth/none/AuthNoneServiceHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_AUTHNONESERVICEHANDLER_H 16 | #define CEPH_AUTHNONESERVICEHANDLER_H 17 | 18 | #include "../AuthServiceHandler.h" 19 | #include "../Auth.h" 20 | 21 | class CephContext; 22 | 23 | class AuthNoneServiceHandler : public AuthServiceHandler { 24 | public: 25 | AuthNoneServiceHandler(CephContext *cct_) 26 | : AuthServiceHandler(cct_) {} 27 | ~AuthNoneServiceHandler() {} 28 | 29 | int start_session(EntityName& name, bufferlist::iterator& indata, bufferlist& result_bl, AuthCapsInfo& caps) { 30 | entity_name = name; 31 | caps.allow_all = true; 32 | return CEPH_AUTH_NONE; 33 | } 34 | int handle_request(bufferlist::iterator& indata, bufferlist& result_bl, uint64_t& global_id, AuthCapsInfo& caps, uint64_t *auid = NULL) { 35 | return 0; 36 | } 37 | void build_cephx_response_header(int request_type, int status, bufferlist& bl) { } 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /messages/MOSDAlive.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | 17 | #ifndef CEPH_MOSDALIVE_H 18 | #define CEPH_MOSDALIVE_H 19 | 20 | #include "messages/PaxosServiceMessage.h" 21 | 22 | class MOSDAlive : public PaxosServiceMessage { 23 | public: 24 | epoch_t want; 25 | 26 | MOSDAlive(epoch_t h, epoch_t w) : PaxosServiceMessage(MSG_OSD_ALIVE, h), want(w) { } 27 | MOSDAlive() : PaxosServiceMessage(MSG_OSD_ALIVE, 0) {} 28 | private: 29 | ~MOSDAlive() {} 30 | 31 | public: 32 | void encode_payload(uint64_t features) { 33 | paxos_encode(); 34 | ::encode(want, payload); 35 | } 36 | void decode_payload() { 37 | bufferlist::iterator p = payload.begin(); 38 | paxos_decode(p); 39 | ::decode(want, p); 40 | } 41 | 42 | const char *get_type_name() const { return "osd_alive"; } 43 | void print(ostream &out) const { 44 | out << "osd_alive(want up_thru " << want << " have " << version << ")"; 45 | } 46 | 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /auth/unknown/AuthUnknownServiceHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_AUTHUNKNOWNSERVICEHANDLER_H 16 | #define CEPH_AUTHUNKNOWNSERVICEHANDLER_H 17 | 18 | #include "../AuthServiceHandler.h" 19 | #include "../Auth.h" 20 | 21 | class CephContext; 22 | 23 | class AuthUnknownServiceHandler : public AuthServiceHandler { 24 | public: 25 | AuthUnknownServiceHandler(CephContext *cct_) 26 | : AuthServiceHandler(cct_) {} 27 | ~AuthUnknownServiceHandler() {} 28 | 29 | int start_session(EntityName& name, bufferlist::iterator& indata, bufferlist& result_bl, AuthCapsInfo& caps) { 30 | return CEPH_AUTH_UNKNOWN; 31 | } 32 | int handle_request(bufferlist::iterator& indata, bufferlist& result_bl, uint64_t& global_id, AuthCapsInfo& caps, uint64_t *auid = NULL) { 33 | assert(0); // shouldn't get called 34 | return 0; 35 | } 36 | void build_cephx_response_header(int request_type, int status, bufferlist& bl) { } 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /common/Thread.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_THREAD_H 17 | #define CEPH_THREAD_H 18 | 19 | #include 20 | #include 21 | 22 | class Thread { 23 | private: 24 | pthread_t thread_id; 25 | pid_t pid; 26 | int ioprio_class, ioprio_priority; 27 | 28 | void *entry_wrapper(); 29 | 30 | public: 31 | Thread(const Thread& other); 32 | const Thread& operator=(const Thread& other); 33 | 34 | Thread(); 35 | virtual ~Thread(); 36 | 37 | protected: 38 | virtual void *entry() = 0; 39 | 40 | private: 41 | static void *_entry_func(void *arg); 42 | 43 | public: 44 | const pthread_t &get_thread_id(); 45 | pid_t get_pid() const { return pid; } 46 | bool is_started() const; 47 | bool am_self(); 48 | int kill(int signal); 49 | int try_create(size_t stacksize); 50 | void create(size_t stacksize = 0); 51 | int join(void **prval = 0); 52 | int detach(); 53 | int set_ioprio(int cls, int prio); 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /messages/MMDSOpenIno.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MDSOPENINO_H 16 | #define CEPH_MDSOPENINO_H 17 | 18 | #include "msg/Message.h" 19 | 20 | struct MMDSOpenIno : public Message { 21 | inodeno_t ino; 22 | vector ancestors; 23 | 24 | MMDSOpenIno() : Message(MSG_MDS_OPENINO) {} 25 | MMDSOpenIno(ceph_tid_t t, inodeno_t i, vector& a) : 26 | Message(MSG_MDS_OPENINO), ino(i), ancestors(a) { 27 | header.tid = t; 28 | } 29 | 30 | const char *get_type_name() const { return "openino"; } 31 | void print(ostream &out) const { 32 | out << "openino(" << header.tid << " " << ino << " " << ancestors << ")"; 33 | } 34 | 35 | void encode_payload(uint64_t features) { 36 | ::encode(ino, payload); 37 | ::encode(ancestors, payload); 38 | } 39 | void decode_payload() { 40 | bufferlist::iterator p = payload.begin(); 41 | ::decode(ino, p); 42 | ::decode(ancestors, p); 43 | } 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /messages/MExportCaps.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MEXPORTCAPS_H 17 | #define CEPH_MEXPORTCAPS_H 18 | 19 | #include "msg/Message.h" 20 | 21 | 22 | class MExportCaps : public Message { 23 | public: 24 | inodeno_t ino; 25 | bufferlist cap_bl; 26 | map client_map; 27 | 28 | MExportCaps() : 29 | Message(MSG_MDS_EXPORTCAPS) {} 30 | private: 31 | ~MExportCaps() {} 32 | 33 | public: 34 | const char *get_type_name() const { return "export_caps"; } 35 | void print(ostream& o) const { 36 | o << "export_caps(" << ino << ")"; 37 | } 38 | 39 | void encode_payload(uint64_t features) { 40 | ::encode(ino, payload); 41 | ::encode(cap_bl, payload); 42 | ::encode(client_map, payload); 43 | } 44 | void decode_payload() { 45 | bufferlist::iterator p = payload.begin(); 46 | ::decode(ino, p); 47 | ::decode(cap_bl, p); 48 | ::decode(client_map, p); 49 | } 50 | 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /messages/MExportDirNotifyAck.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MEXPORTDIRNOTIFYACK_H 16 | #define CEPH_MEXPORTDIRNOTIFYACK_H 17 | 18 | #include "msg/Message.h" 19 | 20 | class MExportDirNotifyAck : public Message { 21 | dirfrag_t dirfrag; 22 | 23 | public: 24 | dirfrag_t get_dirfrag() { return dirfrag; } 25 | 26 | MExportDirNotifyAck() {} 27 | MExportDirNotifyAck(dirfrag_t df, uint64_t tid) : 28 | Message(MSG_MDS_EXPORTDIRNOTIFYACK), dirfrag(df) { 29 | set_tid(tid); 30 | } 31 | private: 32 | ~MExportDirNotifyAck() {} 33 | 34 | public: 35 | const char *get_type_name() const { return "ExNotA"; } 36 | void print(ostream& o) const { 37 | o << "export_notify_ack(" << dirfrag << ")"; 38 | } 39 | 40 | void encode_payload(uint64_t features) { 41 | ::encode(dirfrag, payload); 42 | } 43 | void decode_payload() { 44 | bufferlist::iterator p = payload.begin(); 45 | ::decode(dirfrag, p); 46 | } 47 | 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /messages/MLogAck.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MLOGACK_H 16 | #define CEPH_MLOGACK_H 17 | 18 | #include 19 | 20 | class MLogAck : public Message { 21 | public: 22 | uuid_d fsid; 23 | version_t last; 24 | std::string channel; 25 | 26 | MLogAck() : Message(MSG_LOGACK) {} 27 | MLogAck(uuid_d& f, version_t l) : Message(MSG_LOGACK), fsid(f), last(l) {} 28 | private: 29 | ~MLogAck() {} 30 | 31 | public: 32 | const char *get_type_name() const { return "log_ack"; } 33 | void print(ostream& out) const { 34 | out << "log(last " << last << ")"; 35 | } 36 | 37 | void encode_payload(uint64_t features) { 38 | ::encode(fsid, payload); 39 | ::encode(last, payload); 40 | ::encode(channel, payload); 41 | } 42 | void decode_payload() { 43 | bufferlist::iterator p = payload.begin(); 44 | ::decode(fsid, p); 45 | ::decode(last, p); 46 | if (!p.end()) 47 | ::decode(channel, p); 48 | } 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /auth/cephx/CephxAuthorizeHandler.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "../KeyRing.h" 3 | 4 | #include "CephxProtocol.h" 5 | #include "CephxAuthorizeHandler.h" 6 | 7 | #define dout_subsys ceph_subsys_auth 8 | 9 | 10 | 11 | bool CephxAuthorizeHandler::verify_authorizer(CephContext *cct, KeyStore *keys, 12 | bufferlist& authorizer_data, bufferlist& authorizer_reply, 13 | EntityName& entity_name, uint64_t& global_id, AuthCapsInfo& caps_info, CryptoKey& session_key, uint64_t *auid) 14 | { 15 | bufferlist::iterator iter = authorizer_data.begin(); 16 | 17 | if (!authorizer_data.length()) { 18 | ldout(cct, 1) << "verify authorizer, authorizer_data.length()=0" << dendl; 19 | return false; 20 | } 21 | 22 | CephXServiceTicketInfo auth_ticket_info; 23 | 24 | bool isvalid = cephx_verify_authorizer(cct, keys, iter, auth_ticket_info, authorizer_reply); 25 | 26 | if (isvalid) { 27 | caps_info = auth_ticket_info.ticket.caps; 28 | entity_name = auth_ticket_info.ticket.name; 29 | global_id = auth_ticket_info.ticket.global_id; 30 | session_key = auth_ticket_info.session_key; 31 | if (auid) *auid = auth_ticket_info.ticket.auid; 32 | } 33 | 34 | return isvalid; 35 | } 36 | 37 | // Return type of crypto used for this session's data; for cephx, symmetric authentication 38 | 39 | int CephxAuthorizeHandler::authorizer_session_crypto() 40 | { 41 | return SESSION_SYMMETRIC_AUTHENTICATE; 42 | } 43 | -------------------------------------------------------------------------------- /messages/MExportDirCancel.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MEXPORTDIRCANCEL_H 16 | #define CEPH_MEXPORTDIRCANCEL_H 17 | 18 | #include "msg/Message.h" 19 | #include "include/types.h" 20 | 21 | class MExportDirCancel : public Message { 22 | dirfrag_t dirfrag; 23 | 24 | public: 25 | dirfrag_t get_dirfrag() { return dirfrag; } 26 | 27 | MExportDirCancel() : Message(MSG_MDS_EXPORTDIRCANCEL) {} 28 | MExportDirCancel(dirfrag_t df, uint64_t tid) : 29 | Message(MSG_MDS_EXPORTDIRCANCEL), dirfrag(df) { 30 | set_tid(tid); 31 | } 32 | private: 33 | ~MExportDirCancel() {} 34 | 35 | public: 36 | const char *get_type_name() const { return "ExCancel"; } 37 | void print(ostream& o) const { 38 | o << "export_cancel(" << dirfrag << ")"; 39 | } 40 | 41 | void encode_payload(uint64_t features) { 42 | ::encode(dirfrag, payload); 43 | } 44 | void decode_payload() { 45 | bufferlist::iterator p = payload.begin(); 46 | ::decode(dirfrag, p); 47 | } 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /auth/AuthServiceHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_AUTHSERVICEHANDLER_H 16 | #define CEPH_AUTHSERVICEHANDLER_H 17 | 18 | #include "include/types.h" 19 | #include "common/config.h" 20 | #include "Auth.h" 21 | 22 | class CephContext; 23 | class KeyServer; 24 | 25 | struct AuthServiceHandler { 26 | protected: 27 | CephContext *cct; 28 | public: 29 | EntityName entity_name; 30 | uint64_t global_id; 31 | 32 | AuthServiceHandler(CephContext *cct_) : cct(cct_), global_id(0) {} 33 | 34 | virtual ~AuthServiceHandler() { } 35 | 36 | virtual int start_session(EntityName& name, bufferlist::iterator& indata, bufferlist& result, AuthCapsInfo& caps) = 0; 37 | virtual int handle_request(bufferlist::iterator& indata, bufferlist& result, uint64_t& global_id, AuthCapsInfo& caps, uint64_t *auid = NULL) = 0; 38 | 39 | EntityName& get_entity_name() { return entity_name; } 40 | }; 41 | 42 | extern AuthServiceHandler *get_auth_service_handler(int type, CephContext *cct, KeyServer *ks); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /auth/none/AuthNoneSessionHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "../AuthSessionHandler.h" 16 | #include "../Auth.h" 17 | 18 | #define dout_subsys ceph_subsys_auth 19 | 20 | class CephContext; 21 | 22 | class AuthNoneSessionHandler : public AuthSessionHandler { 23 | public: 24 | AuthNoneSessionHandler(CephContext *cct_, CryptoKey session_key) 25 | : AuthSessionHandler(cct_, CEPH_AUTH_NONE, session_key) {} 26 | ~AuthNoneSessionHandler() {} 27 | 28 | bool no_security() { 29 | return true; 30 | } 31 | 32 | // The None suite neither signs nor encrypts messages, so these functions just return success. 33 | // Since nothing was signed or encrypted, don't increment the stats. PLR 34 | 35 | int sign_message(Message *m) { 36 | return 0; 37 | } 38 | 39 | int check_message_signature(Message *m) { 40 | return 0; 41 | } 42 | 43 | int encrypt_message(Message *m) { 44 | return 0; 45 | } 46 | 47 | int decrypt_message(Message *m) { 48 | return 0; 49 | } 50 | 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /messages/MStatfs.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MSTATFS_H 17 | #define CEPH_MSTATFS_H 18 | 19 | #include /* or */ 20 | #include "messages/PaxosServiceMessage.h" 21 | 22 | class MStatfs : public PaxosServiceMessage { 23 | public: 24 | uuid_d fsid; 25 | 26 | MStatfs() : PaxosServiceMessage(CEPH_MSG_STATFS, 0) {} 27 | MStatfs(const uuid_d& f, ceph_tid_t t, version_t v) : 28 | PaxosServiceMessage(CEPH_MSG_STATFS, v), fsid(f) { 29 | set_tid(t); 30 | } 31 | 32 | private: 33 | ~MStatfs() {} 34 | 35 | public: 36 | const char *get_type_name() const { return "statfs"; } 37 | void print(ostream& out) const { 38 | out << "statfs(" << get_tid() << " v" << version << ")"; 39 | } 40 | 41 | void encode_payload(uint64_t features) { 42 | paxos_encode(); 43 | ::encode(fsid, payload); 44 | } 45 | void decode_payload() { 46 | bufferlist::iterator p = payload.begin(); 47 | paxos_decode(p); 48 | ::decode(fsid, p); 49 | } 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /log/EntryQueue.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #ifndef __CEPH_LOG_ENTRYQUEUE_H 5 | #define __CEPH_LOG_ENTRYQUEUE_H 6 | 7 | #include "Entry.h" 8 | 9 | namespace ceph { 10 | namespace log { 11 | 12 | struct EntryQueue { 13 | int m_len; 14 | struct Entry *m_head, *m_tail; 15 | 16 | bool empty() const { 17 | return m_len == 0; 18 | } 19 | 20 | void swap(EntryQueue& other) { 21 | int len = m_len; 22 | struct Entry *h = m_head, *t = m_tail; 23 | m_len = other.m_len; 24 | m_head = other.m_head; 25 | m_tail = other.m_tail; 26 | other.m_len = len; 27 | other.m_head = h; 28 | other.m_tail = t; 29 | } 30 | 31 | void enqueue(Entry *e) { 32 | if (m_tail) { 33 | m_tail->m_next = e; 34 | m_tail = e; 35 | } else { 36 | m_head = m_tail = e; 37 | } 38 | m_len++; 39 | } 40 | 41 | Entry *dequeue() { 42 | if (!m_head) 43 | return NULL; 44 | Entry *e = m_head; 45 | m_head = m_head->m_next; 46 | if (!m_head) 47 | m_tail = NULL; 48 | m_len--; 49 | e->m_next = NULL; 50 | return e; 51 | } 52 | 53 | EntryQueue() 54 | : m_len(0), 55 | m_head(NULL), 56 | m_tail(NULL) 57 | {} 58 | ~EntryQueue() { 59 | Entry *t; 60 | while (m_head) { 61 | t = m_head->m_next; 62 | delete m_head; 63 | m_head = t; 64 | } 65 | } 66 | }; 67 | 68 | } 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /auth/unknown/AuthUnknownSessionHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "../AuthSessionHandler.h" 16 | #include "../Auth.h" 17 | 18 | #define dout_subsys ceph_subsys_auth 19 | 20 | class CephContext; 21 | 22 | class AuthUnknownSessionHandler : public AuthSessionHandler { 23 | public: 24 | AuthUnknownSessionHandler(CephContext *cct_, CryptoKey session_key) 25 | : AuthSessionHandler(cct_, CEPH_AUTH_UNKNOWN, session_key) {} 26 | ~AuthUnknownSessionHandler() {} 27 | 28 | bool no_security() { 29 | return true; 30 | } 31 | 32 | // The Unknown suite neither signs nor encrypts messages, so these functions just return success. 33 | // Since nothing was signed or encrypted, don't increment the stats. PLR 34 | 35 | int sign_message(Message *m) { 36 | return 0; 37 | } 38 | 39 | int check_message_signature(Message *m) { 40 | return 0; 41 | } 42 | 43 | int encrypt_message(Message *m) { 44 | return 0; 45 | } 46 | 47 | int decrypt_message(Message *m) { 48 | return 0; 49 | } 50 | 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /common/io_priority.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2012 Red Hat 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include 16 | #include 17 | //by ketor #include /* For SYS_xxx definitions */ 18 | #include 19 | #include 20 | 21 | #include "common/errno.h" 22 | #include "io_priority.h" 23 | 24 | pid_t ceph_gettid(void) 25 | { 26 | #ifdef __linux__ 27 | return syscall(SYS_gettid); 28 | #else 29 | return -ENOSYS; 30 | #endif 31 | } 32 | 33 | int ceph_ioprio_set(int whence, int who, int ioprio) 34 | { 35 | #ifdef __linux__ 36 | return syscall(SYS_ioprio_set, whence, who, ioprio); 37 | #else 38 | return -ENOSYS; 39 | #endif 40 | } 41 | 42 | int ceph_ioprio_string_to_class(const std::string& s) 43 | { 44 | std::string l = s; 45 | std::transform(l.begin(), l.end(), l.begin(), ::tolower); 46 | 47 | if (l == "idle") 48 | return IOPRIO_CLASS_IDLE; 49 | if (l == "be" || l == "besteffort" || l == "best effort") 50 | return IOPRIO_CLASS_BE; 51 | if (l == "rt" || l == "realtime" || l == "real time") 52 | return IOPRIO_CLASS_RT; 53 | return -EINVAL; 54 | } 55 | -------------------------------------------------------------------------------- /common/sync_filesystem.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_SYNC_FILESYSTEM_H 16 | #define CEPH_SYNC_FILESYSTEM_H 17 | 18 | #include 19 | 20 | #ifndef __CYGWIN__ 21 | # ifndef DARWIN 22 | # include 23 | # include 24 | # include "../os/btrfs_ioctl.h" 25 | # endif 26 | #endif 27 | 28 | inline int sync_filesystem(int fd) 29 | { 30 | /* On Linux, newer versions of glibc have a function called syncfs that 31 | * performs a sync on only one filesystem. If we don't have this call, we 32 | * have to fall back on sync(), which synchronizes every filesystem on the 33 | * computer. */ 34 | #ifdef HAVE_SYS_SYNCFS 35 | if (syncfs(fd) == 0) 36 | return 0; 37 | else 38 | return -errno; 39 | #elif defined(SYS_syncfs) 40 | if (syscall(SYS_syncfs, fd) == 0) 41 | return 0; 42 | else 43 | return -errno; 44 | #elif defined(__NR_syncfs) 45 | if (syscall(__NR_syncfs, fd) == 0) 46 | return 0; 47 | else 48 | return -errno; 49 | #endif 50 | 51 | sync(); 52 | return 0; 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /messages/MMonMap.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MMONMAP_H 16 | #define CEPH_MMONMAP_H 17 | 18 | #include "include/ceph_features.h" 19 | #include "msg/Message.h" 20 | #include "mon/MonMap.h" 21 | 22 | class MMonMap : public Message { 23 | public: 24 | bufferlist monmapbl; 25 | 26 | MMonMap() : Message(CEPH_MSG_MON_MAP) { } 27 | MMonMap(bufferlist &bl) : Message(CEPH_MSG_MON_MAP) { 28 | monmapbl.claim(bl); 29 | } 30 | private: 31 | ~MMonMap() {} 32 | 33 | public: 34 | const char *get_type_name() const { return "mon_map"; } 35 | 36 | void encode_payload(uint64_t features) { 37 | if (monmapbl.length() && (features & CEPH_FEATURE_MONENC) == 0) { 38 | // reencode old-format monmap 39 | MonMap t; 40 | t.decode(monmapbl); 41 | monmapbl.clear(); 42 | t.encode(monmapbl, features); 43 | } 44 | 45 | ::encode(monmapbl, payload); 46 | } 47 | void decode_payload() { 48 | bufferlist::iterator p = payload.begin(); 49 | ::decode(monmapbl, p); 50 | } 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /messages/MRemoveSnaps.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MREMOVESNAPS_H 16 | #define CEPH_MREMOVESNAPS_H 17 | 18 | #include "messages/PaxosServiceMessage.h" 19 | 20 | struct MRemoveSnaps : public PaxosServiceMessage { 21 | map > snaps; 22 | 23 | MRemoveSnaps() : 24 | PaxosServiceMessage(MSG_REMOVE_SNAPS, 0) { } 25 | MRemoveSnaps(map >& s) : 26 | PaxosServiceMessage(MSG_REMOVE_SNAPS, 0) { 27 | snaps.swap(s); 28 | } 29 | private: 30 | ~MRemoveSnaps() {} 31 | 32 | public: 33 | const char *get_type_name() const { return "remove_snaps"; } 34 | void print(ostream& out) const { 35 | out << "remove_snaps(" << snaps << " v" << version << ")"; 36 | } 37 | 38 | void encode_payload(uint64_t features) { 39 | paxos_encode(); 40 | ::encode(snaps, payload); 41 | } 42 | void decode_payload() { 43 | bufferlist::iterator p = payload.begin(); 44 | paxos_decode(p); 45 | ::decode(snaps, p); 46 | assert(p.end()); 47 | } 48 | 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /messages/MMonSubscribeAck.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MMONSUBSCRIBEACK_H 16 | #define CEPH_MMONSUBSCRIBEACK_H 17 | 18 | #include "msg/Message.h" 19 | 20 | struct MMonSubscribeAck : public Message { 21 | __u32 interval; 22 | uuid_d fsid; 23 | 24 | MMonSubscribeAck() : Message(CEPH_MSG_MON_SUBSCRIBE_ACK), 25 | interval(0) { 26 | memset(&fsid, 0, sizeof(fsid)); 27 | } 28 | MMonSubscribeAck(uuid_d& f, int i) : Message(CEPH_MSG_MON_SUBSCRIBE_ACK), 29 | interval(i), fsid(f) { } 30 | private: 31 | ~MMonSubscribeAck() {} 32 | 33 | public: 34 | const char *get_type_name() const { return "mon_subscribe_ack"; } 35 | void print(ostream& o) const { 36 | o << "mon_subscribe_ack(" << interval << "s)"; 37 | } 38 | 39 | void decode_payload() { 40 | bufferlist::iterator p = payload.begin(); 41 | ::decode(interval, p); 42 | ::decode(fsid, p); 43 | } 44 | void encode_payload(uint64_t features) { 45 | ::encode(interval, payload); 46 | ::encode(fsid, payload); 47 | } 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /json_spirit/json_spirit_writer_options.h: -------------------------------------------------------------------------------- 1 | #ifndef JSON_SPIRIT_WRITER_OPTIONS 2 | #define JSON_SPIRIT_WRITER_OPTIONS 3 | 4 | // Copyright John W. Wilkinson 2007 - 2011 5 | // Distributed under the MIT License, see accompanying file LICENSE.txt 6 | 7 | // json spirit version 4.05 8 | 9 | #if defined(_MSC_VER) && (_MSC_VER >= 1020) 10 | # pragma once 11 | #endif 12 | 13 | namespace json_spirit 14 | { 15 | enum Output_options{ pretty_print = 0x01, // Add whitespace to format the output nicely. 16 | 17 | raw_utf8 = 0x02, // This prevents non-printable characters from being escapted using "\uNNNN" notation. 18 | // Note, this is an extension to the JSON standard. It disables the escaping of 19 | // non-printable characters allowing UTF-8 sequences held in 8 bit char strings 20 | // to pass through unaltered. 21 | 22 | remove_trailing_zeros = 0x04, 23 | // outputs e.g. "1.200000000000000" as "1.2" 24 | single_line_arrays = 0x08, 25 | // pretty printing except that arrays printed on single lines unless they contain 26 | // composite elements, i.e. objects or arrays 27 | }; 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /messages/MExportDirAck.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MEXPORTDIRACK_H 16 | #define CEPH_MEXPORTDIRACK_H 17 | 18 | #include "MExportDir.h" 19 | 20 | class MExportDirAck : public Message { 21 | public: 22 | dirfrag_t dirfrag; 23 | bufferlist imported_caps; 24 | 25 | dirfrag_t get_dirfrag() { return dirfrag; } 26 | 27 | MExportDirAck() : Message(MSG_MDS_EXPORTDIRACK) {} 28 | MExportDirAck(dirfrag_t df, uint64_t tid) : 29 | Message(MSG_MDS_EXPORTDIRACK), dirfrag(df) { 30 | set_tid(tid); 31 | } 32 | private: 33 | ~MExportDirAck() {} 34 | 35 | public: 36 | const char *get_type_name() const { return "ExAck"; } 37 | void print(ostream& o) const { 38 | o << "export_ack(" << dirfrag << ")"; 39 | } 40 | 41 | void decode_payload() { 42 | bufferlist::iterator p = payload.begin(); 43 | ::decode(dirfrag, p); 44 | ::decode(imported_caps, p); 45 | } 46 | void encode_payload(uint64_t features) { 47 | ::encode(dirfrag, payload); 48 | ::encode(imported_caps, payload); 49 | } 50 | 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /client/Dentry.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_CLIENT_DENTRY_H 2 | #define CEPH_CLIENT_DENTRY_H 3 | 4 | #include "include/lru.h" 5 | #include "include/xlist.h" 6 | 7 | #include "mds/mdstypes.h" 8 | 9 | class Dir; 10 | struct Inode; 11 | 12 | class Dentry : public LRUObject { 13 | public: 14 | string name; // sort of lame 15 | //const char *name; 16 | Dir *dir; 17 | Inode *inode; 18 | int ref; // 1 if there's a dir beneath me. 19 | uint64_t offset; 20 | mds_rank_t lease_mds; 21 | utime_t lease_ttl; 22 | uint64_t lease_gen; 23 | ceph_seq_t lease_seq; 24 | int cap_shared_gen; 25 | 26 | xlist::item item_dentry_list; 27 | 28 | /* 29 | * ref==1 -> cached, unused 30 | * ref >1 -> pinned in lru 31 | */ 32 | void get() { 33 | assert(ref > 0); 34 | if (++ref == 2) 35 | lru_pin(); 36 | //cout << "dentry.get on " << this << " " << name << " now " << ref << std::endl; 37 | } 38 | void put() { 39 | assert(ref > 0); 40 | if (--ref == 1) 41 | lru_unpin(); 42 | //cout << "dentry.put on " << this << " " << name << " now " << ref << std::endl; 43 | if (ref == 0) 44 | delete this; 45 | } 46 | 47 | void dump(Formatter *f) const; 48 | 49 | Dentry() : 50 | dir(0), inode(0), ref(1), offset(0), 51 | lease_mds(-1), lease_gen(0), lease_seq(0), cap_shared_gen(0), 52 | item_dentry_list(this) { } 53 | private: 54 | ~Dentry() { 55 | assert(ref == 0); 56 | } 57 | }; 58 | 59 | 60 | 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /messages/MInodeFileCaps.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MINODEFILECAPS_H 17 | #define CEPH_MINODEFILECAPS_H 18 | 19 | class MInodeFileCaps : public Message { 20 | inodeno_t ino; 21 | __u32 caps; 22 | 23 | public: 24 | inodeno_t get_ino() { return ino; } 25 | int get_caps() { return caps; } 26 | 27 | MInodeFileCaps() : Message(MSG_MDS_INODEFILECAPS) {} 28 | MInodeFileCaps(inodeno_t ino, int caps) : 29 | Message(MSG_MDS_INODEFILECAPS) { 30 | this->ino = ino; 31 | this->caps = caps; 32 | } 33 | private: 34 | ~MInodeFileCaps() {} 35 | 36 | public: 37 | const char *get_type_name() const { return "inode_file_caps";} 38 | void print(ostream& out) const { 39 | out << "inode_file_caps(" << ino << " " << ccap_string(caps) << ")"; 40 | } 41 | 42 | void encode_payload(uint64_t features) { 43 | ::encode(ino, payload); 44 | ::encode(caps, payload); 45 | } 46 | void decode_payload() { 47 | bufferlist::iterator p = payload.begin(); 48 | ::decode(ino, p); 49 | ::decode(caps, p); 50 | } 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /messages/MCommand.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MCOMMAND_H 16 | #define CEPH_MCOMMAND_H 17 | 18 | #include 19 | #include 20 | 21 | #include "msg/Message.h" 22 | 23 | class MCommand : public Message { 24 | public: 25 | uuid_d fsid; 26 | std::vector cmd; 27 | 28 | MCommand() 29 | : Message(MSG_MON_COMMAND) {} 30 | MCommand(const uuid_d &f) 31 | : Message(MSG_COMMAND), 32 | fsid(f) { } 33 | 34 | private: 35 | ~MCommand() {} 36 | 37 | public: 38 | const char *get_type_name() const { return "command"; } 39 | void print(ostream& o) const { 40 | o << "command(tid " << get_tid() << ": "; 41 | for (unsigned i=0; i 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | 17 | #ifndef CEPH_MOSDPGTEMP_H 18 | #define CEPH_MOSDPGTEMP_H 19 | 20 | #include "messages/PaxosServiceMessage.h" 21 | 22 | class MOSDPGTemp : public PaxosServiceMessage { 23 | public: 24 | epoch_t map_epoch; 25 | map > pg_temp; 26 | 27 | MOSDPGTemp(epoch_t e) : PaxosServiceMessage(MSG_OSD_PGTEMP, e), map_epoch(e) { } 28 | MOSDPGTemp() : PaxosServiceMessage(MSG_OSD_PGTEMP, 0) {} 29 | private: 30 | ~MOSDPGTemp() {} 31 | 32 | public: 33 | void encode_payload(uint64_t features) { 34 | paxos_encode(); 35 | ::encode(map_epoch, payload); 36 | ::encode(pg_temp, payload); 37 | } 38 | void decode_payload() { 39 | bufferlist::iterator p = payload.begin(); 40 | paxos_decode(p); 41 | ::decode(map_epoch, p); 42 | ::decode(pg_temp, p); 43 | } 44 | 45 | const char *get_type_name() const { return "osd_pgtemp"; } 46 | void print(ostream &out) const { 47 | out << "osd_pgtemp(e" << map_epoch << " " << pg_temp << " v" << version << ")"; 48 | } 49 | 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /messages/MExportDirFinish.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MEXPORTDIRFINISH_H 16 | #define CEPH_MEXPORTDIRFINISH_H 17 | 18 | #include "msg/Message.h" 19 | 20 | class MExportDirFinish : public Message { 21 | dirfrag_t dirfrag; 22 | bool last; 23 | 24 | public: 25 | dirfrag_t get_dirfrag() { return dirfrag; } 26 | bool is_last() { return last; } 27 | 28 | MExportDirFinish() {} 29 | MExportDirFinish(dirfrag_t df, bool l, uint64_t tid) : 30 | Message(MSG_MDS_EXPORTDIRFINISH), dirfrag(df), last(l) { 31 | set_tid(tid); 32 | } 33 | private: 34 | ~MExportDirFinish() {} 35 | 36 | public: 37 | const char *get_type_name() const { return "ExFin"; } 38 | void print(ostream& o) const { 39 | o << "export_finish(" << dirfrag << (last ? " last" : "") << ")"; 40 | } 41 | 42 | void encode_payload(uint64_t features) { 43 | ::encode(dirfrag, payload); 44 | ::encode(last, payload); 45 | } 46 | void decode_payload() { 47 | bufferlist::iterator p = payload.begin(); 48 | ::decode(dirfrag, p); 49 | ::decode(last, p); 50 | } 51 | 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /global/signal_handler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_GLOBAL_SIGNAL_HANDLER_H 16 | #define CEPH_GLOBAL_SIGNAL_HANDLER_H 17 | 18 | #include 19 | #include 20 | 21 | typedef void (*signal_handler_t)(int); 22 | 23 | void install_sighandler(int signum, signal_handler_t handler, int flags); 24 | 25 | // handles SIGHUP 26 | void sighup_handler(int signum); 27 | 28 | // Install the standard Ceph signal handlers 29 | void install_standard_sighandlers(void); 30 | 31 | 32 | /// initialize async signal handler framework 33 | void init_async_signal_handler(); 34 | 35 | /// shutdown async signal handler framework 36 | void shutdown_async_signal_handler(); 37 | 38 | /// queue an async signal 39 | void queue_async_signal(int signum); 40 | 41 | /// install a safe, async, callback for the given signal 42 | void register_async_signal_handler(int signum, signal_handler_t handler); 43 | void register_async_signal_handler_oneshot(int signum, signal_handler_t handler); 44 | 45 | /// uninstall a safe async signal callback 46 | void unregister_async_signal_handler(int signum, signal_handler_t handler); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /auth/none/AuthNoneAuthorizeHandler.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2009-2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "AuthNoneAuthorizeHandler.h" 16 | #include "common/debug.h" 17 | 18 | #define dout_subsys ceph_subsys_auth 19 | 20 | bool AuthNoneAuthorizeHandler::verify_authorizer(CephContext *cct, KeyStore *keys, 21 | bufferlist& authorizer_data, bufferlist& authorizer_reply, 22 | EntityName& entity_name, uint64_t& global_id, AuthCapsInfo& caps_info, CryptoKey& session_key, 23 | uint64_t *auid) 24 | { 25 | bufferlist::iterator iter = authorizer_data.begin(); 26 | 27 | try { 28 | __u8 struct_v = 1; 29 | ::decode(struct_v, iter); 30 | ::decode(entity_name, iter); 31 | ::decode(global_id, iter); 32 | } catch (const buffer::error &err) { 33 | ldout(cct, 0) << "AuthNoneAuthorizeHandle::verify_authorizer() failed to decode" << dendl; 34 | return false; 35 | } 36 | 37 | caps_info.allow_all = true; 38 | 39 | return true; 40 | } 41 | 42 | // Return type of crypto used for this session's data; for none, no crypt used 43 | 44 | int AuthNoneAuthorizeHandler::authorizer_session_crypto() 45 | { 46 | return SESSION_CRYPTO_NONE; 47 | } 48 | -------------------------------------------------------------------------------- /messages/MCommandReply.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MCOMMANDREPLY_H 16 | #define CEPH_MCOMMANDREPLY_H 17 | 18 | #include "msg/Message.h" 19 | #include "MCommand.h" 20 | 21 | class MCommandReply : public Message { 22 | public: 23 | __s32 r; 24 | string rs; 25 | 26 | MCommandReply() 27 | : Message(MSG_COMMAND_REPLY) {} 28 | MCommandReply(MCommand *m, int _r) 29 | : Message(MSG_COMMAND_REPLY), r(_r) { 30 | header.tid = m->get_tid(); 31 | } 32 | MCommandReply(int _r, string s) 33 | : Message(MSG_COMMAND_REPLY), 34 | r(_r), rs(s) { } 35 | private: 36 | ~MCommandReply() {} 37 | 38 | public: 39 | const char *get_type_name() const { return "command_reply"; } 40 | void print(ostream& o) const { 41 | o << "command_reply(tid " << get_tid() << ": " << r << " " << rs << ")"; 42 | } 43 | 44 | void encode_payload(uint64_t features) { 45 | ::encode(r, payload); 46 | ::encode(rs, payload); 47 | } 48 | void decode_payload() { 49 | bufferlist::iterator p = payload.begin(); 50 | ::decode(r, p); 51 | ::decode(rs, p); 52 | } 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /common/signal.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_COMMON_SIGNAL_H 16 | #define CEPH_COMMON_SIGNAL_H 17 | 18 | #include 19 | #include 20 | 21 | // Returns a string showing the set of blocked signals for the calling thread. 22 | // Other threads may have a different set (this is per-thread thing). 23 | //extern std::string signal_mask_to_str(); 24 | 25 | // Block a list of signals. If siglist == NULL, blocks all signals. 26 | // If not, the list is terminated with a 0 element. 27 | // 28 | // On success, stores the old set of blocked signals in 29 | // old_sigset. On failure, stores an invalid set of blocked signals in 30 | // old_sigset. 31 | extern void block_signals(const int *siglist, sigset_t *old_sigset); 32 | 33 | // Restore the set of blocked signals. Will not restore an invalid set of 34 | // blocked signals. 35 | extern void restore_sigset(const sigset_t *old_sigset); 36 | 37 | // Unblock all signals. On success, stores the old set of blocked signals in 38 | // old_sigset. On failure, stores an invalid set of blocked signals in 39 | // old_sigset. 40 | extern void unblock_all_signals(sigset_t *old_sigset); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /auth/RotatingKeyRing.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_ROTATINGKEYRING_H 16 | #define CEPH_ROTATINGKEYRING_H 17 | 18 | #include "common/config.h" 19 | #include "common/Mutex.h" 20 | 21 | #include "auth/Crypto.h" 22 | #include "auth/Auth.h" 23 | 24 | /* 25 | * mediate access to a service's keyring and rotating secrets 26 | */ 27 | 28 | class KeyRing; 29 | 30 | class RotatingKeyRing : public KeyStore { 31 | CephContext *cct; 32 | uint32_t service_id; 33 | RotatingSecrets secrets; 34 | KeyRing *keyring; 35 | mutable Mutex lock; 36 | 37 | public: 38 | RotatingKeyRing(CephContext *cct_, uint32_t s, KeyRing *kr) : 39 | cct(cct_), 40 | service_id(s), 41 | keyring(kr), 42 | lock("RotatingKeyRing::lock") {} 43 | 44 | bool need_new_secrets() const; 45 | bool need_new_secrets(utime_t now) const; 46 | void set_secrets(RotatingSecrets& s); 47 | void dump_rotating() const; 48 | bool get_secret(const EntityName& name, CryptoKey& secret) const; 49 | bool get_service_secret(uint32_t service_id, uint64_t secret_id, 50 | CryptoKey& secret) const; 51 | KeyRing *get_keyring(); 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /messages/MDentryUnlink.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MDENTRYUNLINK_H 17 | #define CEPH_MDENTRYUNLINK_H 18 | 19 | class MDentryUnlink : public Message { 20 | dirfrag_t dirfrag; 21 | string dn; 22 | 23 | public: 24 | dirfrag_t get_dirfrag() { return dirfrag; } 25 | string& get_dn() { return dn; } 26 | 27 | bufferlist straybl; 28 | 29 | MDentryUnlink() : 30 | Message(MSG_MDS_DENTRYUNLINK) { } 31 | MDentryUnlink(dirfrag_t df, string& n) : 32 | Message(MSG_MDS_DENTRYUNLINK), 33 | dirfrag(df), 34 | dn(n) {} 35 | private: 36 | ~MDentryUnlink() {} 37 | 38 | public: 39 | const char *get_type_name() const { return "dentry_unlink";} 40 | void print(ostream& o) const { 41 | o << "dentry_unlink(" << dirfrag << " " << dn << ")"; 42 | } 43 | 44 | void decode_payload() { 45 | bufferlist::iterator p = payload.begin(); 46 | ::decode(dirfrag, p); 47 | ::decode(dn, p); 48 | ::decode(straybl, p); 49 | } 50 | void encode_payload(uint64_t features) { 51 | ::encode(dirfrag, payload); 52 | ::encode(dn, payload); 53 | ::encode(straybl, payload); 54 | } 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /msg/Messenger.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #include "include/types.h" 5 | #include "Messenger.h" 6 | 7 | #include "msg/simple/SimpleMessenger.h" 8 | //by ketor #include "../msg/async/AsyncMessenger.h" 9 | #ifdef HAVE_XIO 10 | #include "msg/xio/XioMessenger.h" 11 | #endif 12 | 13 | Messenger *Messenger::create(CephContext *cct, const string &type, 14 | entity_name_t name, string lname, 15 | uint64_t nonce) 16 | { 17 | int r = -1; 18 | if (type == "random") 19 | r = rand() % 2; // random does not include xio 20 | if (r == 0 || type == "simple") 21 | return new SimpleMessenger(cct, name, lname, nonce); 22 | // else if ((r == 1 || type == "async") && 23 | // cct->check_experimental_feature_enabled("ms-type-async")) 24 | // return new AsyncMessenger(cct, name, lname, nonce); 25 | #ifdef HAVE_XIO 26 | else if ((type == "xio") && 27 | cct->check_experimental_feature_enabled("ms-type-xio")) 28 | return new XioMessenger(cct, name, lname, nonce); 29 | #endif 30 | // lderr(cct) << "unrecognized ms_type '" << type << "'" << dendl; 31 | return NULL; 32 | } 33 | 34 | /* 35 | * Pre-calculate desired software CRC settings. CRC computation may 36 | * be disabled by default for some transports (e.g., those with strong 37 | * hardware checksum support). 38 | */ 39 | int Messenger::get_default_crc_flags(md_config_t * conf) 40 | { 41 | int r = 0; 42 | if (conf->ms_crc_data) 43 | r |= MSG_CRC_DATA; 44 | if (conf->ms_crc_header) 45 | r |= MSG_CRC_HEADER; 46 | return r; 47 | } 48 | -------------------------------------------------------------------------------- /messages/MExportDirPrepAck.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MEXPORTDIRPREPACK_H 16 | #define CEPH_MEXPORTDIRPREPACK_H 17 | 18 | #include "msg/Message.h" 19 | #include "include/types.h" 20 | 21 | class MExportDirPrepAck : public Message { 22 | dirfrag_t dirfrag; 23 | bool success; 24 | 25 | public: 26 | dirfrag_t get_dirfrag() { return dirfrag; } 27 | 28 | MExportDirPrepAck() {} 29 | MExportDirPrepAck(dirfrag_t df, bool s, uint64_t tid) : 30 | Message(MSG_MDS_EXPORTDIRPREPACK), dirfrag(df), success(s) { 31 | set_tid(tid); 32 | } 33 | private: 34 | ~MExportDirPrepAck() {} 35 | 36 | public: 37 | bool is_success() { return success; } 38 | const char *get_type_name() const { return "ExPAck"; } 39 | void print(ostream& o) const { 40 | o << "export_prep_ack(" << dirfrag << (success ? " success)" : " fail)"); 41 | } 42 | 43 | void decode_payload() { 44 | bufferlist::iterator p = payload.begin(); 45 | ::decode(dirfrag, p); 46 | ::decode(success, p); 47 | } 48 | void encode_payload(uint64_t features) { 49 | ::encode(dirfrag, payload); 50 | ::encode(success, payload); 51 | } 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /messages/MMDSResolveAck.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MMDSRESOLVEACK_H 16 | #define CEPH_MMDSRESOLVEACK_H 17 | 18 | #include "msg/Message.h" 19 | 20 | #include "include/types.h" 21 | 22 | 23 | class MMDSResolveAck : public Message { 24 | public: 25 | map commit; 26 | vector abort; 27 | 28 | MMDSResolveAck() : Message(MSG_MDS_RESOLVEACK) {} 29 | private: 30 | ~MMDSResolveAck() {} 31 | 32 | public: 33 | const char *get_type_name() const { return "resolve_ack"; } 34 | /*void print(ostream& out) const { 35 | out << "resolve_ack.size() 36 | << "+" << ambiguous_imap.size() 37 | << " imports +" << slave_requests.size() << " slave requests)"; 38 | } 39 | */ 40 | 41 | void add_commit(metareqid_t r) { 42 | commit[r].clear(); 43 | } 44 | void add_abort(metareqid_t r) { 45 | abort.push_back(r); 46 | } 47 | 48 | void encode_payload(uint64_t features) { 49 | ::encode(commit, payload); 50 | ::encode(abort, payload); 51 | } 52 | void decode_payload() { 53 | bufferlist::iterator p = payload.begin(); 54 | ::decode(commit, p); 55 | ::decode(abort, p); 56 | } 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /messages/MOSDPGMissing.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2010 Dreamhost 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MOSDPGMISSING_H 17 | #define CEPH_MOSDPGMISSING_H 18 | 19 | #include "msg/Message.h" 20 | 21 | class MOSDPGMissing : public Message { 22 | epoch_t epoch; 23 | 24 | public: 25 | pg_info_t info; 26 | pg_missing_t missing; 27 | 28 | epoch_t get_epoch() { return epoch; } 29 | 30 | MOSDPGMissing() : Message(MSG_OSD_PG_MISSING) {} 31 | MOSDPGMissing(version_t mv, const pg_info_t &info_, 32 | const pg_missing_t &missing_) 33 | : Message(MSG_OSD_PG_MISSING), epoch(mv), info(info_), 34 | missing(missing_) { } 35 | private: 36 | ~MOSDPGMissing() {} 37 | 38 | public: 39 | const char *get_type_name() const { return "pg_missing"; } 40 | void print(ostream& out) const { 41 | out << "pg_missing(" << info.pgid << " e" << epoch << ")"; 42 | } 43 | 44 | void encode_payload(uint64_t features) { 45 | ::encode(epoch, payload); 46 | ::encode(info, payload); 47 | ::encode(missing, payload); 48 | } 49 | void decode_payload() { 50 | bufferlist::iterator p = payload.begin(); 51 | ::decode(epoch, p); 52 | ::decode(info, p); 53 | missing.decode(p, info.pgid.pool()); 54 | } 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /messages/MGetPoolStatsReply.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MGETPOOLSTATSREPLY_H 17 | #define CEPH_MGETPOOLSTATSREPLY_H 18 | 19 | #include 20 | 21 | class MGetPoolStatsReply : public PaxosServiceMessage { 22 | public: 23 | uuid_d fsid; 24 | map pool_stats; 25 | 26 | MGetPoolStatsReply() : PaxosServiceMessage(MSG_GETPOOLSTATSREPLY, 0) {} 27 | MGetPoolStatsReply(uuid_d& f, ceph_tid_t t, version_t v) : 28 | PaxosServiceMessage(MSG_GETPOOLSTATSREPLY, v), 29 | fsid(f) { 30 | set_tid(t); 31 | } 32 | 33 | private: 34 | ~MGetPoolStatsReply() {} 35 | 36 | public: 37 | const char *get_type_name() const { return "getpoolstats"; } 38 | void print(ostream& out) const { 39 | out << "getpoolstatsreply(" << get_tid() << " v" << version << ")"; 40 | } 41 | 42 | void encode_payload(uint64_t features) { 43 | paxos_encode(); 44 | ::encode(fsid, payload); 45 | ::encode(pool_stats, payload, features); 46 | } 47 | void decode_payload() { 48 | bufferlist::iterator p = payload.begin(); 49 | paxos_decode(p); 50 | ::decode(fsid, p); 51 | ::decode(pool_stats, p); 52 | } 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /messages/MMonJoin.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MMONJOIN_H 16 | #define CEPH_MMONJOIN_H 17 | 18 | #include "messages/PaxosServiceMessage.h" 19 | 20 | #include 21 | using std::vector; 22 | 23 | class MMonJoin : public PaxosServiceMessage { 24 | public: 25 | uuid_d fsid; 26 | string name; 27 | entity_addr_t addr; 28 | 29 | MMonJoin() : PaxosServiceMessage(MSG_MON_JOIN, 0) {} 30 | MMonJoin(uuid_d &f, string n, const entity_addr_t& a) 31 | : PaxosServiceMessage(MSG_MON_JOIN, 0), 32 | fsid(f), name(n), addr(a) 33 | { } 34 | 35 | private: 36 | ~MMonJoin() {} 37 | 38 | public: 39 | const char *get_type_name() const { return "mon_join"; } 40 | void print(ostream& o) const { 41 | o << "mon_join(" << name << " " << addr << ")"; 42 | } 43 | 44 | void encode_payload(uint64_t features) { 45 | paxos_encode(); 46 | ::encode(fsid, payload); 47 | ::encode(name, payload); 48 | ::encode(addr, payload); 49 | } 50 | void decode_payload() { 51 | bufferlist::iterator p = payload.begin(); 52 | paxos_decode(p); 53 | ::decode(fsid, p); 54 | ::decode(name, p); 55 | ::decode(addr, p); 56 | } 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /common/histogram.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "common/histogram.h" 16 | #include "common/Formatter.h" 17 | 18 | // -- pow2_hist_t -- 19 | void pow2_hist_t::dump(Formatter *f) const 20 | { 21 | f->open_array_section("histogram"); 22 | for (std::vector::const_iterator p = h.begin(); p != h.end(); ++p) 23 | f->dump_int("count", *p); 24 | f->close_section(); 25 | f->dump_int("upper_bound", upper_bound()); 26 | } 27 | 28 | void pow2_hist_t::encode(bufferlist& bl) const 29 | { 30 | ENCODE_START(1, 1, bl); 31 | ::encode(h, bl); 32 | ENCODE_FINISH(bl); 33 | } 34 | 35 | void pow2_hist_t::decode(bufferlist::iterator& p) 36 | { 37 | DECODE_START(1, p); 38 | ::decode(h, p); 39 | DECODE_FINISH(p); 40 | } 41 | 42 | void pow2_hist_t::generate_test_instances(std::list& ls) 43 | { 44 | ls.push_back(new pow2_hist_t); 45 | ls.push_back(new pow2_hist_t); 46 | ls.back()->h.push_back(1); 47 | ls.back()->h.push_back(3); 48 | ls.back()->h.push_back(0); 49 | ls.back()->h.push_back(2); 50 | } 51 | 52 | void pow2_hist_t::decay(int bits) 53 | { 54 | for (std::vector::iterator p = h.begin(); p != h.end(); ++p) { 55 | *p >>= bits; 56 | } 57 | _contract(); 58 | } 59 | -------------------------------------------------------------------------------- /messages/MGetPoolStats.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MGETPOOLSTATS_H 17 | #define CEPH_MGETPOOLSTATS_H 18 | 19 | #include 20 | 21 | #include "messages/PaxosServiceMessage.h" 22 | 23 | class MGetPoolStats : public PaxosServiceMessage { 24 | public: 25 | uuid_d fsid; 26 | list pools; 27 | 28 | MGetPoolStats() : PaxosServiceMessage(MSG_GETPOOLSTATS, 0) {} 29 | MGetPoolStats(const uuid_d& f, ceph_tid_t t, list& ls, version_t l) : 30 | PaxosServiceMessage(MSG_GETPOOLSTATS, l), 31 | fsid(f), pools(ls) { 32 | set_tid(t); 33 | } 34 | 35 | private: 36 | ~MGetPoolStats() {} 37 | 38 | public: 39 | const char *get_type_name() const { return "getpoolstats"; } 40 | void print(ostream& out) const { 41 | out << "getpoolstats(" << get_tid() << " " << pools << " v" << version << ")"; 42 | } 43 | 44 | void encode_payload(uint64_t features) { 45 | paxos_encode(); 46 | ::encode(fsid, payload); 47 | ::encode(pools, payload); 48 | } 49 | void decode_payload() { 50 | bufferlist::iterator p = payload.begin(); 51 | paxos_decode(p); 52 | ::decode(fsid, p); 53 | ::decode(pools, p); 54 | } 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /messages/MMonCommandAck.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MMONCOMMANDACK_H 16 | #define CEPH_MMONCOMMANDACK_H 17 | 18 | #include "messages/PaxosServiceMessage.h" 19 | 20 | class MMonCommandAck : public PaxosServiceMessage { 21 | public: 22 | vector cmd; 23 | __s32 r; 24 | string rs; 25 | 26 | MMonCommandAck() : PaxosServiceMessage(MSG_MON_COMMAND_ACK, 0) {} 27 | MMonCommandAck(vector& c, int _r, string s, version_t v) : 28 | PaxosServiceMessage(MSG_MON_COMMAND_ACK, v), 29 | cmd(c), r(_r), rs(s) { } 30 | private: 31 | ~MMonCommandAck() {} 32 | 33 | public: 34 | const char *get_type_name() const { return "mon_command"; } 35 | void print(ostream& o) const { 36 | o << "mon_command_ack(" << cmd << "=" << r << " " << rs << " v" << version << ")"; 37 | } 38 | 39 | void encode_payload(uint64_t features) { 40 | paxos_encode(); 41 | ::encode(r, payload); 42 | ::encode(rs, payload); 43 | ::encode(cmd, payload); 44 | } 45 | void decode_payload() { 46 | bufferlist::iterator p = payload.begin(); 47 | paxos_decode(p); 48 | ::decode(r, p); 49 | ::decode(rs, p); 50 | ::decode(cmd, p); 51 | } 52 | }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /client/Trace.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_CLIENT_TRACE_H 17 | #define CEPH_CLIENT_TRACE_H 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | using std::list; 25 | using std::string; 26 | using std::ifstream; 27 | 28 | /* 29 | 30 | this class is more like an iterator over a constant tokenlist (which 31 | is protected by a mutex, see Trace.cc) 32 | 33 | */ 34 | 35 | class Trace { 36 | int _line; 37 | const char *filename; 38 | ifstream *fs; 39 | string line; 40 | 41 | public: 42 | Trace(const char* f) : _line(0), filename(f), fs(0) {} 43 | ~Trace() { 44 | delete fs; 45 | } 46 | 47 | Trace(const Trace& other); 48 | const Trace& operator=(const Trace& other); 49 | 50 | int get_line() { return _line; } 51 | 52 | void start(); 53 | 54 | const char *peek_string(char *buf, const char *prefix); 55 | const char *get_string(char *buf, const char *prefix); 56 | 57 | /*by ketor __int64_t*/int64_t get_int() { 58 | char buf[20]; 59 | return atoll(get_string(buf, 0)); 60 | } 61 | bool end() { 62 | return !fs || fs->eof(); 63 | //return _cur == _end; 64 | } 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /messages/MMDSOpenInoReply.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MDSOPENINOREPLY_H 16 | #define CEPH_MDSOPENINOREPLY_H 17 | 18 | #include "msg/Message.h" 19 | 20 | struct MMDSOpenInoReply : public Message { 21 | inodeno_t ino; 22 | vector ancestors; 23 | mds_rank_t hint; 24 | int32_t error; 25 | 26 | MMDSOpenInoReply() : Message(MSG_MDS_OPENINOREPLY) {} 27 | MMDSOpenInoReply(ceph_tid_t t, inodeno_t i, mds_rank_t h=MDS_RANK_NONE, int e=0) : 28 | Message(MSG_MDS_OPENINOREPLY), ino(i), hint(h), error(e) { 29 | header.tid = t; 30 | } 31 | 32 | const char *get_type_name() const { return "openinoreply"; } 33 | void print(ostream &out) const { 34 | out << "openinoreply(" << header.tid << " " 35 | << ino << " " << hint << " " << ancestors << ")"; 36 | } 37 | 38 | void encode_payload(uint64_t features) { 39 | ::encode(ino, payload); 40 | ::encode(ancestors, payload); 41 | ::encode(hint, payload); 42 | ::encode(error, payload); 43 | } 44 | void decode_payload() { 45 | bufferlist::iterator p = payload.begin(); 46 | ::decode(ino, p); 47 | ::decode(ancestors, p); 48 | ::decode(hint, p); 49 | ::decode(error, p); 50 | } 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /messages/MOSDECSubOpRead.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2013 Inktank Storage, Inc. 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef MOSDECSUBOPREAD_H 16 | #define MOSDECSUBOPREAD_H 17 | 18 | #include "msg/Message.h" 19 | #include "osd/osd_types.h" 20 | #include "osd/ECMsgTypes.h" 21 | 22 | class MOSDECSubOpRead : public Message { 23 | static const int HEAD_VERSION = 2; 24 | static const int COMPAT_VERSION = 1; 25 | 26 | public: 27 | spg_t pgid; 28 | epoch_t map_epoch; 29 | ECSubRead op; 30 | 31 | int get_cost() const { 32 | return 0; 33 | } 34 | 35 | MOSDECSubOpRead() : 36 | Message(MSG_OSD_EC_READ, HEAD_VERSION, COMPAT_VERSION) 37 | {} 38 | 39 | virtual void decode_payload() { 40 | bufferlist::iterator p = payload.begin(); 41 | ::decode(pgid, p); 42 | ::decode(map_epoch, p); 43 | ::decode(op, p); 44 | } 45 | 46 | virtual void encode_payload(uint64_t features) { 47 | ::encode(pgid, payload); 48 | ::encode(map_epoch, payload); 49 | ::encode(op, payload, features); 50 | } 51 | 52 | const char *get_type_name() const { return "MOSDECSubOpRead"; } 53 | 54 | void print(ostream& out) const { 55 | out << "MOSDECSubOpRead(" << pgid 56 | << " " << map_epoch 57 | << " " << op; 58 | out << ")"; 59 | } 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /messages/MMonCommand.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MMONCOMMAND_H 16 | #define CEPH_MMONCOMMAND_H 17 | 18 | #include "messages/PaxosServiceMessage.h" 19 | 20 | #include 21 | using std::vector; 22 | 23 | class MMonCommand : public PaxosServiceMessage { 24 | public: 25 | uuid_d fsid; 26 | vector cmd; 27 | 28 | MMonCommand() : PaxosServiceMessage(MSG_MON_COMMAND, 0) {} 29 | MMonCommand(const uuid_d &f) 30 | : PaxosServiceMessage(MSG_MON_COMMAND, 0), 31 | fsid(f) 32 | { } 33 | 34 | private: 35 | ~MMonCommand() {} 36 | 37 | public: 38 | const char *get_type_name() const { return "mon_command"; } 39 | void print(ostream& o) const { 40 | o << "mon_command("; 41 | for (unsigned i=0; i 8 | #include 9 | #elif defined(__FreeBSD__) 10 | #include 11 | #include 12 | #endif 13 | 14 | #define CEPH_IOCTL_MAGIC 0x97 15 | 16 | /* just use u64 to align sanely on all archs */ 17 | struct ceph_ioctl_layout { 18 | __u64 stripe_unit, stripe_count, object_size; 19 | __u64 data_pool; 20 | __s64 unused; 21 | }; 22 | 23 | #define CEPH_IOC_GET_LAYOUT _IOR(CEPH_IOCTL_MAGIC, 1, \ 24 | struct ceph_ioctl_layout) 25 | #define CEPH_IOC_SET_LAYOUT _IOW(CEPH_IOCTL_MAGIC, 2, \ 26 | struct ceph_ioctl_layout) 27 | #define CEPH_IOC_SET_LAYOUT_POLICY _IOW(CEPH_IOCTL_MAGIC, 5, \ 28 | struct ceph_ioctl_layout) 29 | 30 | /* 31 | * Extract identity, address of the OSD and object storing a given 32 | * file offset. 33 | */ 34 | struct ceph_ioctl_dataloc { 35 | __u64 file_offset; /* in+out: file offset */ 36 | __u64 object_offset; /* out: offset in object */ 37 | __u64 object_no; /* out: object # */ 38 | __u64 object_size; /* out: object size */ 39 | char object_name[64]; /* out: object name */ 40 | __u64 block_offset; /* out: offset in block */ 41 | __u64 block_size; /* out: block length */ 42 | __s64 osd; /* out: osd # */ 43 | struct sockaddr_storage osd_addr; /* out: osd address */ 44 | }; 45 | 46 | #define CEPH_IOC_GET_DATALOC _IOWR(CEPH_IOCTL_MAGIC, 3, \ 47 | struct ceph_ioctl_dataloc) 48 | 49 | #define CEPH_IOC_LAZYIO _IO(CEPH_IOCTL_MAGIC, 4) 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /messages/MLog.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MLOG_H 16 | #define CEPH_MLOG_H 17 | 18 | #include "common/LogEntry.h" 19 | #include "messages/PaxosServiceMessage.h" 20 | 21 | #include 22 | #include 23 | 24 | class MLog : public PaxosServiceMessage { 25 | public: 26 | uuid_d fsid; 27 | std::deque entries; 28 | 29 | MLog() : PaxosServiceMessage(MSG_LOG, 0) {} 30 | MLog(const uuid_d& f, const std::deque& e) 31 | : PaxosServiceMessage(MSG_LOG, 0), fsid(f), entries(e) { } 32 | MLog(const uuid_d& f) : PaxosServiceMessage(MSG_LOG, 0), fsid(f) { } 33 | private: 34 | ~MLog() {} 35 | 36 | public: 37 | const char *get_type_name() const { return "log"; } 38 | void print(ostream& out) const { 39 | out << "log("; 40 | if (entries.size()) 41 | out << entries.size() << " entries"; 42 | out << ")"; 43 | } 44 | 45 | void encode_payload(uint64_t features) { 46 | paxos_encode(); 47 | ::encode(fsid, payload); 48 | ::encode(entries, payload); 49 | } 50 | void decode_payload() { 51 | bufferlist::iterator p = payload.begin(); 52 | paxos_decode(p); 53 | ::decode(fsid, p); 54 | ::decode(entries, p); 55 | } 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /common/escape.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_RGW_ESCAPE_H 16 | #define CEPH_RGW_ESCAPE_H 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | /* Returns the length of a buffer that would be needed to escape 'buf' 23 | * as an XML attrribute 24 | */ 25 | int escape_xml_attr_len(const char *buf); 26 | 27 | /* Escapes 'buf' as an XML attribute. Assumes that 'out' is at least long 28 | * enough to fit the output. You can find out the required length by calling 29 | * escape_xml_attr_len first. 30 | */ 31 | void escape_xml_attr(const char *buf, char *out); 32 | 33 | /* Returns the length of a buffer that would be needed to escape 'buf' 34 | * as an JSON attrribute 35 | */ 36 | int escape_json_attr_len(const char *buf, int src_len); 37 | 38 | /* Escapes 'buf' as an JSON attribute. Assumes that 'out' is at least long 39 | * enough to fit the output. You can find out the required length by calling 40 | * escape_json_attr_len first. 41 | */ 42 | void escape_json_attr(const char *buf, int src_len, char *out); 43 | 44 | /* Note: we escape control characters. Although the XML spec doesn't actually 45 | * require this, Amazon does it in their XML responses. 46 | */ 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /osdc/WritebackHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | #ifndef CEPH_OSDC_WRITEBACKHANDLER_H 4 | #define CEPH_OSDC_WRITEBACKHANDLER_H 5 | 6 | #include "include/Context.h" 7 | #include "include/types.h" 8 | #include "osd/osd_types.h" 9 | 10 | class WritebackHandler { 11 | public: 12 | WritebackHandler() {} 13 | virtual ~WritebackHandler() {} 14 | 15 | virtual void read(const object_t& oid, uint64_t object_no, 16 | const object_locator_t& oloc, uint64_t off, uint64_t len, 17 | snapid_t snapid, bufferlist *pbl, uint64_t trunc_size, 18 | __u32 trunc_seq, int op_flags, Context *onfinish) = 0; 19 | /** 20 | * check if a given extent read result may change due to a write 21 | * 22 | * Check if the content we see at the given read offset may change due to a write to 23 | * this object. 24 | * 25 | * @param oid object 26 | * @param read_off read offset 27 | * @param read_len read length 28 | * @param snapid read snapid 29 | */ 30 | virtual bool may_copy_on_write(const object_t& oid, uint64_t read_off, uint64_t read_len, snapid_t snapid) = 0; 31 | virtual ceph_tid_t write(const object_t& oid, const object_locator_t& oloc, 32 | uint64_t off, uint64_t len, const SnapContext& snapc, 33 | const bufferlist &bl, utime_t mtime, 34 | uint64_t trunc_size, __u32 trunc_seq, 35 | Context *oncommit) = 0; 36 | virtual ceph_tid_t lock(const object_t& oid, const object_locator_t& oloc, 37 | int op, int flags, Context *onack, Context *oncommit) { 38 | assert(0 == "this WritebackHandler does not support the lock operation"); 39 | } 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /client/ClientSnapRealm.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #ifndef CEPH_CLIENT_SNAPREALM_H 5 | #define CEPH_CLIENT_SNAPREALM_H 6 | 7 | #include "include/types.h" 8 | #include "common/snap_types.h" 9 | #include "include/xlist.h" 10 | 11 | struct Inode; 12 | 13 | struct SnapRealm { 14 | inodeno_t ino; 15 | int nref; 16 | snapid_t created; 17 | snapid_t seq; 18 | 19 | inodeno_t parent; 20 | snapid_t parent_since; 21 | vector prior_parent_snaps; // snaps prior to parent_since 22 | vector my_snaps; 23 | 24 | SnapRealm *pparent; 25 | set pchildren; 26 | 27 | private: 28 | SnapContext cached_snap_context; // my_snaps + parent snaps + past_parent_snaps 29 | friend ostream& operator<<(ostream& out, const SnapRealm& r); 30 | 31 | public: 32 | xlist inodes_with_caps; 33 | 34 | SnapRealm(inodeno_t i) : 35 | ino(i), nref(0), created(0), seq(0), 36 | pparent(NULL) { } 37 | 38 | void build_snap_context(); 39 | void invalidate_cache() { 40 | cached_snap_context.clear(); 41 | } 42 | 43 | const SnapContext& get_snap_context() { 44 | if (cached_snap_context.seq == 0) 45 | build_snap_context(); 46 | return cached_snap_context; 47 | } 48 | 49 | void dump(Formatter *f) const; 50 | }; 51 | 52 | inline ostream& operator<<(ostream& out, const SnapRealm& r) { 53 | return out << "snaprealm(" << r.ino << " nref=" << r.nref << " c=" << r.created << " seq=" << r.seq 54 | << " parent=" << r.parent 55 | << " my_snaps=" << r.my_snaps 56 | << " cached_snapc=" << r.cached_snap_context 57 | << ")"; 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /messages/MOSDECSubOpReadReply.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2013 Inktank Storage, Inc. 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef MOSDECSUBOPREADREPLY_H 16 | #define MOSDECSUBOPREADREPLY_H 17 | 18 | #include "msg/Message.h" 19 | #include "osd/osd_types.h" 20 | #include "osd/ECMsgTypes.h" 21 | 22 | class MOSDECSubOpReadReply : public Message { 23 | static const int HEAD_VERSION = 1; 24 | static const int COMPAT_VERSION = 1; 25 | 26 | public: 27 | spg_t pgid; 28 | epoch_t map_epoch; 29 | ECSubReadReply op; 30 | 31 | int get_cost() const { 32 | return 0; 33 | } 34 | 35 | MOSDECSubOpReadReply() : 36 | Message(MSG_OSD_EC_READ_REPLY, HEAD_VERSION, COMPAT_VERSION) 37 | {} 38 | 39 | virtual void decode_payload() { 40 | bufferlist::iterator p = payload.begin(); 41 | ::decode(pgid, p); 42 | ::decode(map_epoch, p); 43 | ::decode(op, p); 44 | } 45 | 46 | virtual void encode_payload(uint64_t features) { 47 | ::encode(pgid, payload); 48 | ::encode(map_epoch, payload); 49 | ::encode(op, payload); 50 | } 51 | 52 | const char *get_type_name() const { return "MOSDECSubOpReadReply"; } 53 | 54 | void print(ostream& out) const { 55 | out << "MOSDECSubOpReadReply(" << pgid 56 | << " " << map_epoch 57 | << " " << op; 58 | out << ")"; 59 | } 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /include/hash.h: -------------------------------------------------------------------------------- 1 | #ifndef CEPH_HASH_H 2 | #define CEPH_HASH_H 3 | 4 | #include "acconfig.h" 5 | 6 | // Robert Jenkins' function for mixing 32-bit values 7 | // http://burtleburtle.net/bob/hash/evahash.html 8 | // a, b = random bits, c = input and output 9 | 10 | #define hashmix(a,b,c) \ 11 | a=a-b; a=a-c; a=a^(c>>13); \ 12 | b=b-c; b=b-a; b=b^(a<<8); \ 13 | c=c-a; c=c-b; c=c^(b>>13); \ 14 | a=a-b; a=a-c; a=a^(c>>12); \ 15 | b=b-c; b=b-a; b=b^(a<<16); \ 16 | c=c-a; c=c-b; c=c^(b>>5); \ 17 | a=a-b; a=a-c; a=a^(c>>3); \ 18 | b=b-c; b=b-a; b=b^(a<<10); \ 19 | c=c-a; c=c-b; c=c^(b>>15); 20 | 21 | 22 | //namespace ceph { 23 | 24 | template struct rjhash { }; 25 | 26 | inline uint64_t rjhash64(uint64_t key) { 27 | key = (~key) + (key << 21); // key = (key << 21) - key - 1; 28 | key = key ^ (key >> 24); 29 | key = (key + (key << 3)) + (key << 8); // key * 265 30 | key = key ^ (key >> 14); 31 | key = (key + (key << 2)) + (key << 4); // key * 21 32 | key = key ^ (key >> 28); 33 | key = key + (key << 31); 34 | return key; 35 | } 36 | 37 | inline uint32_t rjhash32(uint32_t a) { 38 | a = (a+0x7ed55d16) + (a<<12); 39 | a = (a^0xc761c23c) ^ (a>>19); 40 | a = (a+0x165667b1) + (a<<5); 41 | a = (a+0xd3a2646c) ^ (a<<9); 42 | a = (a+0xfd7046c5) + (a<<3); 43 | a = (a^0xb55a4f09) ^ (a>>16); 44 | return a; 45 | } 46 | 47 | 48 | template<> struct rjhash { 49 | inline size_t operator()(const uint32_t x) const { 50 | return rjhash32(x); 51 | } 52 | }; 53 | 54 | template<> struct rjhash { 55 | inline size_t operator()(const uint64_t x) const { 56 | return rjhash64(x); 57 | } 58 | }; 59 | 60 | //} 61 | 62 | 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /messages/MOSDECSubOpWriteReply.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2013 Inktank Storage, Inc. 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef MOSDECSUBOPWRITEREPLY_H 16 | #define MOSDECSUBOPWRITEREPLY_H 17 | 18 | #include "msg/Message.h" 19 | #include "osd/osd_types.h" 20 | #include "osd/ECMsgTypes.h" 21 | 22 | class MOSDECSubOpWriteReply : public Message { 23 | static const int HEAD_VERSION = 1; 24 | static const int COMPAT_VERSION = 1; 25 | 26 | public: 27 | spg_t pgid; 28 | epoch_t map_epoch; 29 | ECSubWriteReply op; 30 | 31 | int get_cost() const { 32 | return 0; 33 | } 34 | 35 | MOSDECSubOpWriteReply() : 36 | Message(MSG_OSD_EC_WRITE_REPLY, HEAD_VERSION, COMPAT_VERSION) 37 | {} 38 | 39 | virtual void decode_payload() { 40 | bufferlist::iterator p = payload.begin(); 41 | ::decode(pgid, p); 42 | ::decode(map_epoch, p); 43 | ::decode(op, p); 44 | } 45 | 46 | virtual void encode_payload(uint64_t features) { 47 | ::encode(pgid, payload); 48 | ::encode(map_epoch, payload); 49 | ::encode(op, payload); 50 | } 51 | 52 | const char *get_type_name() const { return "MOSDECSubOpWriteReply"; } 53 | 54 | void print(ostream& out) const { 55 | out << "MOSDECSubOpWriteReply(" << pgid 56 | << " " << map_epoch 57 | << " " << op; 58 | out << ")"; 59 | } 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /messages/MExportDir.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MEXPORTDIR_H 17 | #define CEPH_MEXPORTDIR_H 18 | 19 | #include "msg/Message.h" 20 | 21 | 22 | class MExportDir : public Message { 23 | public: 24 | dirfrag_t dirfrag; 25 | bufferlist export_data; 26 | vector bounds; 27 | bufferlist client_map; 28 | 29 | MExportDir() : Message(MSG_MDS_EXPORTDIR) {} 30 | MExportDir(dirfrag_t df, uint64_t tid) : 31 | Message(MSG_MDS_EXPORTDIR), dirfrag(df) { 32 | set_tid(tid); 33 | } 34 | private: 35 | ~MExportDir() {} 36 | 37 | public: 38 | const char *get_type_name() const { return "Ex"; } 39 | void print(ostream& o) const { 40 | o << "export(" << dirfrag << ")"; 41 | } 42 | 43 | void add_export(dirfrag_t df) { 44 | bounds.push_back(df); 45 | } 46 | 47 | void encode_payload(uint64_t features) { 48 | ::encode(dirfrag, payload); 49 | ::encode(bounds, payload); 50 | ::encode(export_data, payload); 51 | ::encode(client_map, payload); 52 | } 53 | void decode_payload() { 54 | bufferlist::iterator p = payload.begin(); 55 | ::decode(dirfrag, p); 56 | ::decode(bounds, p); 57 | ::decode(export_data, p); 58 | ::decode(client_map, p); 59 | } 60 | 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /messages/MHeartbeat.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_MHEARTBEAT_H 17 | #define CEPH_MHEARTBEAT_H 18 | 19 | #include "include/types.h" 20 | #include "msg/Message.h" 21 | 22 | class MHeartbeat : public Message { 23 | mds_load_t load; 24 | __s32 beat; 25 | map import_map; 26 | 27 | public: 28 | mds_load_t& get_load() { return load; } 29 | int get_beat() { return beat; } 30 | 31 | map& get_import_map() { 32 | return import_map; 33 | } 34 | 35 | MHeartbeat() 36 | : Message(MSG_MDS_HEARTBEAT), load(utime_t()) { } 37 | MHeartbeat(mds_load_t& load, int beat) 38 | : Message(MSG_MDS_HEARTBEAT), 39 | load(load) { 40 | this->beat = beat; 41 | } 42 | private: 43 | ~MHeartbeat() {} 44 | 45 | public: 46 | const char *get_type_name() const { return "HB"; } 47 | 48 | void encode_payload(uint64_t features) { 49 | ::encode(load, payload); 50 | ::encode(beat, payload); 51 | ::encode(import_map, payload); 52 | } 53 | void decode_payload() { 54 | bufferlist::iterator p = payload.begin(); 55 | utime_t now(ceph_clock_now(NULL)); 56 | ::decode(load, now, p); 57 | ::decode(beat, p); 58 | ::decode(import_map, p); 59 | } 60 | 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /messages/MMDSLoadTargets.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MMDSLoadTargets_H 16 | #define CEPH_MMDSLoadTargets_H 17 | 18 | #include "msg/Message.h" 19 | #include "messages/PaxosServiceMessage.h" 20 | #include "include/types.h" 21 | 22 | #include 23 | using std::map; 24 | 25 | class MMDSLoadTargets : public PaxosServiceMessage { 26 | public: 27 | mds_gid_t global_id; 28 | set targets; 29 | 30 | MMDSLoadTargets() : PaxosServiceMessage(MSG_MDS_OFFLOAD_TARGETS, 0) {} 31 | 32 | MMDSLoadTargets(mds_gid_t g, set& mds_targets) : 33 | PaxosServiceMessage(MSG_MDS_OFFLOAD_TARGETS, 0), 34 | global_id(g), targets(mds_targets) {} 35 | private: 36 | ~MMDSLoadTargets() {} 37 | 38 | public: 39 | const char* get_type_name() const { return "mds_load_targets"; } 40 | void print(ostream& o) const { 41 | o << "mds_load_targets(" << global_id << " " << targets << ")"; 42 | } 43 | 44 | void decode_payload() { 45 | bufferlist::iterator p = payload.begin(); 46 | paxos_decode(p); 47 | ::decode(global_id, p); 48 | ::decode(targets, p); 49 | } 50 | 51 | void encode_payload(uint64_t features) { 52 | paxos_encode(); 53 | ::encode(global_id, payload); 54 | ::encode(targets, payload); 55 | } 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /auth/AuthAuthorizeHandler.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2009-2011 New Dream Network 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #include "common/debug.h" 16 | #include "Auth.h" 17 | #include "AuthAuthorizeHandler.h" 18 | #include "cephx/CephxAuthorizeHandler.h" 19 | #include "none/AuthNoneAuthorizeHandler.h" 20 | #include "AuthMethodList.h" 21 | #include "common/Mutex.h" 22 | 23 | #define dout_subsys ceph_subsys_auth 24 | 25 | AuthAuthorizeHandler *AuthAuthorizeHandlerRegistry::get_handler(int protocol) 26 | { 27 | if (!supported.is_supported_auth(protocol)) { 28 | return NULL; 29 | } 30 | 31 | Mutex::Locker l(m_lock); 32 | map::iterator iter = m_authorizers.find(protocol); 33 | if (iter != m_authorizers.end()) 34 | return iter->second; 35 | 36 | switch (protocol) { 37 | case CEPH_AUTH_NONE: 38 | m_authorizers[protocol] = new AuthNoneAuthorizeHandler(); 39 | return m_authorizers[protocol]; 40 | 41 | case CEPH_AUTH_CEPHX: 42 | m_authorizers[protocol] = new CephxAuthorizeHandler(); 43 | return m_authorizers[protocol]; 44 | } 45 | return NULL; 46 | } 47 | 48 | AuthAuthorizeHandlerRegistry::~AuthAuthorizeHandlerRegistry() 49 | { 50 | for (map::iterator iter = m_authorizers.begin(); 51 | iter != m_authorizers.end(); 52 | ++iter) 53 | delete iter->second; 54 | } 55 | -------------------------------------------------------------------------------- /client/MetaSession.cc: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #include "include/types.h" 5 | #include "messages/MClientCapRelease.h" 6 | 7 | #include "MetaSession.h" 8 | 9 | #include "common/Formatter.h" 10 | 11 | const char *MetaSession::get_state_name() const 12 | { 13 | switch (state) { 14 | case STATE_NEW: return "new"; 15 | case STATE_OPENING: return "opening"; 16 | case STATE_OPEN: return "open"; 17 | case STATE_CLOSING: return "closing"; 18 | case STATE_CLOSED: return "closed"; 19 | case STATE_STALE: return "stale"; 20 | default: return "unknown"; 21 | } 22 | } 23 | 24 | void MetaSession::dump(Formatter *f) const 25 | { 26 | f->dump_int("mds", mds_num); 27 | f->dump_stream("addr") << inst.addr; 28 | f->dump_unsigned("seq", seq); 29 | f->dump_unsigned("cap_gen", cap_gen); 30 | f->dump_stream("cap_ttl") << cap_ttl; 31 | f->dump_stream("last_cap_renew_request") << last_cap_renew_request; 32 | f->dump_unsigned("cap_renew_seq", cap_renew_seq); 33 | f->dump_int("num_caps", num_caps); 34 | f->dump_string("state", get_state_name()); 35 | } 36 | 37 | MetaSession::~MetaSession() 38 | { 39 | if (release) 40 | release->put(); 41 | } 42 | 43 | void MetaSession::enqueue_cap_release(inodeno_t ino, uint64_t cap_id, ceph_seq_t iseq, 44 | ceph_seq_t mseq, epoch_t osd_barrier) 45 | { 46 | if (!release) { 47 | release = new MClientCapRelease; 48 | } 49 | 50 | if (osd_barrier > release->osd_epoch_barrier) { 51 | release->osd_epoch_barrier = osd_barrier; 52 | } 53 | 54 | ceph_mds_cap_item i; 55 | i.ino = ino; 56 | i.cap_id = cap_id; 57 | i.seq = iseq; 58 | i.migrate_seq = mseq; 59 | release->caps.push_back(i); 60 | } 61 | -------------------------------------------------------------------------------- /auth/none/AuthNoneClientHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_AUTHNONECLIENTHANDLER_H 16 | #define CEPH_AUTHNONECLIENTHANDLER_H 17 | 18 | #include "../AuthClientHandler.h" 19 | #include "AuthNoneProtocol.h" 20 | 21 | class CephContext; 22 | 23 | class AuthNoneClientHandler : public AuthClientHandler { 24 | public: 25 | AuthNoneClientHandler(CephContext *cct_, RotatingKeyRing *rkeys) 26 | : AuthClientHandler(cct_) {} 27 | 28 | void reset() { } 29 | 30 | void prepare_build_request() {} 31 | int build_request(bufferlist& bl) const { return 0; } 32 | int handle_response(int ret, bufferlist::iterator& iter) { return 0; } 33 | bool build_rotating_request(bufferlist& bl) const { return false; } 34 | 35 | int get_protocol() const { return CEPH_AUTH_NONE; } 36 | 37 | AuthAuthorizer *build_authorizer(uint32_t service_id) const { 38 | RWLock::RLocker l(lock); 39 | AuthNoneAuthorizer *auth = new AuthNoneAuthorizer(); 40 | if (auth) { 41 | auth->build_authorizer(cct->_conf->name, global_id); 42 | } 43 | return auth; 44 | } 45 | 46 | bool need_tickets() { return false; } 47 | 48 | void set_global_id(uint64_t id) { 49 | RWLock::WLocker l(lock); 50 | global_id = id; 51 | } 52 | private: 53 | void validate_tickets() {} 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /client/MetaSession.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #ifndef CEPH_CLIENT_METASESSION_H 5 | #define CEPH_CLIENT_METASESSION_H 6 | 7 | #include "include/types.h" 8 | #include "include/utime.h" 9 | #include "msg/msg_types.h" 10 | #include "include/xlist.h" 11 | 12 | #include "messages/MClientCapRelease.h" 13 | #include "mds/MDSMap.h" 14 | 15 | struct Cap; 16 | struct Inode; 17 | struct CapSnap; 18 | struct MetaRequest; 19 | class MClientCapRelease; 20 | 21 | struct MetaSession { 22 | mds_rank_t mds_num; 23 | ConnectionRef con; 24 | version_t seq; 25 | uint64_t cap_gen; 26 | utime_t cap_ttl, last_cap_renew_request; 27 | uint64_t cap_renew_seq; 28 | int num_caps; 29 | entity_inst_t inst; 30 | 31 | enum { 32 | STATE_NEW, 33 | STATE_OPENING, 34 | STATE_OPEN, 35 | STATE_CLOSING, 36 | STATE_CLOSED, 37 | STATE_STALE, 38 | } state; 39 | 40 | bool readonly; 41 | 42 | list waiting_for_open; 43 | 44 | xlist caps; 45 | xlist flushing_caps; 46 | xlist flushing_capsnaps; 47 | xlist requests; 48 | xlist unsafe_requests; 49 | 50 | Cap *s_cap_iterator; 51 | 52 | MClientCapRelease *release; 53 | 54 | MetaSession() 55 | : mds_num(-1), con(NULL), 56 | seq(0), cap_gen(0), cap_renew_seq(0), num_caps(0), 57 | state(STATE_NEW), readonly(false), s_cap_iterator(NULL), 58 | release(NULL) 59 | {} 60 | ~MetaSession(); 61 | 62 | const char *get_state_name() const; 63 | 64 | void dump(Formatter *f) const; 65 | 66 | void enqueue_cap_release(inodeno_t ino, uint64_t cap_id, ceph_seq_t iseq, 67 | ceph_seq_t mseq, epoch_t osd_barrier); 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /include/Distribution.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | 16 | #ifndef CEPH_DISTRIBUTION_H 17 | #define CEPH_DISTRIBUTION_H 18 | 19 | #include 20 | using namespace std; 21 | 22 | class Distribution { 23 | vector p; 24 | vector v; 25 | 26 | public: 27 | //Distribution() { 28 | //} 29 | 30 | unsigned get_width() { 31 | return p.size(); 32 | } 33 | 34 | void clear() { 35 | p.clear(); 36 | v.clear(); 37 | } 38 | void add(int val, float pr) { 39 | p.push_back(pr); 40 | v.push_back(val); 41 | } 42 | 43 | void random() { 44 | float sum = 0.0; 45 | for (unsigned i=0; i= 1020) 10 | # pragma once 11 | #endif 12 | 13 | #include 14 | 15 | namespace json_spirit 16 | { 17 | // An Error_position exception is thrown by the "read_or_throw" functions below on finding an error. 18 | // Note the "read_or_throw" functions are around 3 times slower than the standard functions "read" 19 | // functions that return a bool. 20 | // 21 | struct Error_position 22 | { 23 | Error_position(); 24 | Error_position( unsigned int line, unsigned int column, const std::string& reason ); 25 | bool operator==( const Error_position& lhs ) const; 26 | unsigned int line_; 27 | unsigned int column_; 28 | std::string reason_; 29 | }; 30 | 31 | inline Error_position::Error_position() 32 | : line_( 0 ) 33 | , column_( 0 ) 34 | { 35 | } 36 | 37 | inline Error_position::Error_position( unsigned int line, unsigned int column, const std::string& reason ) 38 | : line_( line ) 39 | , column_( column ) 40 | , reason_( reason ) 41 | { 42 | } 43 | 44 | inline bool Error_position::operator==( const Error_position& lhs ) const 45 | { 46 | if( this == &lhs ) return true; 47 | 48 | return ( reason_ == lhs.reason_ ) && 49 | ( line_ == lhs.line_ ) && 50 | ( column_ == lhs.column_ ); 51 | } 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /log/SubsystemMap.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | 4 | #ifndef CEPH_LOG_SUBSYSTEMS 5 | #define CEPH_LOG_SUBSYSTEMS 6 | 7 | #include 8 | #include 9 | 10 | #include "include/assert.h" 11 | 12 | namespace ceph { 13 | namespace log { 14 | 15 | struct Subsystem { 16 | int log_level, gather_level; 17 | std::string name; 18 | 19 | Subsystem() : log_level(0), gather_level(0) {} 20 | }; 21 | 22 | class SubsystemMap { 23 | std::vector m_subsys; 24 | unsigned m_max_name_len; 25 | 26 | friend class Log; 27 | 28 | public: 29 | SubsystemMap() : m_max_name_len(0) {} 30 | 31 | int get_num() const { 32 | return m_subsys.size(); 33 | } 34 | 35 | int get_max_subsys_len() const { 36 | return m_max_name_len; 37 | } 38 | 39 | void add(unsigned subsys, std::string name, int log, int gather); 40 | void set_log_level(unsigned subsys, int log); 41 | void set_gather_level(unsigned subsys, int gather); 42 | 43 | int get_log_level(unsigned subsys) const { 44 | if (subsys >= m_subsys.size()) 45 | subsys = 0; 46 | return m_subsys[subsys].log_level; 47 | } 48 | 49 | int get_gather_level(unsigned subsys) const { 50 | if (subsys >= m_subsys.size()) 51 | subsys = 0; 52 | return m_subsys[subsys].gather_level; 53 | } 54 | 55 | const std::string& get_name(unsigned subsys) const { 56 | if (subsys >= m_subsys.size()) 57 | subsys = 0; 58 | return m_subsys[subsys].name; 59 | } 60 | 61 | bool should_gather(unsigned sub, int level) { 62 | assert(sub < m_subsys.size()); 63 | return level <= m_subsys[sub].gather_level || 64 | level <= m_subsys[sub].log_level; 65 | } 66 | }; 67 | 68 | } 69 | } 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /messages/MAuth.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2006 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_MAUTH_H 16 | #define CEPH_MAUTH_H 17 | 18 | #include "messages/PaxosServiceMessage.h" 19 | 20 | struct MAuth : public PaxosServiceMessage { 21 | __u32 protocol; 22 | bufferlist auth_payload; 23 | epoch_t monmap_epoch; 24 | 25 | /* if protocol == 0, then auth_payload is a set<__u32> listing protocols the client supports */ 26 | 27 | MAuth() : PaxosServiceMessage(CEPH_MSG_AUTH, 0), protocol(0), monmap_epoch(0) { } 28 | private: 29 | ~MAuth() {} 30 | 31 | public: 32 | const char *get_type_name() const { return "auth"; } 33 | void print(ostream& out) const { 34 | out << "auth(proto " << protocol << " " << auth_payload.length() << " bytes" 35 | << " epoch " << monmap_epoch << ")"; 36 | } 37 | 38 | void decode_payload() { 39 | bufferlist::iterator p = payload.begin(); 40 | paxos_decode(p); 41 | ::decode(protocol, p); 42 | ::decode(auth_payload, p); 43 | if (!p.end()) 44 | ::decode(monmap_epoch, p); 45 | else 46 | monmap_epoch = 0; 47 | } 48 | void encode_payload(uint64_t features) { 49 | paxos_encode(); 50 | ::encode(protocol, payload); 51 | ::encode(auth_payload, payload); 52 | ::encode(monmap_epoch, payload); 53 | } 54 | bufferlist& get_auth_payload() { return auth_payload; } 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /auth/unknown/AuthUnknownClientHandler.h: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2004-2009 Sage Weil 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_AUTHUNKNOWNCLIENTHANDLER_H 16 | #define CEPH_AUTHUNKNOWNCLIENTHANDLER_H 17 | 18 | #include "../AuthClientHandler.h" 19 | #include "AuthUnknownProtocol.h" 20 | 21 | class CephContext; 22 | 23 | class AuthUnknownClientHandler : public AuthClientHandler { 24 | public: 25 | AuthUnknownClientHandler(CephContext *cct_, RotatingKeyRing *rkeys) 26 | : AuthClientHandler(cct_) {} 27 | 28 | void reset() { } 29 | 30 | void prepare_build_request() {} 31 | int build_request(bufferlist& bl) const { return 0; } 32 | int handle_response(int ret, bufferlist::iterator& iter) { return 0; } 33 | bool build_rotating_request(bufferlist& bl) const { return false; } 34 | 35 | int get_protocol() const { return CEPH_AUTH_UNKNOWN; } 36 | 37 | AuthAuthorizer *build_authorizer(uint32_t service_id) const { 38 | RWLock::RLocker l(lock); 39 | AuthUnknownAuthorizer *auth = new AuthUnknownAuthorizer(); 40 | if (auth) { 41 | auth->build_authorizer(cct->_conf->name, global_id); 42 | } 43 | return auth; 44 | } 45 | 46 | bool need_tickets() { return false; } 47 | 48 | void set_global_id(uint64_t id) { 49 | RWLock::WLocker l(lock); 50 | global_id = id; 51 | } 52 | private: 53 | void validate_tickets() { } 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /common/tracked_int_ptr.hpp: -------------------------------------------------------------------------------- 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 2 | // vim: ts=8 sw=2 smarttab 3 | /* 4 | * Ceph - scalable distributed file system 5 | * 6 | * Copyright (C) 2013 Inktank Storage, Inc. 7 | * 8 | * This is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License version 2.1, as published by the Free Software 11 | * Foundation. See file COPYING. 12 | * 13 | */ 14 | 15 | #ifndef CEPH_TRACKEDINTPTR_H 16 | #define CEPH_TRACKEDINTPTR_H 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include "common/Mutex.h" 23 | #include "common/Cond.h" 24 | 25 | template 26 | class TrackedIntPtr { 27 | T *ptr; 28 | uint64_t id; 29 | public: 30 | TrackedIntPtr() : ptr(NULL), id(0) {} 31 | TrackedIntPtr(T *ptr) : ptr(ptr), id(ptr ? get_with_id(ptr) : 0) {} 32 | ~TrackedIntPtr() { 33 | if (ptr) 34 | put_with_id(ptr, id); 35 | else 36 | assert(id == 0); 37 | } 38 | void swap(TrackedIntPtr &other) { 39 | T *optr = other.ptr; 40 | uint64_t oid = other.id; 41 | other.ptr = ptr; 42 | other.id = id; 43 | ptr = optr; 44 | id = oid; 45 | } 46 | TrackedIntPtr(const TrackedIntPtr &rhs) : 47 | ptr(rhs.ptr), id(ptr ? get_with_id(ptr) : 0) {} 48 | 49 | void operator=(const TrackedIntPtr &rhs) { 50 | TrackedIntPtr o(rhs.ptr); 51 | swap(o); 52 | } 53 | T &operator*() { 54 | return *ptr; 55 | } 56 | T *operator->() { 57 | return ptr; 58 | } 59 | bool operator<(const TrackedIntPtr &lhs) const { 60 | return ptr < lhs.ptr; 61 | } 62 | bool operator==(const TrackedIntPtr &lhs) const { 63 | return ptr == lhs.ptr; 64 | } 65 | }; 66 | 67 | #endif 68 | --------------------------------------------------------------------------------