mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
First cut of FreeBSD support. This patch allowes ceph to compile successfully
under FreeBSD. Signed-off-by: Stanislav Sedov <stas@FreeBSD.org>
This commit is contained in:
parent
0cd3e56224
commit
9fde4d946f
18
configure.ac
18
configure.ac
@ -24,7 +24,16 @@ AM_PROG_LIBTOOL
|
||||
case "${target_os}" in
|
||||
darwin*)
|
||||
AC_DEFINE([DARWIN], [1], [Define if darwin/osx])
|
||||
;;
|
||||
linux*)
|
||||
linux="yes"
|
||||
;;
|
||||
freebsd*)
|
||||
freebsd="yes"
|
||||
;;
|
||||
esac
|
||||
AM_CONDITIONAL(LINUX, test x"$linux" = x"yes")
|
||||
AM_CONDITIONAL(FREEBSD, test x"$freebsd" = x"yes")
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CXX
|
||||
@ -57,7 +66,9 @@ AC_CHECK_CC_FLAG([-Wignored-qualifiers], [WARN_IGNORED_QUALIFIERS])
|
||||
# Checks for libraries.
|
||||
AC_CHECK_LIB([m], [pow], [true], AC_MSG_FAILURE([libm not found]))
|
||||
AC_CHECK_LIB([pthread], [pthread_create], [true], AC_MSG_FAILURE([libpthread not found]))
|
||||
AC_CHECK_LIB([keyutils], [add_key], [true], AC_MSG_FAILURE([libkeyutils not found]))
|
||||
if test x"$linux" = x"yes"; then
|
||||
AC_CHECK_LIB([keyutils], [add_key], [true], AC_MSG_FAILURE([libkeyutils not found]))
|
||||
fi
|
||||
AC_CHECK_FUNCS([syncfs], AC_DEFINE([HAVE_SYS_SYNCFS], [1], [we have syncfs]), [])
|
||||
|
||||
# Find some crypto library for us to use, while letting user to decide which one to use.
|
||||
@ -225,8 +236,13 @@ AS_IF([test "x$with_hadoop" != xno],
|
||||
])])
|
||||
AM_CONDITIONAL(WITH_HADOOPCLIENT, [test "$HAVE_JNI" = "1"])
|
||||
|
||||
#
|
||||
# FreeBSD has it in base.
|
||||
#
|
||||
if test x"$freebsd" != x"yes"; then
|
||||
PKG_CHECK_MODULES([LIBEDIT], [libedit >= 2.11],
|
||||
[], AC_MSG_FAILURE([No usable version of libedit found.]))
|
||||
fi
|
||||
|
||||
#libatomic-ops? You want it!
|
||||
AC_ARG_WITH([libatomic-ops],
|
||||
|
@ -17,7 +17,13 @@ check_PROGRAMS =
|
||||
TESTS = $(check_PROGRAMS)
|
||||
|
||||
|
||||
EXTRALIBS = -lrt
|
||||
EXTRALIBS =
|
||||
if FREEBSD
|
||||
EXTRALIBS += -lexecinfo
|
||||
endif
|
||||
if LINUX
|
||||
EXTRALIBS += -lrt
|
||||
endif
|
||||
if WITH_PROFILER
|
||||
EXTRALIBS += -lprofiler
|
||||
endif
|
||||
@ -34,7 +40,10 @@ bin_PROGRAMS += ceph-mon
|
||||
# osd
|
||||
ceph_osd_SOURCES = ceph_osd.cc objclass/class_debug.cc \
|
||||
objclass/class_api.cc
|
||||
ceph_osd_LDADD = libosd.la libos.la $(LIBGLOBAL_LDA) -ldl
|
||||
ceph_osd_LDADD = libosd.la libos.la $(LIBGLOBAL_LDA)
|
||||
if LINUX
|
||||
ceph_osd_LDADD += -ldl
|
||||
endif
|
||||
bin_PROGRAMS += ceph-osd
|
||||
ceph_osd_CXXFLAGS = ${AM_CXXFLAGS}
|
||||
|
||||
@ -99,7 +108,9 @@ bin_PROGRAMS += monmaptool crushtool osdmaptool
|
||||
|
||||
mount_ceph_SOURCES = mount/mount.ceph.c common/armor.c common/safe_io.c common/secret.c include/addr_parsing.c
|
||||
mount_ceph_LDADD = -lkeyutils
|
||||
if LINUX
|
||||
sbin_PROGRAMS += mount.ceph
|
||||
endif
|
||||
|
||||
# user tools
|
||||
cephfs_SOURCES = cephfs.cc
|
||||
@ -297,7 +308,9 @@ bin_DEBUGPROGRAMS += scratchtool scratchtoolpp radosacl
|
||||
rbd_SOURCES = rbd.cc common/fiemap.cc common/secret.c
|
||||
rbd_CXXFLAGS = ${AM_CXXFLAGS}
|
||||
rbd_LDADD = libglobal.la librbd.la librados.la -lpthread -lm -lkeyutils $(CRYPTO_LIBS) $(EXTRALIBS)
|
||||
if LINUX
|
||||
bin_PROGRAMS += rbd
|
||||
endif
|
||||
|
||||
if WITH_RADOSGW
|
||||
my_libradosgw_src = \
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "common/hex.h"
|
||||
#include "common/safe_io.h"
|
||||
#include "include/ceph_fs.h"
|
||||
#include "include/compat.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -30,9 +30,9 @@ using namespace std;
|
||||
#include "global/global_init.h"
|
||||
#include "common/ceph_argparse.h"
|
||||
|
||||
#ifndef DARWIN
|
||||
#if !defined(DARWIN) && !defined(__FreeBSD__)
|
||||
#include <envz.h>
|
||||
#endif // DARWIN
|
||||
#endif // DARWIN || __FreeBSD__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -24,6 +24,9 @@
|
||||
|
||||
#include <sys/statvfs.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
@ -68,6 +71,8 @@ using namespace std;
|
||||
|
||||
#include "include/lru.h"
|
||||
|
||||
#include "include/compat.h"
|
||||
|
||||
#include "Client.h"
|
||||
#include "Inode.h"
|
||||
#include "Dentry.h"
|
||||
@ -4243,7 +4248,7 @@ void Client::fill_dirent(struct dirent *de, const char *name, int type, uint64_t
|
||||
de->d_name[255] = '\0';
|
||||
#ifndef __CYGWIN__
|
||||
de->d_ino = ino;
|
||||
#ifndef DARWIN
|
||||
#if !defined(DARWIN) && !defined(__FreeBSD__)
|
||||
de->d_off = next_off;
|
||||
#endif
|
||||
de->d_reclen = 1;
|
||||
|
@ -1,8 +1,14 @@
|
||||
#ifndef FS_CEPH_IOCTL_H
|
||||
#define FS_CEPH_IOCTL_H
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/ioctl.h>
|
||||
#include <linux/types.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include "include/inttypes.h"
|
||||
#endif
|
||||
|
||||
#define CEPH_IOCTL_MAGIC 0x97
|
||||
|
||||
|
@ -23,7 +23,11 @@
|
||||
#include "common/debug.h"
|
||||
#include "include/utime.h"
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#else
|
||||
#include <values.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
@ -35,6 +39,7 @@
|
||||
#include <syslog.h>
|
||||
|
||||
#include "include/assert.h"
|
||||
#include "include/compat.h"
|
||||
|
||||
///////////////////////////// Constants /////////////////////////////
|
||||
#define TIME_FMT "%04d-%02d-%02d %02d:%02d:%02d.%06ld"
|
||||
|
@ -131,7 +131,11 @@ void HeartbeatMap::check_touch_file()
|
||||
if (path.length()) {
|
||||
int fd = ::open(path.c_str(), O_WRONLY|O_CREAT, 0644);
|
||||
if (fd >= 0) {
|
||||
#if defined(__FreeBSD__)
|
||||
::futimes(fd, NULL);
|
||||
#else
|
||||
::futimens(fd, NULL);
|
||||
#endif
|
||||
::close(fd);
|
||||
} else {
|
||||
ldout(m_cct, 0) << "unable to touch " << path << ": "
|
||||
|
@ -90,6 +90,7 @@ void MemoryModel::_sample(snap *psnap)
|
||||
psnap->heap = heap >> 10;
|
||||
|
||||
// ...
|
||||
#if defined(__linux__)
|
||||
struct mallinfo mi = mallinfo();
|
||||
|
||||
psnap->malloc = mi.uordblks >> 10;
|
||||
@ -106,4 +107,7 @@ void MemoryModel::_sample(snap *psnap)
|
||||
<< "\t" << mi.hblks
|
||||
<< "\t" << mi.hblkhd / 1024
|
||||
<< std::endl;
|
||||
#else
|
||||
#warning "Not implemented!"
|
||||
#endif
|
||||
}
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "include/compat.h"
|
||||
|
||||
using std::ostringstream;
|
||||
|
||||
/*
|
||||
|
@ -1,5 +1,9 @@
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/errno.h>
|
||||
#else
|
||||
#include <sys/errno.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* base64 encode/decode.
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "common/simple_spin.h"
|
||||
#include "include/atomic.h"
|
||||
#include "include/types.h"
|
||||
#include "include/compat.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fstream>
|
||||
|
@ -19,7 +19,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#if defined(__linux__)
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
code_environment_t g_code_env = CODE_ENVIRONMENT_UTILITY;
|
||||
|
||||
@ -52,9 +54,14 @@ int get_process_name(char *buf, int len)
|
||||
* null-terminated. */
|
||||
return -ENAMETOOLONG;
|
||||
}
|
||||
#if defined(__FreeBSD__)
|
||||
#warning XXX
|
||||
return -ENAMETOOLONG;
|
||||
#else
|
||||
memset(buf, 0, len);
|
||||
ret = prctl(PR_GET_NAME, buf);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string get_process_name_cpp()
|
||||
|
@ -31,7 +31,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/fs.h>
|
||||
#endif
|
||||
#include "include/inttypes.h"
|
||||
#include "include/fiemap.h"
|
||||
|
||||
struct fiemap *read_fiemap(int fd)
|
||||
|
@ -20,6 +20,18 @@
|
||||
|
||||
#include <ext/hash_map>
|
||||
|
||||
#if defined(__FreeBSD__) && defined(__LP64__) // On FreeBSD pthread_t is a pointer.
|
||||
namespace __gnu_cxx {
|
||||
template<>
|
||||
struct hash<pthread_t>
|
||||
{
|
||||
size_t
|
||||
operator()(pthread_t __x) const
|
||||
{ return (uintptr_t)__x; }
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
/******* Constants **********/
|
||||
#define DOUT_SUBSYS lockdep
|
||||
#undef DOUT_COND
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
int pipe_cloexec(int pipefd[2])
|
||||
{
|
||||
#ifdef O_CLOEXEC
|
||||
#if defined(O_CLOEXEC) && !defined(__FreeBSD__)
|
||||
int ret;
|
||||
ret = pipe2(pipefd, O_CLOEXEC);
|
||||
if (ret) {
|
||||
|
@ -41,9 +41,12 @@ __FBSDID("$FreeBSD: src/sys/netinet/sctp_crc32.c,v 1.8 2007/05/08 17:01:10 rrs E
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/endian.h>
|
||||
#else
|
||||
#include <endian.h>
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef SCTP_USE_ADLER32
|
||||
|
||||
|
@ -1,7 +1,12 @@
|
||||
#ifndef CEPH_CRUSH_CRUSH_H
|
||||
#define CEPH_CRUSH_CRUSH_H
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/types.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
#include "include/inttypes.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CRUSH is a pseudo-random data distribution algorithm that
|
||||
|
@ -1,5 +1,10 @@
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/types.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
#include "include/inttypes.h"
|
||||
#endif
|
||||
#include "hash.h"
|
||||
|
||||
/*
|
||||
|
@ -40,6 +40,10 @@
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
#ifndef EBADE
|
||||
#define EBADE EFTYPE
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef char const* iterator_t;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "global/global_init.h"
|
||||
#include "global/pidfile.h"
|
||||
#include "global/signal_handler.h"
|
||||
#include "include/compat.h"
|
||||
#include "include/color.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
@ -23,6 +23,12 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "include/compat.h"
|
||||
|
||||
#define dout_prefix *_dout
|
||||
|
||||
static char pid_file[PATH_MAX] = "";
|
||||
|
@ -16,6 +16,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include <netdb.h>
|
||||
|
||||
#define BUF_SIZE 128
|
||||
|
@ -1,7 +1,12 @@
|
||||
#ifndef CEPH_ASSERT_H
|
||||
#define CEPH_ASSERT_H
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <features.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/cdefs.h>
|
||||
#define __GNUC_PREREQ(minor, major) __GNUC_PREREQ__(minor, major)
|
||||
#endif
|
||||
|
||||
#ifdef __CEPH__
|
||||
# include "acconfig.h"
|
||||
|
@ -15,7 +15,12 @@
|
||||
#ifndef CEPH_BUFFER_H
|
||||
#define CEPH_BUFFER_H
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/types.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
#include "include/inttypes.h"
|
||||
#endif
|
||||
|
||||
#ifndef _XOPEN_SOURCE
|
||||
# define _XOPEN_SOURCE 600
|
||||
@ -32,13 +37,14 @@
|
||||
void *valloc(size_t);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
#if defined(__linux__) // For malloc(2).
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h> // snprintf
|
||||
#include <string.h>
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
|
@ -7,7 +7,13 @@
|
||||
#ifndef CEPH_BYTEORDER_H
|
||||
#define CEPH_BYTEORDER_H
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <endian.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/endian.h>
|
||||
#else
|
||||
#error "Your platform is not yet supported."
|
||||
#endif
|
||||
|
||||
static __inline__ __u16 swab16(__u16 val)
|
||||
{
|
||||
|
@ -19,11 +19,20 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
// FreeBSD compatibility
|
||||
#ifdef __FreeBSD__
|
||||
typedef off_t loff_t;
|
||||
typedef off_t off64_t;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __USE_FILE_OFFSET64
|
||||
/*
|
||||
* On FreeBSD the offset is 64 bit, but libc doesn't announce it in the way glibc does.
|
||||
*/
|
||||
#if !defined(__FreeBSD__) && !defined(__USE_FILE_OFFSET64)
|
||||
# error libceph: must define __USE_FILE_OFFSET64 or readdir results will be corrupted
|
||||
#endif
|
||||
|
||||
|
22
src/include/compat.h
Normal file
22
src/include/compat.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Ceph - scalable distributed file system
|
||||
*
|
||||
* Copyright (C) 2011 Stanislav Sedov <stas@FreeBSD.org>
|
||||
*
|
||||
* This is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software
|
||||
* Foundation. See file COPYING.
|
||||
*/
|
||||
|
||||
#ifndef CEPH_COMPAT_H
|
||||
#define CEPH_COMPAT_H
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#define lseek64(fd, offset, whence) lseek(fd, offset, whence)
|
||||
#define ENODATA 61
|
||||
#define TEMP_FAILURE_RETRY
|
||||
#define MSG_MORE 0
|
||||
#endif /* !__FreeBSD__ */
|
||||
|
||||
#endif /* !CEPH_COMPAT_H */
|
@ -13,7 +13,11 @@
|
||||
# include "linux_fiemap.h"
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/ioctl.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#ifndef FS_IOC_FIEMAP
|
||||
# define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
|
||||
#endif
|
||||
|
@ -2,6 +2,27 @@
|
||||
#define CEPH_INTTYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#if defined(__linux__)
|
||||
#include <linux/types.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
typedef int8_t __s8;
|
||||
typedef uint8_t __u8;
|
||||
typedef int16_t __s16;
|
||||
typedef uint16_t __u16;
|
||||
typedef int32_t __s32;
|
||||
typedef uint32_t __u32;
|
||||
typedef int64_t __s64;
|
||||
typedef uint64_t __u64;
|
||||
|
||||
#define __bitwise__
|
||||
|
||||
typedef __u16 __bitwise__ __le16;
|
||||
typedef __u16 __bitwise__ __be16;
|
||||
typedef __u32 __bitwise__ __le32;
|
||||
typedef __u32 __bitwise__ __be32;
|
||||
typedef __u64 __bitwise__ __le64;
|
||||
typedef __u64 __bitwise__ __be64;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -11,7 +11,12 @@
|
||||
#ifndef _LINUX_FIEMAP_H
|
||||
#define _LINUX_FIEMAP_H
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/types.h>
|
||||
#elif defined(__FreeBSD_)
|
||||
#include <sys/types.h>
|
||||
#include "include/inttypes.h"
|
||||
#endif
|
||||
|
||||
struct fiemap_extent {
|
||||
__u64 fe_logical; /* logical offset in bytes for the start of
|
||||
|
@ -345,7 +345,11 @@ enum {
|
||||
CEPH_OSD_OP_FLAG_FAILOK = 2, /* continue despite failure */
|
||||
};
|
||||
|
||||
#if defined(ERESTART)
|
||||
#define EOLDSNAPC ERESTART /* ORDERSNAP flag set; writer has old snapc*/
|
||||
#else
|
||||
#define EOLDSNAPC EINTR /* ORDERSNAP flag set; writer has old snapc*/
|
||||
#endif
|
||||
#define EBLACKLISTED ESHUTDOWN /* blacklisted */
|
||||
|
||||
/* xattr comparison */
|
||||
|
@ -6,7 +6,12 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#if defined(__linux__)
|
||||
#include <linux/types.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
#include "include/inttypes.h"
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#ifndef CEPH_OSD_TMAP_SET
|
||||
|
@ -20,7 +20,11 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#if defined(__linux__)
|
||||
#include <linux/types.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include "../rados/librados.h"
|
||||
|
||||
|
@ -13,7 +13,11 @@
|
||||
#ifndef CEPH_RBD_TYPES_H
|
||||
#define CEPH_RBD_TYPES_H
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/types.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* rbd image 'foo' consists of objects
|
||||
|
@ -77,6 +77,12 @@ typedef long long off64_t;
|
||||
#define O_DIRECT 00040000
|
||||
#endif
|
||||
|
||||
// FreeBSD compatibility
|
||||
#ifdef __FreeBSD__
|
||||
typedef off_t loff_t;
|
||||
typedef off_t off64_t;
|
||||
#endif
|
||||
|
||||
// -- stl crap --
|
||||
|
||||
namespace __gnu_cxx {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#define _BACKWARD_BACKWARD_WARNING_H // make gcc 4.3 shut up about hash_*
|
||||
#endif
|
||||
|
||||
#include "include/compat.h"
|
||||
#include "common/entity_name.h"
|
||||
#include "common/errno.h"
|
||||
#include "common/safe_io.h"
|
||||
|
@ -1609,7 +1609,17 @@ void MDS::respawn()
|
||||
}
|
||||
new_argv[orig_argc] = NULL;
|
||||
|
||||
#if defined(__linux__)
|
||||
dout(1) << " cwd " << get_current_dir_name() << dendl;
|
||||
#else
|
||||
{
|
||||
#include <sys/param.h>
|
||||
char buf[PATH_MAX];
|
||||
|
||||
getcwd(buf, sizeof(buf));
|
||||
dout(1) << " cwd " << buf << dendl;
|
||||
}
|
||||
#endif
|
||||
|
||||
unblock_all_signals(NULL);
|
||||
execv(orig_argv[0], new_argv);
|
||||
|
@ -49,10 +49,14 @@
|
||||
#include "include/filepath.h"
|
||||
#include "common/Timer.h"
|
||||
#include "common/perf_counters.h"
|
||||
#include "include/compat.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <sys/xattr.h>
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
|
@ -5,7 +5,12 @@ typedef char bool;
|
||||
#define true 1
|
||||
|
||||
#include <netinet/in.h>
|
||||
#if defined(__linux__)
|
||||
#include <linux/types.h>
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <sys/types.h>
|
||||
#include "include/inttypes.h"
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
@ -22,6 +22,12 @@
|
||||
#include "common/config.h"
|
||||
#include "common/sync_filesystem.h"
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "include/compat.h"
|
||||
|
||||
#define DOUT_SUBSYS mon
|
||||
#undef dout_prefix
|
||||
#define dout_prefix _prefix(_dout, dir)
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include "common/config.h"
|
||||
#include "common/errno.h"
|
||||
|
||||
#include "include/compat.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#define DOUT_SUBSYS mon
|
||||
|
@ -39,6 +39,8 @@
|
||||
#include "common/safe_io.h"
|
||||
#include "include/page.h"
|
||||
|
||||
#include "include/compat.h"
|
||||
|
||||
#define DOUT_SUBSYS ms
|
||||
#undef dout_prefix
|
||||
#define dout_prefix _prefix(_dout, msgr)
|
||||
|
@ -43,13 +43,21 @@ int tcp_read_wait(int sd, int timeout)
|
||||
if (sd < 0)
|
||||
return -1;
|
||||
struct pollfd pfd;
|
||||
short evmask;
|
||||
pfd.fd = sd;
|
||||
pfd.events = POLLIN | POLLRDHUP;
|
||||
pfd.events = POLLIN;
|
||||
#if defined(__linux__)
|
||||
pfd.events |= POLLRDHUP;
|
||||
#endif
|
||||
|
||||
if (poll(&pfd, 1, timeout) <= 0)
|
||||
return -1;
|
||||
|
||||
if (pfd.revents & (POLLERR | POLLHUP | POLLRDHUP | POLLNVAL))
|
||||
evmask = POLLERR | POLLHUP | POLLNVAL;
|
||||
#if defined(__linux__)
|
||||
evmask |= POLLRDHUP;
|
||||
#endif
|
||||
if (pfd.revents & evmask)
|
||||
return -1;
|
||||
|
||||
if (!(pfd.revents & POLLIN))
|
||||
@ -90,7 +98,10 @@ int tcp_write(CephContext *cct, int sd, const char *buf, int len)
|
||||
return -1;
|
||||
struct pollfd pfd;
|
||||
pfd.fd = sd;
|
||||
pfd.events = POLLOUT | POLLHUP | POLLRDHUP | POLLNVAL | POLLERR;
|
||||
pfd.events = POLLOUT | POLLHUP | POLLNVAL | POLLERR;
|
||||
#if defined(__linux__)
|
||||
pfd.events |= POLLRDHUP;
|
||||
#endif
|
||||
|
||||
if (cct->_conf->ms_inject_socket_failures && sd >= 0) {
|
||||
if (rand() % cct->_conf->ms_inject_socket_failures == 0) {
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "common/perf_counters.h"
|
||||
#include "os/ObjectStore.h"
|
||||
|
||||
#include "include/compat.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
@ -27,6 +29,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/disk.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define DOUT_SUBSYS journal
|
||||
#undef dout_prefix
|
||||
@ -99,6 +105,9 @@ int FileJournal::_open_block_device()
|
||||
{
|
||||
int ret = 0;
|
||||
int64_t bdev_sz = 0;
|
||||
#if defined(__FreeBSD__)
|
||||
ret = ::ioctl(fd, DIOCGMEDIASIZE, &bdev_sz);
|
||||
#elif defined(__linux__)
|
||||
#ifdef BLKGETSIZE64
|
||||
// ioctl block device
|
||||
ret = ::ioctl(fd, BLKGETSIZE64, &bdev_sz);
|
||||
@ -107,9 +116,10 @@ int FileJournal::_open_block_device()
|
||||
unsigned long sectors = 0;
|
||||
ret = ::ioctl(fd, BLKGETSIZE, §ors);
|
||||
bdev_sz = sectors * 512ULL;
|
||||
#endif
|
||||
#else
|
||||
#error "Compile error: we don't know how to get the size of a raw block device."
|
||||
#endif
|
||||
#endif /* !__FreeBSD__ */
|
||||
if (ret) {
|
||||
dout(0) << __func__ << ": failed to read block device size." << dendl;
|
||||
return -EIO;
|
||||
@ -820,7 +830,7 @@ void FileJournal::do_write(bufferlist& bl)
|
||||
|
||||
if (!directio) {
|
||||
dout(20) << "do_write fsync" << dendl;
|
||||
#ifdef DARWIN
|
||||
#if defined(DARWIN) || defined(__FreeBSD__)
|
||||
::fsync(fd);
|
||||
#else
|
||||
# ifdef HAVE_SYNC_FILE_RANGE
|
||||
|
@ -22,18 +22,26 @@
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/fs.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include "include/inttypes.h"
|
||||
#endif
|
||||
|
||||
#include "include/compat.h"
|
||||
#include "include/fiemap.h"
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
#if !defined(__CYGWIN__) && !defined(__FreeBSD__)
|
||||
# include <sys/xattr.h>
|
||||
#endif
|
||||
|
||||
#ifdef DARWIN
|
||||
#if defined(DARWIN) || defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#endif // DARWIN
|
||||
@ -63,7 +71,7 @@
|
||||
using ceph::crypto::SHA1;
|
||||
|
||||
#ifndef __CYGWIN__
|
||||
# ifndef DARWIN
|
||||
# if !defined(DARWIN) && !defined(__FreeBSD__)
|
||||
# include "btrfs_ioctl.h"
|
||||
# endif
|
||||
#endif
|
||||
@ -114,7 +122,27 @@ int do_setxattr(const char *fn, const char *name, const void *val, size_t size);
|
||||
int do_listxattr(const char *fn, char *names, size_t len);
|
||||
int do_removexattr(const char *fn, const char *name);
|
||||
|
||||
#ifdef DARWIN
|
||||
#if defined(__FreeBSD__)
|
||||
static int sys_getxattr(const char *fn, const char *name, void *val, size_t size)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int sys_setxattr(const char *fn, const char *name, const void *val, size_t size)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int sys_removexattr(const char *fn, const char *name)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int sys_listxattr(const char *fn, char *names, size_t len)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
#elif defined(DARWIN)
|
||||
static int sys_getxattr(const char *fn, const char *name, void *val, size_t size)
|
||||
{
|
||||
int r = ::getxattr(fn, name, val, size, 0, 0);
|
||||
@ -138,7 +166,7 @@ static int sys_listxattr(const char *fn, char *names, size_t len)
|
||||
int r = ::listxattr(fn, names, len, 0);
|
||||
return (r < 0 ? -errno : r);
|
||||
}
|
||||
#else
|
||||
#elif defined(__linux__)
|
||||
|
||||
static int sys_getxattr(const char *fn, const char *name, void *val, size_t size)
|
||||
{
|
||||
@ -163,6 +191,8 @@ int sys_listxattr(const char *fn, char *names, size_t len)
|
||||
int r = ::listxattr(fn, names, len);
|
||||
return (r < 0 ? -errno : r);
|
||||
}
|
||||
#else
|
||||
#error "Your platform is not yet supported!"
|
||||
#endif
|
||||
|
||||
int FileStore::get_cdir(coll_t cid, char *s, int len)
|
||||
@ -513,6 +543,7 @@ int do_setxattr(const char *fn, const char *name, const void *val, size_t size)
|
||||
|
||||
int do_fsetxattr(int fd, const char *name, const void *val, size_t size)
|
||||
{
|
||||
#if !defined(__FreeBSD__)
|
||||
int i = 0, pos = 0;
|
||||
char raw_name[ATTR_MAX_NAME_LEN * 2 + 16];
|
||||
int ret = 0;
|
||||
@ -541,9 +572,14 @@ int do_fsetxattr(int fd, const char *name, const void *val, size_t size)
|
||||
}
|
||||
|
||||
return ret;
|
||||
#else
|
||||
#warning "Implementation missing"
|
||||
return (-1);
|
||||
#endif
|
||||
}
|
||||
|
||||
int do_removexattr(const char *fn, const char *name) {
|
||||
#if !defined(__FreeBSD__)
|
||||
int i = 0;
|
||||
char raw_name[ATTR_MAX_NAME_LEN * 2 + 16];
|
||||
int r;
|
||||
@ -557,6 +593,10 @@ int do_removexattr(const char *fn, const char *name) {
|
||||
i++;
|
||||
} while (r >= 0);
|
||||
return 0;
|
||||
#else
|
||||
#warning "Implementation missing"
|
||||
return (-1);
|
||||
#endif
|
||||
}
|
||||
|
||||
int do_listxattr(const char *fn, char *names, size_t len) {
|
||||
@ -748,6 +788,7 @@ int FileStore::open_journal()
|
||||
|
||||
int FileStore::wipe_subvol(const char *s)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
struct btrfs_ioctl_vol_args volargs;
|
||||
memset(&volargs, 0, sizeof(volargs));
|
||||
strncpy(volargs.name, s, sizeof(volargs.name)-1);
|
||||
@ -764,6 +805,7 @@ int FileStore::wipe_subvol(const char *s)
|
||||
dout(0) << "mkfs removed old subvol " << s << dendl;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
dout(0) << "mkfs removing old directory " << s << dendl;
|
||||
ostringstream old_dir;
|
||||
@ -804,7 +846,9 @@ int FileStore::mkfs()
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
int basedir_fd;
|
||||
#if defined(__linux__)
|
||||
struct btrfs_ioctl_vol_args volargs;
|
||||
#endif
|
||||
|
||||
if (!m_filestore_dev.empty()) {
|
||||
dout(0) << "mounting" << dendl;
|
||||
@ -900,6 +944,7 @@ int FileStore::mkfs()
|
||||
}
|
||||
|
||||
// current
|
||||
#if defined(__linux__)
|
||||
memset(&volargs, 0, sizeof(volargs));
|
||||
basedir_fd = ::open(basedir.c_str(), O_RDONLY);
|
||||
volargs.fd = 0;
|
||||
@ -911,6 +956,7 @@ int FileStore::mkfs()
|
||||
// not fatal
|
||||
}
|
||||
else if (ret == EOPNOTSUPP || ret == ENOTTY) {
|
||||
#endif
|
||||
dout(2) << " BTRFS_IOC_SUBVOL_CREATE ioctl failed, trying mkdir "
|
||||
<< current_fn << dendl;
|
||||
if (::mkdir(current_fn.c_str(), 0755)) {
|
||||
@ -921,6 +967,7 @@ int FileStore::mkfs()
|
||||
goto close_basedir_fd;
|
||||
}
|
||||
}
|
||||
#if defined(__linux__)
|
||||
}
|
||||
else {
|
||||
derr << "FileStore::mkfs: BTRFS_IOC_SUBVOL_CREATE failed with error "
|
||||
@ -938,6 +985,7 @@ int FileStore::mkfs()
|
||||
goto close_basedir_fd;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// journal?
|
||||
ret = mkjournal();
|
||||
@ -1042,8 +1090,6 @@ bool FileStore::test_mount_in_use()
|
||||
|
||||
int FileStore::_detect_fs()
|
||||
{
|
||||
char buf[80];
|
||||
|
||||
// fake collections?
|
||||
if (m_filestore_fake_collections) {
|
||||
dout(0) << "faking collections (in memory)" << dendl;
|
||||
@ -1098,6 +1144,8 @@ int FileStore::_detect_fs()
|
||||
return -errno;
|
||||
blk_size = st.f_bsize;
|
||||
|
||||
#if defined(__linux__)
|
||||
char buf[80];
|
||||
static const __SWORD_TYPE BTRFS_F_TYPE(0x9123683E);
|
||||
if (st.f_type == BTRFS_F_TYPE) {
|
||||
dout(0) << "mount detected btrfs" << dendl;
|
||||
@ -1213,7 +1261,9 @@ int FileStore::_detect_fs()
|
||||
<< TEXT_NORMAL;
|
||||
}
|
||||
|
||||
} else {
|
||||
} else
|
||||
#endif /* __linux__ */
|
||||
{
|
||||
dout(0) << "mount did NOT detect btrfs" << dendl;
|
||||
btrfs = false;
|
||||
}
|
||||
@ -1479,6 +1529,7 @@ int FileStore::mount()
|
||||
goto close_basedir_fd;
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
if (btrfs && m_filestore_btrfs_snap) {
|
||||
if (snaps.empty()) {
|
||||
dout(0) << "mount WARNING: no consistent snaps found, store may be in inconsistent state" << dendl;
|
||||
@ -1568,6 +1619,7 @@ int FileStore::mount()
|
||||
TEMP_FAILURE_RETRY(::close(vol_args.fd));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
initial_op_seq = 0;
|
||||
|
||||
current_fd = ::open(current_fn.c_str(), O_RDONLY);
|
||||
@ -2149,7 +2201,7 @@ unsigned FileStore::apply_transactions(list<Transaction*> &tls,
|
||||
|
||||
int FileStore::_transaction_start(uint64_t bytes, uint64_t ops)
|
||||
{
|
||||
#ifdef DARWIN
|
||||
#if defined(DARWIN) || defined(__FreeBSD__)
|
||||
return 0;
|
||||
#else
|
||||
if (!btrfs || !btrfs_trans_start_end ||
|
||||
@ -2178,12 +2230,12 @@ int FileStore::_transaction_start(uint64_t bytes, uint64_t ops)
|
||||
::mknod(fn, 0644, 0);
|
||||
|
||||
return fd;
|
||||
#endif /* DARWIN */
|
||||
#endif /* DARWIN || __FreeBSD__ */
|
||||
}
|
||||
|
||||
void FileStore::_transaction_finish(int fd)
|
||||
{
|
||||
#ifdef DARWIN
|
||||
#if defined(DARWIN) || defined(__FreeBSD__)
|
||||
return;
|
||||
#else
|
||||
if (!btrfs || !btrfs_trans_start_end ||
|
||||
@ -2197,7 +2249,7 @@ void FileStore::_transaction_finish(int fd)
|
||||
dout(10) << "transaction_finish " << fd << dendl;
|
||||
::ioctl(fd, BTRFS_IOC_TRANS_END);
|
||||
::close(fd);
|
||||
#endif /* DARWIN */
|
||||
#endif /* DARWIN || __FreeBSD__ */
|
||||
}
|
||||
|
||||
unsigned FileStore::_do_transaction(Transaction& t)
|
||||
@ -2689,11 +2741,11 @@ int FileStore::_clone(coll_t cid, const hobject_t& oldoid, const hobject_t& newo
|
||||
goto out;
|
||||
}
|
||||
if (btrfs)
|
||||
#ifndef DARWIN
|
||||
#if !defined(DARWIN) && !defined(__FreeBSD__)
|
||||
r = ::ioctl(n, BTRFS_IOC_CLONE, o);
|
||||
#else
|
||||
;
|
||||
#endif /* DARWIN */
|
||||
#endif /* DARWIN || __FreeBSD__ */
|
||||
else {
|
||||
struct stat st;
|
||||
::fstat(o, &st);
|
||||
@ -2750,6 +2802,7 @@ int FileStore::_do_clone_range(int from, int to, uint64_t srcoff, uint64_t len,
|
||||
|
||||
dout(20) << "_do_clone_range cloning " << srcoffclone << "~" << lenclone
|
||||
<< " to " << dstoffclone << " = " << r << dendl;
|
||||
#if defined(__linux__)
|
||||
btrfs_ioctl_clone_range_args a;
|
||||
a.src_fd = from;
|
||||
a.src_offset = srcoffclone;
|
||||
@ -2759,12 +2812,15 @@ int FileStore::_do_clone_range(int from, int to, uint64_t srcoff, uint64_t len,
|
||||
if (err >= 0) {
|
||||
r += err;
|
||||
} else if (errno == EINVAL) {
|
||||
#endif
|
||||
// Still failed, might be compressed
|
||||
dout(20) << "_do_clone_range failed CLONE_RANGE call with -EINVAL, using copy" << dendl;
|
||||
return _do_copy_range(from, to, srcoff, len, dstoff);
|
||||
#if defined(__linux__)
|
||||
} else {
|
||||
return -errno;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Take care any trimmed from front
|
||||
if (srcoffclone != srcoff) {
|
||||
@ -3022,6 +3078,7 @@ void FileStore::sync_entry()
|
||||
assert(0);
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
bool do_snap = btrfs && m_filestore_btrfs_snap;
|
||||
|
||||
if (do_snap) {
|
||||
@ -3070,14 +3127,19 @@ void FileStore::sync_entry()
|
||||
|
||||
commit_started();
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
commit_started();
|
||||
|
||||
#if defined(__linux__)
|
||||
if (btrfs) {
|
||||
dout(15) << "sync_entry doing btrfs SYNC" << dendl;
|
||||
// do a full btrfs commit
|
||||
::ioctl(op_fd, BTRFS_IOC_SYNC);
|
||||
} else if (m_filestore_fsync_flushes_journal_data) {
|
||||
} else
|
||||
#endif
|
||||
if (m_filestore_fsync_flushes_journal_data) {
|
||||
dout(15) << "sync_entry doing fsync on " << current_op_seq_fn << dendl;
|
||||
// make the file system's journal commit.
|
||||
// this works with ext3, but NOT ext4
|
||||
@ -3097,6 +3159,7 @@ void FileStore::sync_entry()
|
||||
logger->set(l_os_committing, 0);
|
||||
|
||||
// remove old snaps?
|
||||
#if defined(__linux__)
|
||||
if (do_snap) {
|
||||
while (snaps.size() > 2) {
|
||||
btrfs_ioctl_vol_args vol_args;
|
||||
@ -3114,6 +3177,7 @@ void FileStore::sync_entry()
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
dout(15) << "sync_entry committed to op_seq " << cp << dendl;
|
||||
|
||||
@ -3231,6 +3295,11 @@ int FileStore::snapshot(const string& name)
|
||||
{
|
||||
dout(10) << "snapshot " << name << dendl;
|
||||
sync_and_flush();
|
||||
|
||||
#if !defined(__linux__)
|
||||
dout(0) << "snapshot " << name << " failed, no btrfs" << dendl;
|
||||
return -EOPNOTSUPP;
|
||||
#else
|
||||
|
||||
if (!btrfs) {
|
||||
dout(0) << "snapshot " << name << " failed, no btrfs" << dendl;
|
||||
@ -3246,6 +3315,7 @@ int FileStore::snapshot(const string& name)
|
||||
derr << "snapshot " << name << " failed: " << cpp_strerror(r) << dendl;
|
||||
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
|
@ -12,6 +12,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "FlatIndex.h"
|
||||
#include "CollectionIndex.h"
|
||||
#include "common/ceph_crypto.h"
|
||||
|
@ -15,6 +15,10 @@
|
||||
#include <tr1/memory>
|
||||
#include <map>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "common/Mutex.h"
|
||||
#include "common/Cond.h"
|
||||
#include "common/config.h"
|
||||
|
@ -19,6 +19,10 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "osd/osd_types.h"
|
||||
#include "include/object.h"
|
||||
#include "common/config.h"
|
||||
@ -26,6 +30,8 @@
|
||||
#include "include/buffer.h"
|
||||
#include "common/ceph_crypto.h"
|
||||
|
||||
#include "include/compat.h"
|
||||
|
||||
#include "LFNIndex.h"
|
||||
using ceph::crypto::SHA1;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <vector>
|
||||
|
||||
#ifdef DARWIN
|
||||
#if defined(DARWIN) || defined(__FreeBSD__)
|
||||
#include <sys/statvfs.h>
|
||||
#else
|
||||
#include <sys/vfs.h> /* or <sys/statfs.h> */
|
||||
|
@ -15,10 +15,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef DARWIN
|
||||
#if defined(DARWIN) || defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#endif // DARWIN
|
||||
#endif // DARWIN || __FreeBSD__
|
||||
|
||||
|
||||
int myrand()
|
||||
|
@ -8,6 +8,10 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "common/config.h"
|
||||
|
||||
#define DOUT_SUBSYS osd
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "osd/PG.h"
|
||||
|
||||
#include "include/types.h"
|
||||
#include "include/compat.h"
|
||||
|
||||
#include "OSD.h"
|
||||
#include "OSDMap.h"
|
||||
@ -93,10 +94,10 @@
|
||||
#include <signal.h>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
#ifdef DARWIN
|
||||
#if defined(DARWIN) || defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#endif // DARWIN
|
||||
#endif // DARWIN || __FreeBSD__
|
||||
|
||||
#include "objclass/objclass.h"
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "mds/inode_backtrace.h" // Ugh
|
||||
|
||||
#include "common/config.h"
|
||||
#include "include/compat.h"
|
||||
|
||||
#define DOUT_SUBSYS osd
|
||||
#define DOUT_PREFIX_ARGS this, osd->whoami, osd->osdmap
|
||||
|
@ -27,7 +27,9 @@
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#if !defined(__FreeBSD__)
|
||||
#include <sys/xattr.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -99,8 +101,13 @@ private:
|
||||
}
|
||||
std::string xattr_fs_name(USER_XATTR_PREFIX);
|
||||
xattr_fs_name += x->c_str();
|
||||
#if !defined(__FreeBSD__) // XXX
|
||||
ret = setxattr(obj_path.c_str(), xattr_fs_name.c_str(),
|
||||
xattr->data, xattr->len, 0);
|
||||
#else
|
||||
#warning "Missing implementation!"
|
||||
ret = 1;
|
||||
#endif
|
||||
if (ret) {
|
||||
ret = errno;
|
||||
cerr << ERR_PREFIX << "setxattr error: " << cpp_strerror(ret) << std::endl;
|
||||
@ -110,7 +117,12 @@ private:
|
||||
for (std::list < std::string >::const_iterator x = only_in_b.begin();
|
||||
x != only_in_b.end(); ++x) {
|
||||
flags |= CHANGED_XATTRS;
|
||||
#if !defined(__FreeBSD__) // XXX
|
||||
ret = removexattr(obj_path.c_str(), x->c_str());
|
||||
#else
|
||||
#warning "Missing implementation!"
|
||||
ret = 1;
|
||||
#endif
|
||||
if (ret) {
|
||||
ret = errno;
|
||||
cerr << ERR_PREFIX << "removexattr error: " << cpp_strerror(ret) << std::endl;
|
||||
|
@ -21,7 +21,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#if !defined(__FreeBSD__)
|
||||
#include <sys/xattr.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "global/global_init.h"
|
||||
#include "include/rados/librados.hpp"
|
||||
#include "rados_sync.h"
|
||||
#include "include/compat.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
@ -32,7 +33,9 @@
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#if !defined(__FreeBSD__)
|
||||
#include <sys/xattr.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -89,7 +92,12 @@ ExportDir* ExportDir::create_for_writing(const std::string path, int version,
|
||||
}
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%d", version);
|
||||
#if !defined(__FreeBSD__)
|
||||
ret = setxattr(path.c_str(), XATTR_RADOS_SYNC_VER, buf, strlen(buf) + 1, 0);
|
||||
#else
|
||||
ret = -1;
|
||||
#warning "Missing implementation!"
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
int err = errno;
|
||||
cerr << ERR_PREFIX << "ExportDir: setxattr error :"
|
||||
@ -109,7 +117,12 @@ ExportDir* ExportDir::from_file_system(const std::string path)
|
||||
int ret;
|
||||
char buf[32];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
#if !defined(__FreeBSD__)
|
||||
ret = getxattr(path.c_str(), XATTR_RADOS_SYNC_VER, buf, sizeof(buf) - 1);
|
||||
#else
|
||||
ret = -1;
|
||||
#warning "Missing implementation!"
|
||||
#endif
|
||||
if (ret < 0) {
|
||||
ret = errno;
|
||||
if (ret == ENODATA) {
|
||||
@ -395,7 +408,12 @@ int BackedUpObject::from_path(const char *path, std::auto_ptr<BackedUpObject> &o
|
||||
}
|
||||
|
||||
// get fullname
|
||||
#if !defined(__FreeBSD__)
|
||||
ssize_t res = fgetxattr(fd, XATTR_FULLNAME, NULL, 0);
|
||||
#else
|
||||
ssize_t res = -1;
|
||||
#warning "Missing implementation!"
|
||||
#endif
|
||||
if (res <= 0) {
|
||||
fclose(fp);
|
||||
ret = errno;
|
||||
@ -415,7 +433,12 @@ int BackedUpObject::from_path(const char *path, std::auto_ptr<BackedUpObject> &o
|
||||
}
|
||||
char rados_name_[res + 1];
|
||||
memset(rados_name_, 0, sizeof(rados_name_));
|
||||
#if !defined(__FreeBSD__)
|
||||
res = fgetxattr(fd, XATTR_FULLNAME, rados_name_, res);
|
||||
#else
|
||||
res = -1;
|
||||
#warning "Missing implementation!"
|
||||
#endif
|
||||
if (res < 0) {
|
||||
ret = errno;
|
||||
fclose(fp);
|
||||
@ -603,7 +626,12 @@ int BackedUpObject::download(IoCtx &io_ctx, const char *path)
|
||||
break;
|
||||
}
|
||||
size_t attr_sz = strlen(rados_name) + 1;
|
||||
#if !defined(__FreeBSD__)
|
||||
int res = fsetxattr(fd, XATTR_FULLNAME, rados_name, attr_sz, 0);
|
||||
#else
|
||||
int res = 1;
|
||||
#warning "Missing implementation!"
|
||||
#endif
|
||||
if (res) {
|
||||
int err = errno;
|
||||
cerr << ERR_PREFIX << "download: fsetxattr(" << tmp_path << ") error: "
|
||||
@ -694,7 +722,12 @@ BackedUpObject::BackedUpObject(const char *rados_name_,
|
||||
|
||||
int BackedUpObject::read_xattrs_from_file(int fd)
|
||||
{
|
||||
#if !defined(__FreeBSD__)
|
||||
ssize_t blen = flistxattr(fd, NULL, 0);
|
||||
#else
|
||||
ssize_t blen = 0;
|
||||
#warning "Missing implementation!"
|
||||
#endif
|
||||
if (blen > 0x1000000) {
|
||||
cerr << ERR_PREFIX << "BackedUpObject::read_xattrs_from_file: unwilling "
|
||||
<< "to allocate a buffer of size " << blen << " on the stack for "
|
||||
@ -703,7 +736,12 @@ int BackedUpObject::read_xattrs_from_file(int fd)
|
||||
}
|
||||
char buf[blen + 1];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
#if !defined(__FreeBSD__)
|
||||
ssize_t blen2 = flistxattr(fd, buf, blen);
|
||||
#else
|
||||
ssize_t blen2 = 0;
|
||||
#warning "Missing implementation!"
|
||||
#endif
|
||||
if (blen != blen2) {
|
||||
cerr << ERR_PREFIX << "BackedUpObject::read_xattrs_from_file: xattrs changed while "
|
||||
<< "we were trying to "
|
||||
@ -716,7 +754,12 @@ int BackedUpObject::read_xattrs_from_file(int fd)
|
||||
size_t bs = strlen(b);
|
||||
std::string xattr_name = get_user_xattr_name(b);
|
||||
if (!xattr_name.empty()) {
|
||||
#if !defined(__FreeBSD__)
|
||||
ssize_t attr_len = fgetxattr(fd, b, NULL, 0);
|
||||
#else
|
||||
ssize_t attr_len = -1;
|
||||
#warning "Missing implementation!"
|
||||
#endif
|
||||
if (attr_len < 0) {
|
||||
int err = errno;
|
||||
cerr << ERR_PREFIX << "BackedUpObject::read_xattrs_from_file: "
|
||||
@ -731,7 +774,12 @@ int BackedUpObject::read_xattrs_from_file(int fd)
|
||||
<< xattr_name << "'" << std::endl;
|
||||
return ENOBUFS;
|
||||
}
|
||||
#if !defined(__FreeBSD__)
|
||||
ssize_t attr_len2 = fgetxattr(fd, b, attr, attr_len);
|
||||
#else
|
||||
ssize_t attr_len2 = -1;
|
||||
#warning "Missing implementation!"
|
||||
#endif
|
||||
if (attr_len2 < 0) {
|
||||
int err = errno;
|
||||
cerr << ERR_PREFIX << "BackedUpObject::read_xattrs_from_file: "
|
||||
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include "include/intarith.h"
|
||||
|
||||
#include "include/compat.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
@ -41,7 +43,13 @@
|
||||
|
||||
#include "include/rbd_types.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/fs.h>
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include "include/fiemap.h"
|
||||
|
||||
|
@ -30,12 +30,20 @@
|
||||
#include <sys/wait.h>
|
||||
#include <vector>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
using std::ostringstream;
|
||||
using std::string;
|
||||
|
||||
static pid_t do_gettid(void)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
return static_cast < pid_t >(syscall(SYS_gettid));
|
||||
#else
|
||||
return static_cast < pid_t >(pthread_getthreadid_np());
|
||||
#endif
|
||||
}
|
||||
|
||||
ceph::atomic_t m_highest_id(0);
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "common/config.h"
|
||||
#include "tools/common.h"
|
||||
|
||||
#include "include/compat.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -31,7 +31,7 @@ using namespace std;
|
||||
#include "common/Timer.h"
|
||||
#include "global/global_init.h"
|
||||
|
||||
#ifndef DARWIN
|
||||
#if !defined(DARWIN) && !defined(__FreeBSD__)
|
||||
#include <envz.h>
|
||||
#endif // DARWIN
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user