mirror of
https://github.com/ceph/ceph
synced 2025-04-01 00:26:47 +00:00
osd: --get-journal-fsid
Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
parent
ae8fbb881a
commit
dc977901c6
@ -69,6 +69,21 @@ Options
|
||||
resize the journal or need to otherwise destroy it: this guarantees
|
||||
you won't lose data.
|
||||
|
||||
.. option:: --get-cluster-fsid
|
||||
|
||||
Print the cluster fsid (uuid) and exit.
|
||||
|
||||
.. option:: --get-osd-fsid
|
||||
|
||||
Print the OSD's fsid and exit. The OSD's uuid is generated at
|
||||
--mkfs time and is thus unique to a particular instantiation of
|
||||
this OSD.
|
||||
|
||||
.. option:: --get-journal-fsid
|
||||
|
||||
Print the journal's uuid. The journal fsid is set to match the OSD
|
||||
fsid at --mkfs time.
|
||||
|
||||
.. option:: -c ceph.conf, --conf=ceph.conf
|
||||
|
||||
Use *ceph.conf* configuration file instead of the default
|
||||
|
@ -65,6 +65,7 @@ int main(int argc, const char **argv)
|
||||
bool mkkey = false;
|
||||
bool flushjournal = false;
|
||||
bool convertfilestore = false;
|
||||
bool get_journal_fsid = false;
|
||||
bool get_osd_fsid = false;
|
||||
bool get_cluster_fsid = false;
|
||||
std::string dump_pg_log;
|
||||
@ -92,6 +93,8 @@ int main(int argc, const char **argv)
|
||||
get_cluster_fsid = true;
|
||||
} else if (ceph_argparse_flag(args, i, "--get-osd-fsid", (char*)NULL)) {
|
||||
get_osd_fsid = true;
|
||||
} else if (ceph_argparse_flag(args, i, "--get-journal-fsid", (char*)NULL)) {
|
||||
get_journal_fsid = true;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
@ -250,6 +253,13 @@ int main(int argc, const char **argv)
|
||||
cout << osd_fsid << std::endl;
|
||||
exit(0);
|
||||
}
|
||||
if (get_journal_fsid) {
|
||||
uuid_d fsid;
|
||||
int r = OSD::peek_journal_fsid(g_conf->osd_journal, fsid);
|
||||
if (r == 0)
|
||||
cout << fsid << std::endl;
|
||||
exit(r);
|
||||
}
|
||||
|
||||
pick_addresses(g_ceph_context);
|
||||
|
||||
|
@ -394,6 +394,18 @@ done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int FileJournal::peek_fsid(uuid_d& fsid)
|
||||
{
|
||||
int r = _open(false, false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = read_header();
|
||||
if (r < 0)
|
||||
return r;
|
||||
fsid = header.fsid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FileJournal::open(uint64_t fs_op_seq)
|
||||
{
|
||||
dout(2) << "open " << fn << " fsid " << fsid << " fs_op_seq " << fs_op_seq << dendl;
|
||||
|
@ -30,24 +30,6 @@ public:
|
||||
/*
|
||||
* journal header
|
||||
*/
|
||||
#if 0
|
||||
struct old_header_t {
|
||||
__u32 version;
|
||||
__u32 flags;
|
||||
uint64_t fsid;
|
||||
__u32 block_size;
|
||||
__u32 alignment;
|
||||
int64_t max_size; // max size of journal ring buffer
|
||||
int64_t start; // offset of first entry
|
||||
|
||||
old_header_t() : version(1), flags(0), fsid(0), block_size(0), alignment(0), max_size(0), start(0) {}
|
||||
|
||||
void clear() {
|
||||
start = block_size;
|
||||
}
|
||||
} __attribute__((__packed__, aligned(4)));
|
||||
#endif
|
||||
|
||||
struct header_t {
|
||||
uint64_t flags;
|
||||
uuid_d fsid;
|
||||
@ -83,7 +65,7 @@ public:
|
||||
::decode(v, bl);
|
||||
if (v < 2) { // normally 0, but concievably 1
|
||||
// decode old header_t struct (pre v0.40).
|
||||
bl.advance(4); // skip flags (was unused by old code)
|
||||
bl.advance(4); // skip __u32 flags (it was unused by any old code)
|
||||
flags = 0;
|
||||
uint64_t tfsid;
|
||||
::decode(tfsid, bl);
|
||||
@ -254,6 +236,7 @@ private:
|
||||
int create();
|
||||
int open(uint64_t fs_op_seq);
|
||||
void close();
|
||||
int peek_fsid(uuid_d& fsid);
|
||||
|
||||
void flush();
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include "common/ceph_argparse.h"
|
||||
#include "os/FileStore.h"
|
||||
#include "os/FileJournal.h"
|
||||
|
||||
#include "ReplicatedPG.h"
|
||||
|
||||
@ -496,6 +497,13 @@ int OSD::peek_meta(const std::string &dev, std::string& magic,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OSD::peek_journal_fsid(string path, uuid_d& fsid)
|
||||
{
|
||||
FileJournal j(fsid, 0, 0, path.c_str());
|
||||
return j.peek_fsid(fsid);
|
||||
}
|
||||
|
||||
|
||||
#undef dout_prefix
|
||||
#define dout_prefix _prefix(_dout, whoami, osdmap)
|
||||
|
||||
|
@ -1061,6 +1061,7 @@ private:
|
||||
public:
|
||||
static int peek_meta(const std::string &dev, string& magic,
|
||||
uuid_d& cluster_fsid, uuid_d& osd_fsid, int& whoami);
|
||||
static int peek_journal_fsid(std::string jpath, uuid_d& fsid);
|
||||
|
||||
|
||||
// startup/shutdown
|
||||
|
Loading…
Reference in New Issue
Block a user