Skip to content

Commit

Permalink
Merge branch 'wip-17791' into wip-mgolub-testing
Browse files Browse the repository at this point in the history
librbd: handle get_data_pool failure due to old version OSD #11755
  • Loading branch information
Mykola Golub committed Nov 3, 2016
2 parents d861e59 + a8d7b79 commit 19f7d0e
Show file tree
Hide file tree
Showing 93 changed files with 4,159 additions and 1,468 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Expand Up @@ -38,3 +38,6 @@
url = https://github.com/ceph/lua.git
branch = lua-5.3-ceph
ignore = dirty
[submodule "src/Beast"]
path = src/Beast
url = https://github.com/ceph/Beast.git
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -323,6 +323,8 @@ if(WITH_RADOSGW)
find_package(fcgi REQUIRED)
endif(WITH_RADOSGW)

option(WITH_RADOSGW_ASIO_FRONTEND "Rados Gateway's ASIO frontend is enabled" OFF)

#option for CephFS
option(WITH_CEPHFS "CephFS is enabled" ON)

Expand Down
1 change: 1 addition & 0 deletions ceph.spec.in
Expand Up @@ -1341,6 +1341,7 @@ fi
%{_includedir}/rados/librados.hpp
%{_includedir}/rados/buffer.h
%{_includedir}/rados/buffer_fwd.h
%{_includedir}/rados/inline_memory.h
%{_includedir}/rados/page.h
%{_includedir}/rados/crc32c.h
%{_includedir}/rados/rados_types.h
Expand Down
1 change: 1 addition & 0 deletions debian/librados-dev.install
Expand Up @@ -4,6 +4,7 @@ usr/include/rados/buffer_fwd.h
usr/include/rados/crc32c.h
usr/include/rados/librados.h
usr/include/rados/librados.hpp
usr/include/rados/inline_memory.h
usr/include/rados/page.h
usr/include/rados/rados_types.h
usr/include/rados/rados_types.hpp
Expand Down
2 changes: 1 addition & 1 deletion install-deps.sh
Expand Up @@ -121,7 +121,7 @@ else
$SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
! grep -q -i error: $DIR/yum-builddep.out || exit 1
;;
opensuse|suse)
opensuse|suse|sles)
echo "Using zypper to install dependencies"
$SUDO zypper --gpg-auto-import-keys --non-interactive install lsb-release systemd-rpm-macros
sed -e 's/@//g' < ceph.spec.in > $DIR/ceph.spec
Expand Down
7 changes: 4 additions & 3 deletions make-dist
Expand Up @@ -32,8 +32,9 @@ bin/git-archive-all.sh --prefix ceph-$version/ \
$outfile.tar

# populate files with version strings
echo "including src/.git_version, src/ceph_ver.h, ceph.spec"
src/make_version -g src/.git_version -c src/ceph_ver.h
echo "including src/.git_version, ceph.spec"

(git rev-parse HEAD ; git describe) 2> /dev/null > src/.git_version

# if the version has '-' in it, it has a 'release' part,
# like vX.Y.Z-N-g<shortsha1>. If it doesn't, it's just
Expand All @@ -53,7 +54,7 @@ cat ceph.spec.in | \
sed "s/@RPM_RELEASE@/$rpm_release/g" |
sed "s/@TARBALL_BASENAME@/ceph-$version/g" > ceph.spec
ln -s . $outfile
tar cvf $outfile.version.tar $outfile/src/.git_version $outfile/src/ceph_ver.h $outfile/ceph.spec
tar cvf $outfile.version.tar $outfile/src/.git_version $outfile/ceph.spec
tar --concatenate -f $outfile.both.tar $outfile.version.tar
tar --concatenate -f $outfile.both.tar $outfile.tar
mv $outfile.both.tar $outfile.tar
Expand Down
1 change: 1 addition & 0 deletions src/Beast
Submodule Beast added at 999e2f
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Expand Up @@ -188,6 +188,8 @@ if(${ENABLE_GIT_VERSION})
list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER)
list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER)
endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND")
# remove 'v' prefix from raw git version
string(SUBSTRING ${CEPH_GIT_NICE_VER} 1 -1 CEPH_GIT_NICE_VER)
else(${ENABLE_GIT_VERSION})
set(CEPH_GIT_VER "no_version")
set(CEPH_GIT_NICE_VER "Development")
Expand Down
4 changes: 2 additions & 2 deletions src/cls/rgw/cls_rgw.cc
Expand Up @@ -2516,9 +2516,9 @@ static int rgw_bi_list_op(cls_method_context_t hctx, bufferlist *in, bufferlist

string filter = op.name;
#define MAX_BI_LIST_ENTRIES 1000
int32_t max = (op.max < MAX_BI_LIST_ENTRIES ? op.max : MAX_BI_LIST_ENTRIES);
int32_t max = (op.max < MAX_BI_LIST_ENTRIES ? op.max : MAX_BI_LIST_ENTRIES) + 1; /* one extra entry for identifying truncation */
string start_key = op.marker;
int ret = list_plain_entries(hctx, op.name, op.marker, max, &op_ret.entries) + 1; /* one extra entry for identifying truncation */
int ret = list_plain_entries(hctx, op.name, op.marker, max, &op_ret.entries);
if (ret < 0) {
CLS_LOG(0, "ERROR: %s(): list_plain_entries retured ret=%d", __func__, ret);
return ret;
Expand Down
15 changes: 11 additions & 4 deletions src/common/config_opts.h
Expand Up @@ -106,6 +106,8 @@ OPTION(async_compressor_threads, OPT_INT, 2)
OPTION(async_compressor_thread_timeout, OPT_INT, 5)
OPTION(async_compressor_thread_suicide_timeout, OPT_INT, 30)

OPTION(mempool_debug, OPT_BOOL, false)

DEFAULT_SUBSYS(0, 5)
SUBSYS(lockdep, 0, 1)
SUBSYS(context, 0, 1)
Expand Down Expand Up @@ -996,11 +998,12 @@ OPTION(bluestore_extent_map_shard_target_size, OPT_U32, 500)
OPTION(bluestore_extent_map_shard_min_size, OPT_U32, 150)
OPTION(bluestore_extent_map_shard_target_size_slop, OPT_DOUBLE, .2)
OPTION(bluestore_extent_map_inline_shard_prealloc_size, OPT_U32, 256)
OPTION(bluestore_cache_trim_interval, OPT_DOUBLE, .1)
OPTION(bluestore_cache_type, OPT_STR, "2q") // lru, 2q
OPTION(bluestore_2q_cache_kin_ratio, OPT_DOUBLE, .5) // kin page slot size / max page slot size
OPTION(bluestore_2q_cache_kout_ratio, OPT_DOUBLE, .5) // number of kout page slot / total number of page slot
OPTION(bluestore_onode_cache_size, OPT_U32, 4*1024)
OPTION(bluestore_buffer_cache_size, OPT_U32, 512*1024*1024)
OPTION(bluestore_cache_size, OPT_U64, 1024*1024*1024)
OPTION(bluestore_cache_meta_ratio, OPT_DOUBLE, .1)
OPTION(bluestore_kvbackend, OPT_STR, "rocksdb")
OPTION(bluestore_allocator, OPT_STR, "bitmap") // stupid | bitmap
OPTION(bluestore_freelist_type, OPT_STR, "bitmap") // extent | bitmap
Expand All @@ -1009,10 +1012,12 @@ OPTION(bluestore_bitmapallocator_blocks_per_zone, OPT_INT, 1024) // must be powe
OPTION(bluestore_bitmapallocator_span_size, OPT_INT, 1024) // must be power of 2 aligned, e.g., 512, 1024, 2048...
OPTION(bluestore_rocksdb_options, OPT_STR, "compression=kNoCompression,max_write_buffer_number=4,min_write_buffer_number_to_merge=1,recycle_log_file_num=4,write_buffer_size=268435456")
OPTION(bluestore_fsck_on_mount, OPT_BOOL, false)
OPTION(bluestore_fsck_on_mount_deep, OPT_BOOL, true)
OPTION(bluestore_fsck_on_umount, OPT_BOOL, false)
OPTION(bluestore_fsck_on_umount_deep, OPT_BOOL, true)
OPTION(bluestore_fsck_on_mkfs, OPT_BOOL, true)
OPTION(bluestore_sync_transaction, OPT_BOOL, false) // perform kv txn synchronously
OPTION(bluestore_sync_submit_transaction, OPT_BOOL, false)
OPTION(bluestore_fsck_on_mkfs_deep, OPT_BOOL, false)
OPTION(bluestore_sync_submit_transaction, OPT_BOOL, true) // submit kv txn in queueing thread (not kv_sync_thread)
OPTION(bluestore_sync_wal_apply, OPT_BOOL, true) // perform initial wal work synchronously (possibly in combination with aio so we only *queue* ios)
OPTION(bluestore_wal_threads, OPT_INT, 4)
OPTION(bluestore_wal_thread_timeout, OPT_INT, 30)
Expand All @@ -1033,6 +1038,7 @@ OPTION(bluestore_debug_freelist, OPT_BOOL, false)
OPTION(bluestore_debug_prefill, OPT_FLOAT, 0)
OPTION(bluestore_debug_prefragment_max, OPT_INT, 1048576)
OPTION(bluestore_debug_inject_read_err, OPT_BOOL, false)
OPTION(bluestore_debug_randomize_serial_transaction, OPT_INT, 0)
OPTION(bluestore_inject_wal_apply_delay, OPT_FLOAT, 0)
OPTION(bluestore_shard_finishers, OPT_BOOL, false)

Expand All @@ -1041,6 +1047,7 @@ OPTION(kstore_max_bytes, OPT_U64, 64*1024*1024)
OPTION(kstore_backend, OPT_STR, "rocksdb")
OPTION(kstore_rocksdb_options, OPT_STR, "compression=kNoCompression")
OPTION(kstore_fsck_on_mount, OPT_BOOL, false)
OPTION(kstore_fsck_on_mount_deep, OPT_BOOL, true)
OPTION(kstore_nid_prealloc, OPT_U64, 1024)
OPTION(kstore_sync_transaction, OPT_BOOL, false)
OPTION(kstore_sync_submit_transaction, OPT_BOOL, false)
Expand Down
3 changes: 2 additions & 1 deletion src/global/CMakeLists.txt
@@ -1,7 +1,8 @@
set(libglobal_srcs
global_init.cc
pidfile.cc
signal_handler.cc)
signal_handler.cc
mempool.cc)
set(global_common_files
global_context.cc)
add_library(global_common_objs OBJECT ${global_common_files})
Expand Down
56 changes: 56 additions & 0 deletions src/global/global_init.cc
Expand Up @@ -12,6 +12,7 @@
*
*/

#include "include/mempool.h"
#include "common/ceph_argparse.h"
#include "common/code_environment.h"
#include "common/config.h"
Expand All @@ -26,6 +27,7 @@
#include "global/signal_handler.h"
#include "include/compat.h"
#include "include/str_list.h"
#include "common/admin_socket.h"

#include <pwd.h>
#include <grp.h>
Expand All @@ -37,6 +39,56 @@

#define dout_subsys ceph_subsys_

class GlobalObs : public md_config_obs_t,
public AdminSocketHook {
CephContext *cct;

public:
explicit GlobalObs(CephContext *cct) : cct(cct) {
cct->_conf->add_observer(this);
int r = cct->get_admin_socket()->register_command(
"dump_mempools",
"dump_mempools",
this,
"get mempool stats");
assert(r == 0);
}
~GlobalObs() {
cct->_conf->remove_observer(this);
cct->get_admin_socket()->unregister_command("dump_mempools");
}

// md_config_obs_t
const char** get_tracked_conf_keys() const {
static const char *KEYS[] = {
"mempool_debug",
NULL
};
return KEYS;
}

void handle_conf_change(const md_config_t *conf,
const std::set <std::string> &changed) {
if (changed.count("mempool_debug")) {
mempool::set_debug_mode(cct->_conf->mempool_debug);
}
}

// AdminSocketHook
bool call(std::string command, cmdmap_t& cmdmap, std::string format,
bufferlist& out) {
if (command == "dump_mempools") {
std::unique_ptr<Formatter> f(Formatter::create(format));
f->open_object_section("mempools");
mempool::dump(f.get());
f->close_section();
f->flush(out);
return true;
}
return false;
}
};

static void global_init_set_globals(CephContext *cct)
{
g_ceph_context = cct;
Expand Down Expand Up @@ -97,6 +149,10 @@ void global_pre_init(std::vector < const char * > *alt_def_args,
if (alt_def_args)
conf->parse_argv(*alt_def_args); // alternative default args

// set up global config observer
GlobalObs *obs = 0;
g_ceph_context->lookup_or_create_singleton_object(obs, "global_obs");

int ret = conf->parse_config_files(c_str_or_null(conf_file_list),
&cerr, flags);
if (ret == -EDOM) {
Expand Down
112 changes: 112 additions & 0 deletions src/global/mempool.cc
@@ -0,0 +1,112 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2016 Allen Samuels <allen.samuels@sandisk.com>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/

#include "include/mempool.h"
#include "include/demangle.h"


// default to debug_mode off
bool mempool::debug_mode = false;

// --------------------------------------------------------------

mempool::pool_t& mempool::get_pool(mempool::pool_index_t ix)
{
// We rely on this array being initialized before any invocation of
// this function, even if it is called by ctors in other compilation
// units that are being initialized before this compilation unit.
static mempool::pool_t table[num_pools];
return table[ix];
}

const char *mempool::get_pool_name(mempool::pool_index_t ix) {
#define P(x) #x,
static const char *names[num_pools] = {
DEFINE_MEMORY_POOLS_HELPER(P)
};
#undef P
return names[ix];
}

void mempool::dump(ceph::Formatter *f, size_t skip)
{
for (size_t i = skip; i < num_pools; ++i) {
const pool_t &pool = mempool::get_pool((pool_index_t)i);
f->open_object_section(get_pool_name((pool_index_t)i));
pool.dump(f);
f->close_section();
}
}

void mempool::set_debug_mode(bool d)
{
debug_mode = d;
}

// --------------------------------------------------------------
// pool_t

size_t mempool::pool_t::allocated_bytes() const
{
ssize_t result = 0;
for (size_t i = 0; i < num_shards; ++i) {
result += shard[i].bytes;
}
assert(result >= 0);
return (size_t) result;
}

size_t mempool::pool_t::allocated_items() const
{
ssize_t result = 0;
for (size_t i = 0; i < num_shards; ++i) {
result += shard[i].items;
}
assert(result >= 0);
return (size_t) result;
}

void mempool::pool_t::get_stats(
stats_t *total,
std::map<std::string, stats_t> *by_type) const
{
for (size_t i = 0; i < num_shards; ++i) {
total->items += shard[i].items;
total->bytes += shard[i].bytes;
}
if (debug_mode) {
std::unique_lock<std::mutex> shard_lock(lock);
for (auto &p : type_map) {
std::string n = ceph_demangle(p.second.type_name);
stats_t &s = (*by_type)[n];
s.bytes = p.second.items * p.second.item_size;
s.items = p.second.items;
}
}
}

void mempool::pool_t::dump(ceph::Formatter *f) const
{
stats_t total;
std::map<std::string, stats_t> by_type;
get_stats(&total, &by_type);
f->dump_object("total", total);
if (!by_type.empty()) {
for (auto &i : by_type) {
f->open_object_section(i.first.c_str());
i.second.dump(f);
f->close_section();
}
}
}
1 change: 1 addition & 0 deletions src/include/CMakeLists.txt
Expand Up @@ -4,6 +4,7 @@ install(FILES rados/librados.h
rados/librados.hpp
buffer.h
buffer_fwd.h
inline_memory.h
memory.h
page.h
crc32c.h
Expand Down
2 changes: 1 addition & 1 deletion src/include/buffer.h
Expand Up @@ -55,7 +55,7 @@
# include <assert.h>
#endif

#include "include/inline_memory.h"
#include "inline_memory.h"

#if __GNUC__ >= 4
#define CEPH_BUFFER_API __attribute__ ((visibility ("default")))
Expand Down
3 changes: 3 additions & 0 deletions src/include/config-h.in.cmake
Expand Up @@ -126,6 +126,9 @@
/* define if radosgw enabled */
#cmakedefine WITH_RADOSGW

/* define if radosgw's asio frontend enabled */
#cmakedefine WITH_RADOSGW_ASIO_FRONTEND

/* define if HAVE_THREAD_SAFE_RES_QUERY */
#cmakedefine HAVE_THREAD_SAFE_RES_QUERY

Expand Down

0 comments on commit 19f7d0e

Please sign in to comment.