bool mkjournal = false;
bool mkkey = false;
bool flushjournal = false;
+ bool dump_journal = false;
bool convertfilestore = false;
bool get_journal_fsid = false;
bool get_osd_fsid = false;
convertfilestore = true;
} else if (ceph_argparse_witharg(args, i, &val, "--dump-pg-log", (char*)NULL)) {
dump_pg_log = val;
+ } else if (ceph_argparse_flag(args, i, "--dump-journal", (char*)NULL)) {
+ dump_journal = true;
} else if (ceph_argparse_flag(args, i, "--get-cluster-fsid", (char*)NULL)) {
get_cluster_fsid = true;
} else if (ceph_argparse_flag(args, i, "--get-osd-fsid", (char*)NULL)) {
<< dendl;
exit(0);
}
+ if (dump_journal) {
+ common_init_finish(g_ceph_context);
+ int err = OSD::dump_journal(g_conf->osd_data, g_conf->osd_journal, cout);
+ if (err < 0) {
+ derr << TEXT_RED << " ** ERROR: error dumping journal " << g_conf->osd_journal
+ << " for object store " << g_conf->osd_data
+ << ": " << cpp_strerror(-err) << TEXT_NORMAL << dendl;
+ exit(1);
+ }
+ derr << "dumped journal " << g_conf->osd_journal
+ << " for object store " << g_conf->osd_data
+ << dendl;
+ exit(0);
+
+ }
+
if (convertfilestore) {
int err = OSD::convertfs(g_conf->osd_data, g_conf->osd_journal);
fd = -1;
}
+
+int FileJournal::dump(ostream& out)
+{
+ dout(10) << "dump" << dendl;
+ _open(false, false);
+
+ int err = read_header();
+ if (err < 0)
+ return err;
+
+ read_pos = header.start;
+
+ while (1) {
+ bufferlist bl;
+ uint64_t seq = 0;
+ uint64_t pos = read_pos;
+ if (!read_entry(bl, seq)) {
+ dout(3) << "journal_replay: end of journal, done." << dendl;
+ break;
+ }
+
+ out << "offset " << pos << " seq " << seq << "\n";
+
+ bufferlist::iterator p = bl.begin();
+ while (!p.end()) {
+ ObjectStore::Transaction *t = new ObjectStore::Transaction(p);
+ t->dump(out);
+ delete t;
+ }
+ }
+ out << std::endl;
+ dout(10) << "dump finish" << dendl;
+ return 0;
+}
+
+
void FileJournal::start_writer()
{
write_stop = false;
void close();
int peek_fsid(uuid_d& fsid);
+ int dump(ostream& out);
+
void flush();
void throttle();
return 0;
}
+int FileStore::dump_journal(ostream& out)
+{
+ int r;
+
+ if (!journalpath.length())
+ return -EINVAL;
+
+ FileJournal *journal = new FileJournal(fsid, &finisher, &sync_cond, journalpath.c_str(), m_journal_dio);
+ r = journal->dump(out);
+ delete journal;
+ return r;
+}
+
int FileStore::wipe_subvol(const char *s)
{
#if defined(__linux__)
void flush();
void sync_and_flush();
+ int dump_journal(ostream& out);
+
uuid_d get_fsid() { return fsid; }
int snapshot(const string& name);
#ifndef CEPH_JOURNAL_H
#define CEPH_JOURNAL_H
+#include <errno.h>
+
#include "include/buffer.h"
#include "include/Context.h"
#include "common/Finisher.h"
virtual void flush() = 0;
virtual void throttle() = 0;
+ virtual int dump(ostream& out) { return -EOPNOTSUPP; }
+
void set_wait_on_full(bool b) { wait_on_full = b; }
// writes
virtual void flush() {}
virtual void sync_and_flush() {}
+ virtual int dump_journal(ostream& out) { return -EOPNOTSUPP; }
+
virtual int snapshot(const string& name) { return -EOPNOTSUPP; }
virtual void _fake_writes(bool b) {};
return err;
}
+int OSD::dump_journal(const std::string &dev, const std::string &jdev, ostream& out)
+{
+ ObjectStore *store = create_object_store(dev, jdev);
+ if (!store)
+ return -ENOENT;
+ int err = store->dump_journal(out);
+ delete store;
+ return err;
+}
+
int OSD::write_meta(const std::string &base, const std::string &file,
const char *val, size_t vallen)
{
uuid_d fsid, int whoami);
static int mkjournal(const std::string &dev, const std::string &jdev);
static int flushjournal(const std::string &dev, const std::string &jdev);
+ static int dump_journal(const std::string &dev, const std::string &jdev, ostream& out);
/* remove any non-user xattrs from a map of them */
void filter_xattrs(map<string, bufferptr>& attrs) {
for (map<string, bufferptr>::iterator iter = attrs.begin();