Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD related fixes #7170

Merged
merged 8 commits into from Mar 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion Makefile.am
Expand Up @@ -22,6 +22,11 @@ EXTRA_DIST += \
share/id_dsa_drop.ceph.com \
share/id_dsa_drop.ceph.com.pub

NPROC = nproc
if FREEBSD
NPROC = sysctl -n hw.ncpu
endif

# why is it so hard to make autotools to this?
install-data-local::
-mkdir -p $(DESTDIR)$(datadir)/ceph
Expand All @@ -46,7 +51,7 @@ check-local:: all
@cd src/gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
# exercise cli tools
u=`ulimit -u` ; \
p=`expr $(shell nproc) / 2` ; \
p=`expr $(shell ${NPROC}) / 2` ; \
n=`expr $$p \* 1024` ; \
if ${CHECK_ULIMIT} && echo ${MAKEFLAGS} | grep --quiet -e -j && test $$u -lt $$n ; then \
echo "ulimit -u is $$u which is lower than $$n = $$p / 2 * 1024" ; \
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile-env.am
Expand Up @@ -63,7 +63,7 @@ HARDENING_CFLAGS = \
--param=ssp-buffer-size=4 \
-fPIE

SET_STACK_PROTECTOR_STRONG = $(shell expr `gcc -dumpversion` \>= 4.9)
SET_STACK_PROTECTOR_STRONG = $(shell expr `$(CC) -dumpversion` \>= 4.9)

ifeq ($(SET_STACK_PROTECTOR_STRONG),1)
HARDENING_CFLAGS += -fstack-protector-strong
Expand Down
2 changes: 2 additions & 0 deletions src/ceph_fuse.cc
Expand Up @@ -30,7 +30,9 @@ using namespace std;

#include "common/Timer.h"
#include "common/ceph_argparse.h"
#if defined(__linux__)
#include "common/linux_version.h"
#endif
#include "global/global_init.h"
#include "common/safe_io.h"

Expand Down
9 changes: 2 additions & 7 deletions src/common/Makefile.am
Expand Up @@ -76,7 +76,8 @@ libcommon_internal_la_SOURCES = \
common/ContextCompletion.cc \
common/TracepointProvider.cc \
common/PluginRegistry.cc \
common/scrub_types.cc
common/scrub_types.cc \
common/blkdev.cc

common/PluginRegistry.cc: ./ceph_ver.h

Expand Down Expand Up @@ -104,12 +105,6 @@ libcommon_internal_la_SOURCES += \
common/aix_errno.cc
endif

# used by RBD and FileStore
if LINUX
libcommon_internal_la_SOURCES += \
common/blkdev.cc
endif

if ENABLE_XIO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trociny & @tchaikov this will not compile on Solaris however, I had originally added a if WITH_RBD around that file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohanmars Sorry, my previous message (it is also used by FileStore) actually was for this comment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trociny, no FileStore is not built for client side as I understand. Due to limitation on Makefile.am syntax, probably best to add another if FREE_BSD or something. Not sure why WITH_RBD guard was taken away.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably because it is used by FileStore and BlueStore. can we guard it with WITH_OSD and `!SOLARIS?

libcommon_internal_la_SOURCES += \
common/address_helper.cc
Expand Down
2 changes: 2 additions & 0 deletions src/common/MemoryModel.cc
Expand Up @@ -4,7 +4,9 @@
#include "MemoryModel.h"
#include "common/config.h"
#include "debug.h"
#if defined(__linux__)
#include <malloc.h>
#endif

#include <fstream>

Expand Down
21 changes: 20 additions & 1 deletion src/common/blkdev.cc
Expand Up @@ -275,5 +275,24 @@ int get_device_by_uuid(uuid_d dev_uuid, const char* label, char* partition,
return -EOPNOTSUPP;
}
#else
# error "Unable to query block device size: unsupported platform, please report."
int get_block_device_size(int fd, int64_t *psize)
{
return -EOPNOTSUPP;
}

bool block_device_support_discard(const char *devname)
{
return false;
}

int block_device_discard(int fd, int64_t offset, int64_t len)
{
return -EOPNOTSUPP;
}

int get_device_by_uuid(uuid_d dev_uuid, const char* label, char* partition,
char* device)
{
return -EOPNOTSUPP;
}
#endif
6 changes: 5 additions & 1 deletion src/kv/Makefile.am
Expand Up @@ -16,8 +16,12 @@ if WITH_SLIBROCKSDB
# build rocksdb with its own makefile
# for some stupid reason this needs -fPIC...
# PORTABLE=1 fixes the aarch64 build (-march=native doesn't work there)
NPROC = nproc
if FREEBSD
NPROC = sysctl -n hw.ncpu
endif
rocksdb/librocksdb.a:
cd rocksdb && EXTRA_CXXFLAGS=-fPIC PORTABLE=1 make -j$(shell nproc) static_lib
cd rocksdb && CC="${CC}" CXX="${CXX}" EXTRA_CXXFLAGS=-fPIC PORTABLE=1 $(MAKE) -j$(shell ${NPROC}) static_lib
libkv_a_CXXFLAGS += -I rocksdb/include -fPIC
libkv_a_SOURCES += kv/RocksDBStore.cc
libkv_a_LIBADD += rocksdb/librocksdb.a
Expand Down
8 changes: 8 additions & 0 deletions src/os/filestore/FileJournal.cc
Expand Up @@ -33,7 +33,9 @@
#include <sys/mount.h>

#include "common/blkdev.h"
#if defined(__linux__)
#include "common/linux_version.h"
#endif

#if defined(__FreeBSD__)
#define O_DSYNC O_SYNC
Expand Down Expand Up @@ -161,6 +163,11 @@ int FileJournal::_open_block_device()

void FileJournal::_check_disk_write_cache() const
{
#if !defined(__linux__)
dout(10) << "_check_disk_write_cache: not linux, NOT checking disk write "
<< "cache on raw block device " << fn << dendl;
return;
#else
ostringstream hdparm_cmd;
FILE *fp = NULL;

Expand Down Expand Up @@ -232,6 +239,7 @@ void FileJournal::_check_disk_write_cache() const
}
done:
;
#endif // __linux__
}

int FileJournal::_open_file(int64_t oldsize, blksize_t blksize,
Expand Down
27 changes: 15 additions & 12 deletions src/stop.sh
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (C) 2013 Inktank <info@inktank.com>
# Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
Expand Down Expand Up @@ -70,18 +70,21 @@ while [ $# -ge 1 ]; do
done

if [ $stop_all -eq 1 ]; then
while read DEV; do
# While it is currently possible to create an rbd image with
# whitespace chars in its name, krbd will refuse mapping such
# an image, so we can safely split on whitespace here. (The
# same goes for whitespace chars in names of the pools that
# contain rbd images).
DEV="$(echo "${DEV}" | tr -s '[:space:]' | awk '{ print $5 }')"
sudo "${CEPH_BIN}"/rbd unmap "${DEV}"
done < <("${CEPH_BIN}"/rbd showmapped | tail -n +2)
if "${CEPH_BIN}"/rbd showmapped >/dev/null 2>&1; then
"${CEPH_BIN}"/rbd showmapped | tail -n +2 |
while read DEV; do
# While it is currently possible to create an rbd image with
# whitespace chars in its name, krbd will refuse mapping such
# an image, so we can safely split on whitespace here. (The
# same goes for whitespace chars in names of the pools that
# contain rbd images).
DEV="$(echo "${DEV}" | tr -s '[:space:]' | awk '{ print $5 }')"
sudo "${CEPH_BIN}"/rbd unmap "${DEV}"
done

if [ -n "$("${CEPH_BIN}"/rbd showmapped)" ]; then
echo "WARNING: Some rbd images are still mapped!" >&2
if [ -n "$("${CEPH_BIN}"/rbd showmapped)" ]; then
echo "WARNING: Some rbd images are still mapped!" >&2
fi
fi

for p in ceph-mon ceph-mds ceph-osd radosgw lt-radosgw apache2 ; do
Expand Down
12 changes: 9 additions & 3 deletions src/tools/Makefile-client.am
Expand Up @@ -46,8 +46,6 @@ rbd_SOURCES = \
tools/rbd/action/ImportDiff.cc \
tools/rbd/action/Info.cc \
tools/rbd/action/Journal.cc \
tools/rbd/action/Kernel.cc \
tools/rbd/action/Nbd.cc \
tools/rbd/action/List.cc \
tools/rbd/action/Lock.cc \
tools/rbd/action/MergeDiff.cc \
Expand All @@ -59,6 +57,11 @@ rbd_SOURCES = \
tools/rbd/action/Snap.cc \
tools/rbd/action/Status.cc \
tools/rbd/action/Watch.cc
if LINUX
rbd_SOURCES += \
tools/rbd/action/Kernel.cc \
tools/rbd/action/Nbd.cc
endif # LINUX
noinst_HEADERS += \
tools/rbd/ArgumentTypes.h \
tools/rbd/IndentStream.h \
Expand All @@ -67,11 +70,14 @@ noinst_HEADERS += \
tools/rbd/Utils.h
rbd_LDADD = \
libjournal.la libcls_journal_client.la \
$(LIBKRBD) $(LIBRBD) $(LIBRBD_TYPES) $(LIBRADOS) $(CEPH_GLOBAL) \
$(LIBRBD) $(LIBRBD_TYPES) $(LIBRADOS) $(CEPH_GLOBAL) \
$(BOOST_REGEX_LIBS) $(BOOST_PROGRAM_OPTIONS_LIBS)
if LINUX
rbd_LDADD += $(LIBKRBD)
endif # LINUX
bin_PROGRAMS += rbd

if LINUX
rbd_nbd_SOURCES = tools/rbd_nbd/rbd-nbd.cc
rbd_nbd_CXXFLAGS = $(AM_CXXFLAGS)
rbd_nbd_LDADD = $(LIBRBD) $(LIBRADOS) $(CEPH_GLOBAL) $(BOOST_REGEX_LIBS)
Expand Down
1 change: 1 addition & 0 deletions src/tools/rbd/action/Export.cc
@@ -1,6 +1,7 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#include "include/compat.h"
#include "tools/rbd/ArgumentTypes.h"
#include "tools/rbd/Shell.h"
#include "tools/rbd/Utils.h"
Expand Down
1 change: 1 addition & 0 deletions src/tools/rbd/action/ImportDiff.cc
@@ -1,6 +1,7 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#include "include/compat.h"
#include "tools/rbd/ArgumentTypes.h"
#include "tools/rbd/Shell.h"
#include "tools/rbd/Utils.h"
Expand Down
1 change: 1 addition & 0 deletions src/tools/rbd/action/MergeDiff.cc
Expand Up @@ -5,6 +5,7 @@
#include <sys/types.h>
#include <unistd.h>

#include "include/compat.h"
#include "tools/rbd/ArgumentTypes.h"
#include "tools/rbd/Shell.h"
#include "tools/rbd/Utils.h"
Expand Down