mirror of
https://github.com/ceph/ceph
synced 2025-04-01 00:26:47 +00:00
Merge branch 'unstable' of ssh://ceph.newdream.net/home/sage/ceph.newdream.net/git/ceph into unstable
This commit is contained in:
commit
6a53d7337c
@ -258,14 +258,14 @@ editpaths = sed \
|
||||
-e 's|@datadir[@]|$(pkgdatadir)|g' \
|
||||
-e 's|@prefix[@]|$(prefix)|g'
|
||||
|
||||
init-ceph mkcephfs cclass: init-ceph.in mkcephfs.in cclass.in Makefile
|
||||
init-ceph mkcephfs cclass cdebugpack: init-ceph.in mkcephfs.in cclass.in Makefile cdebugpack.in
|
||||
rm -f $@ $@.tmp
|
||||
$(editpaths) '$(srcdir)/$@.in' >$@.tmp
|
||||
chmod +x $@.tmp
|
||||
chmod a-w $@.tmp
|
||||
mv $@.tmp $@
|
||||
|
||||
BUILT_SOURCES += init-ceph mkcephfs cclass
|
||||
BUILT_SOURCES += init-ceph mkcephfs cclass cdebugpack
|
||||
|
||||
##
|
||||
LDADD =
|
||||
|
@ -32,6 +32,8 @@ int main(int argc, const char **argv)
|
||||
vector<const char*> args, nargs;
|
||||
deque<const char *> sections;
|
||||
unsigned i;
|
||||
std::vector<const char *> empty_args;
|
||||
char buf[1024];
|
||||
DEFINE_CONF_VARS(usage);
|
||||
|
||||
argv_to_vec(argc, argv, args);
|
||||
@ -110,6 +112,10 @@ int main(int argc, const char **argv)
|
||||
goto done_ok;
|
||||
}
|
||||
|
||||
parse_startup_config_options(empty_args, type);
|
||||
if (ceph_def_conf_by_name(key, buf, sizeof(buf)))
|
||||
cout << buf << std::endl;
|
||||
|
||||
exit(1);
|
||||
|
||||
done_ok:
|
||||
|
109
src/cdebugpack.in
Normal file
109
src/cdebugpack.in
Normal file
@ -0,0 +1,109 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
|
||||
# if we start up as ./init-ceph, assume everything else is in the
|
||||
# current directory too.
|
||||
if [ `dirname $0` = "." ] && [ $PWD != "/etc/init.d" ]; then
|
||||
BINDIR=.
|
||||
LIBDIR=.
|
||||
ETCDIR=.
|
||||
else
|
||||
BINDIR=@bindir@
|
||||
LIBDIR=@libdir@/ceph
|
||||
# i hate autoconf:
|
||||
if [ "@sysconfdir@" = "/usr/etc" ]; then
|
||||
ETCDIR=/etc/ceph
|
||||
else
|
||||
ETCDIR=@sysconfdir@/ceph
|
||||
fi
|
||||
fi
|
||||
|
||||
BINDBGDIR="/usr/lib/debug/usr/bin"
|
||||
|
||||
usage_exit() {
|
||||
echo "usage: $0 [-c ceph.conf] <filename>"
|
||||
exit
|
||||
}
|
||||
|
||||
|
||||
. $LIBDIR/ceph_common.sh
|
||||
|
||||
dest_tar=""
|
||||
|
||||
while [ $# -ge 1 ]; do
|
||||
case $1 in
|
||||
--conf | -c)
|
||||
[ -z "$2" ] && usage_exit
|
||||
shift
|
||||
conf=$1
|
||||
;;
|
||||
*)
|
||||
if [ "$dest_tar" != "" ]; then
|
||||
echo unrecognized option \'$1\'
|
||||
usage_exit
|
||||
fi
|
||||
dest_tar=$1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ "$dest_tar" == "" ] && usage_exit
|
||||
|
||||
# get absolute path for dest_tar
|
||||
[ "${dest_tar::1}" != "/" ] && dest_tar="`pwd`/$dest_tar"
|
||||
|
||||
bins="cmon cmds cosd"
|
||||
core_paths="/ $BINDIR $BINDBGDIR"
|
||||
[ "$conf" == "" ] && conf=$ETCDIR/ceph.conf
|
||||
log_path=`$CCONF -c $conf "log dir"`
|
||||
|
||||
[ -z "$conf" ] && usage_exit
|
||||
|
||||
|
||||
tmp_path=`mktemp -d /tmp/cdebugpack.XXXXXXXXXX`
|
||||
tmp_path_bin=$tmp_path/bin
|
||||
tmp_path_bin_dbg=$tmp_path/bin.dbg
|
||||
tmp_path_log=$tmp_path/out
|
||||
tmp_path_core=$tmp_path/core
|
||||
|
||||
echo tmp_path=$tmp_path
|
||||
|
||||
mkdir -p $tmp_path_bin
|
||||
mkdir -p $tmp_path_bin_dbg
|
||||
mkdir -p $tmp_path_log
|
||||
mkdir -p $tmp_path_core
|
||||
|
||||
|
||||
#copy the binaries
|
||||
|
||||
for name in $bins; do
|
||||
[ -e $BINDIR/$name ] && cp $BINDIR/$name $tmp_path_bin
|
||||
[ -e $BINDBGDIR/$name ] && cp $BINDBGDIR/$name $tmp_path_bin_dbg
|
||||
done
|
||||
|
||||
|
||||
# copy the logs
|
||||
cp -rp $log_path/* $tmp_path_log
|
||||
|
||||
# copy cores (if exist)
|
||||
|
||||
for path in $core_paths; do
|
||||
files="`find $path -maxdepth 1 -name 'core*'`"
|
||||
if [ "$files" != "" ]; then
|
||||
for core_file in `ls $path/core*`; do
|
||||
tmp_core=`mktemp $tmp_path_core/core.XXXX`
|
||||
cp $core_file $tmp_core
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# now create a tarball
|
||||
|
||||
cd $tmp_path
|
||||
tar cvfz $dest_tar -C $tmp_path *
|
||||
|
||||
rm -fR $tmp_path
|
||||
|
@ -216,6 +216,7 @@ static void (*old_sigabrt_handler)(int);
|
||||
|
||||
void sigsegv_handler(int signum)
|
||||
{
|
||||
*_dout << "*** Caught signal (SEGV) ***" << std::endl;
|
||||
BackTrace bt(0);
|
||||
bt.print(*_dout);
|
||||
|
||||
@ -224,6 +225,7 @@ void sigsegv_handler(int signum)
|
||||
|
||||
void sigabrt_handler(int signum)
|
||||
{
|
||||
*_dout << "*** Caught signal (ABRT) ***" << std::endl;
|
||||
BackTrace bt(0);
|
||||
bt.print(*_dout);
|
||||
|
||||
@ -739,6 +741,58 @@ static bool init_g_conf()
|
||||
return true;
|
||||
}
|
||||
|
||||
static int def_conf_to_str(config_option *opt, char *buf, int len)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (opt->type) {
|
||||
case OPT_INT:
|
||||
case OPT_BOOL:
|
||||
ret = snprintf(buf, len, "%d", (int)opt->def_longlong);
|
||||
break;
|
||||
case OPT_LONGLONG:
|
||||
ret = snprintf(buf, len, "%lld", opt->def_longlong);
|
||||
break;
|
||||
case OPT_STR:
|
||||
case OPT_ADDR:
|
||||
ret = snprintf(buf, len, "%s", opt->def_str);
|
||||
break;
|
||||
case OPT_FLOAT:
|
||||
case OPT_DOUBLE:
|
||||
ret = snprintf(buf, len, "%f", opt->def_double);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ceph_def_conf_by_name(const char *name, char *buf, int buflen)
|
||||
{
|
||||
char *newname = strdup(name);
|
||||
int len = strlen(name);
|
||||
config_option *opt;
|
||||
int ret = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (newname[i] == ' ')
|
||||
newname[i] = '_';
|
||||
}
|
||||
|
||||
len = sizeof(config_optionsp)/sizeof(config_option);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
opt = &config_optionsp[i];
|
||||
if (strcmp(opt->name, newname) == 0) {
|
||||
ret = def_conf_to_str(opt, buf, buflen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(newname);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void fini_g_conf()
|
||||
{
|
||||
int len = sizeof(config_optionsp)/sizeof(config_option);
|
||||
|
@ -482,6 +482,7 @@ char *conf_post_process_val(const char *val);
|
||||
int conf_read_key(const char *alt_section, const char *key, opt_type_t type, void *out, void *def, bool free_old_val = false);
|
||||
bool conf_set_conf_val(void *field, opt_type_t type, const char *val);
|
||||
bool conf_cmd_equals(const char *cmd, const char *opt, char char_opt, unsigned int *val_pos);
|
||||
int ceph_def_conf_by_name(const char *name, char *buf, int len);
|
||||
|
||||
class ExportControl;
|
||||
ExportControl *conf_get_export_control();
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "common/Timer.h"
|
||||
#include "common/Clock.h"
|
||||
#include "include/color.h"
|
||||
|
||||
#include "OSDMonitor.h"
|
||||
#include "MDSMonitor.h"
|
||||
@ -972,7 +973,15 @@ int Monitor::mkfs(bufferlist& osdmapbl)
|
||||
bufferlist magicbl;
|
||||
magicbl.append(CEPH_MON_ONDISK_MAGIC);
|
||||
magicbl.append("\n");
|
||||
store->put_bl_ss(magicbl, "magic", 0);
|
||||
try {
|
||||
store->put_bl_ss(magicbl, "magic", 0);
|
||||
}
|
||||
catch (const MonitorStore::Error &e) {
|
||||
std::cerr << TEXT_RED << "** ERROR: initializing cmon failed: couldn't "
|
||||
<< "initialize the monitor state machine: "
|
||||
<< e.what() << TEXT_NORMAL << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bufferlist features;
|
||||
CompatSet mon_features(ceph_mon_feature_compat,
|
||||
|
@ -31,8 +31,31 @@ static ostream& _prefix(const string& dir) {
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sstream>
|
||||
#include <sys/file.h>
|
||||
|
||||
MonitorStore::Error MonitorStore::Error::
|
||||
FromErrno(const char *prefix, const char *prefix2, int errno_)
|
||||
{
|
||||
char buf[128];
|
||||
const char *b2 = strerror_r(errno_, buf, sizeof(buf));
|
||||
ostringstream oss;
|
||||
oss << prefix << prefix2 << ": " << b2 << " (" << errno_ << ")";
|
||||
return MonitorStore::Error(oss.str());
|
||||
}
|
||||
|
||||
MonitorStore::Error::
|
||||
Error(const std::string &str_) : str(str_) { }
|
||||
|
||||
MonitorStore::Error::
|
||||
~Error() throw () { }
|
||||
|
||||
const char *MonitorStore::Error::
|
||||
what() const throw ()
|
||||
{
|
||||
return str.c_str();
|
||||
}
|
||||
|
||||
int MonitorStore::mount()
|
||||
{
|
||||
char t[1024];
|
||||
@ -256,11 +279,14 @@ int MonitorStore::write_bl_ss(bufferlist& bl, const char *a, const char *b, bool
|
||||
int fd;
|
||||
if (append) {
|
||||
fd = ::open(fn, O_WRONLY|O_CREAT|O_APPEND, 0644);
|
||||
if (fd < 0)
|
||||
throw Error::FromErrno("failed to open for append: ", fn, errno);
|
||||
} else {
|
||||
snprintf(tfn, sizeof(tfn), "%s.new", fn);
|
||||
fd = ::open(tfn, O_WRONLY|O_CREAT, 0644);
|
||||
if (fd < 0)
|
||||
throw Error::FromErrno("failed to open: ", tfn, errno);
|
||||
}
|
||||
assert(fd >= 0);
|
||||
|
||||
err = bl.write_fd(fd);
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "include/types.h"
|
||||
#include "include/buffer.h"
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string.h>
|
||||
|
||||
class MonitorStore {
|
||||
@ -25,7 +26,20 @@ class MonitorStore {
|
||||
int lock_fd;
|
||||
|
||||
int write_bl_ss(bufferlist& bl, const char *a, const char *b, bool append, bool sync=true);
|
||||
|
||||
public:
|
||||
class Error : public std::exception
|
||||
{
|
||||
public:
|
||||
static Error FromErrno(const char *prefix,
|
||||
const char *prefix2, int errno_);
|
||||
Error(const std::string &str_);
|
||||
virtual ~Error() throw ();
|
||||
const char *what() const throw ();
|
||||
private:
|
||||
std::string str;
|
||||
};
|
||||
|
||||
MonitorStore(const char *d) : dir(d) { }
|
||||
~MonitorStore() { }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user