Make it look more like uuid_t. Rename type, comparator.
- client, user authentication
- cas
- osd failure declarations
-- libuuid?
repair
if (whoami < 0) {
nstring magic;
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
int r = OSD::peek_super(dev, magic, fsid, whoami);
if (r < 0) {
cerr << "unable to determine OSD identity from superblock on " << dev << ": " << strerror(-r) << std::endl;
cerr << "OSD magic " << magic << " != my " << CEPH_OSD_ONDISK_MAGIC << std::endl;
exit(1);
}
- if (!ceph_fsid_equal(&fsid, &monmap.fsid)) {
+ if (ceph_fsid_compare(&fsid, &monmap.fsid)) {
cerr << "OSD fsid " << fsid << " != monmap fsid " << monmap.fsid << std::endl;
exit(1);
}
/*
* fs id
*/
-struct ceph_fsid {
- __le64 major;
- __le64 minor;
-} __attribute__ ((packed));
+typedef struct { unsigned char fsid[16]; } ceph_fsid_t;
-static inline int ceph_fsid_equal(const struct ceph_fsid *a,
- const struct ceph_fsid *b)
+static inline int ceph_fsid_compare(const ceph_fsid_t *a,
+ const ceph_fsid_t *b)
{
- return a->major == b->major && a->minor == b->minor;
+ return memcmp(a, b, sizeof(*a));
}
struct ceph_mon_statfs {
- struct ceph_fsid fsid;
+ ceph_fsid_t fsid;
__le64 tid;
};
};
struct ceph_mon_statfs_reply {
- struct ceph_fsid fsid;
+ ceph_fsid_t fsid;
__le64 tid;
struct ceph_statfs st;
};
struct ceph_osd_getmap {
- struct ceph_fsid fsid;
+ ceph_fsid_t fsid;
__le32 start;
} __attribute__ ((packed));
struct ceph_mds_getmap {
- struct ceph_fsid fsid;
+ ceph_fsid_t fsid;
__le32 want;
} __attribute__ ((packed));
#include "encoding.h"
-WRITE_RAW_ENCODER(ceph_fsid)
+WRITE_RAW_ENCODER(ceph_fsid_t)
WRITE_RAW_ENCODER(ceph_file_layout)
WRITE_RAW_ENCODER(ceph_mds_request_head)
WRITE_RAW_ENCODER(ceph_mds_caps)
// --
-inline ostream& operator<<(ostream& out, const ceph_fsid& f) {
- return out << hex << f.major << '.' << f.minor << dec;
+inline ostream& operator<<(ostream& out, const ceph_fsid_t& f) {
+ char b[37];
+ sprintf(b, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ f.fsid[0], f.fsid[1], f.fsid[2], f.fsid[3], f.fsid[4], f.fsid[5], f.fsid[6], f.fsid[7],
+ f.fsid[8], f.fsid[9], f.fsid[10], f.fsid[11], f.fsid[12], f.fsid[13], f.fsid[14], f.fsid[15]);
+ return out << b;
}
inline ostream& operator<<(ostream& out, const ceph_osd_op& op) {
class MLog : public Message {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
deque<LogEntry> entries;
version_t last;
MLog() : Message(MSG_PGSTATS) {}
- MLog(ceph_fsid& f, deque<LogEntry>& e) :
+ MLog(ceph_fsid_t& f, deque<LogEntry>& e) :
Message(MSG_LOG), fsid(f), entries(e), last(0) { }
- MLog(ceph_fsid& f, version_t l) :
+ MLog(ceph_fsid_t& f, version_t l) :
Message(MSG_LOG), fsid(f), last(l) {}
const char *get_type_name() { return "log"; }
#include "mds/MDSMap.h"
class MMDSBeacon : public Message {
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
epoch_t last_epoch_seen; // include last mdsmap epoch mds has seen to avoid race with monitor decree
__u32 state;
version_t seq;
public:
MMDSBeacon() : Message(MSG_MDS_BEACON) {}
- MMDSBeacon(ceph_fsid &f, epoch_t les, int st, version_t se, int wr) :
+ MMDSBeacon(ceph_fsid_t &f, epoch_t les, int st, version_t se, int wr) :
Message(MSG_MDS_BEACON),
fsid(f), last_epoch_seen(les), state(st), seq(se), want_rank(wr) { }
- ceph_fsid& get_fsid() { return fsid; }
+ ceph_fsid_t& get_fsid() { return fsid; }
epoch_t get_last_epoch_seen() { return last_epoch_seen; }
int get_state() { return state; }
version_t get_seq() { return seq; }
class MMDSGetMap : public Message {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
epoch_t want;
MMDSGetMap() {}
- MMDSGetMap(ceph_fsid &f, epoch_t w=0) :
+ MMDSGetMap(ceph_fsid_t &f, epoch_t w=0) :
Message(CEPH_MSG_MDS_GETMAP),
fsid(f),
want(w) { }
}
*/
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
epoch_t epoch;
bufferlist encoded;
MMDSMap() :
Message(CEPH_MSG_MDS_MAP) {}
- MMDSMap(ceph_fsid &f, MDSMap *mm) :
+ MMDSMap(ceph_fsid_t &f, MDSMap *mm) :
Message(CEPH_MSG_MDS_MAP),
fsid(f) {
epoch = mm->get_epoch();
class MMonCommand : public Message {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
vector<string> cmd;
MMonCommand() : Message(MSG_MON_COMMAND) {}
- MMonCommand(ceph_fsid &f) :
+ MMonCommand(ceph_fsid_t &f) :
Message(MSG_MON_COMMAND),
fsid(f) { }
class MMonObserve : public Message {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
uint32_t machine_id;
version_t ver;
MMonObserve() : Message(MSG_MON_OBSERVE) {}
- MMonObserve(ceph_fsid &f, int mid, version_t v) :
+ MMonObserve(ceph_fsid_t &f, int mid, version_t v) :
Message(MSG_MON_OBSERVE),
fsid(f), machine_id(mid), ver(v) { }
class MOSDFailure : public Message {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
entity_inst_t failed;
epoch_t epoch;
MOSDFailure() : Message(MSG_OSD_FAILURE) {}
- MOSDFailure(ceph_fsid &fs, entity_inst_t f, epoch_t e) :
+ MOSDFailure(ceph_fsid_t &fs, entity_inst_t f, epoch_t e) :
Message(MSG_OSD_FAILURE),
fsid(fs), failed(f), epoch(e) {}
class MOSDGetMap : public Message {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
epoch_t start; // this is the first incremental the sender wants (he has start-1)
MOSDGetMap() : Message(CEPH_MSG_OSD_GETMAP) {}
- MOSDGetMap(ceph_fsid& f, epoch_t s=0) :
+ MOSDGetMap(ceph_fsid_t& f, epoch_t s=0) :
Message(CEPH_MSG_OSD_GETMAP),
fsid(f), start(s) { }
class MOSDMap : public Message {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
map<epoch_t, bufferlist> maps;
map<epoch_t, bufferlist> incremental_maps;
MOSDMap() : Message(CEPH_MSG_OSD_MAP) { }
- MOSDMap(ceph_fsid &f, OSDMap *oc=0) : Message(CEPH_MSG_OSD_MAP),
+ MOSDMap(ceph_fsid_t &f, OSDMap *oc=0) : Message(CEPH_MSG_OSD_MAP),
fsid(f) {
if (oc)
oc->encode(maps[oc->get_epoch()]);
class MOSDPing : public Message {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
epoch_t map_epoch, peer_as_of_epoch;
bool ack;
osd_peer_stat_t peer_stat;
- MOSDPing(ceph_fsid& f, epoch_t e, epoch_t pe, osd_peer_stat_t& ps, bool a=false) :
+ MOSDPing(ceph_fsid_t& f, epoch_t e, epoch_t pe, osd_peer_stat_t& ps, bool a=false) :
Message(MSG_OSD_PING), fsid(f), map_epoch(e), peer_as_of_epoch(pe), ack(a), peer_stat(ps) { }
MOSDPing() {}
*/
struct MOSDScrub : public Message {
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
vector<pg_t> scrub_pgs;
bool repair;
MOSDScrub() {}
- MOSDScrub(ceph_fsid& f) :
+ MOSDScrub(ceph_fsid_t& f) :
Message(MSG_OSD_SCRUB),
fsid(f), repair(false) {}
- MOSDScrub(ceph_fsid& f, vector<pg_t>& pgs, bool r) :
+ MOSDScrub(ceph_fsid_t& f, vector<pg_t>& pgs, bool r) :
Message(MSG_OSD_SCRUB),
fsid(f), scrub_pgs(pgs), repair(r) {}
class MPGStats : public Message {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
map<pg_t,pg_stat_t> pg_stat;
osd_stat_t osd_stat;
epoch_t epoch;
utime_t had_map_for;
MPGStats() : Message(MSG_PGSTATS) {}
- MPGStats(ceph_fsid& f, epoch_t e, utime_t had) :
+ MPGStats(ceph_fsid_t& f, epoch_t e, utime_t had) :
Message(MSG_PGSTATS), fsid(f), epoch(e), had_map_for(had) {}
const char *get_type_name() { return "pg_stats"; }
class MStatfs : public Message {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
tid_t tid;
MStatfs() : Message(CEPH_MSG_STATFS) {}
struct ceph_mon_statfs_reply h;
MStatfsReply() : Message(CEPH_MSG_STATFS_REPLY) {}
- MStatfsReply(ceph_fsid &f, tid_t t) : Message(CEPH_MSG_STATFS_REPLY) {
+ MStatfsReply(ceph_fsid_t &f, tid_t t) : Message(CEPH_MSG_STATFS_REPLY) {
h.fsid = f;
h.tid = t;
}
{
dout(10) << "prepare_log " << *m << " from " << m->get_orig_source() << dendl;
- if (!ceph_fsid_equal(&m->fsid, &mon->monmap->fsid)) {
+ if (ceph_fsid_compare(&m->fsid, &mon->monmap->fsid)) {
dout(0) << "handle_log on fsid " << m->fsid << " != " << mon->monmap->fsid << dendl;
delete m;
return false;
version_t seq = m->get_seq();
MDSMap::mds_info_t info;
- if (!ceph_fsid_equal(&m->get_fsid(), &mon->monmap->fsid)) {
+ if (ceph_fsid_compare(&m->get_fsid(), &mon->monmap->fsid)) {
dout(0) << "preprocess_beacon on fsid " << m->get_fsid() << " != " << mon->monmap->fsid << dendl;
goto out;
}
class MonMap {
public:
epoch_t epoch; // what epoch/version of the monmap
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
vector<entity_inst_t> mon_inst;
int last_mon; // last mon i talked to
generate_fsid();
}
- ceph_fsid& get_fsid() { return fsid; }
+ ceph_fsid_t& get_fsid() { return fsid; }
unsigned size() {
return mon_inst.size();
void generate_fsid() {
- fsid.major = ((uint64_t)rand() << 32) + rand();
- fsid.minor = ((uint64_t)rand() << 32) + rand();
+ for (int i=0; i<16; i++)
+ fsid.fsid[i] = rand();
}
// read from/write to a file
void Monitor::handle_command(MMonCommand *m)
{
- if (!ceph_fsid_equal(&m->fsid, &monmap->fsid)) {
+ if (ceph_fsid_compare(&m->fsid, &monmap->fsid)) {
dout(0) << "handle_command on fsid " << m->fsid << " != " << monmap->fsid << dendl;
reply_command(m, -EPERM, "wrong fsid");
return;
<< " start " << m->get_start_epoch()
<< dendl;
- if (!ceph_fsid_equal(&m->fsid, &mon->monmap->fsid)) {
+ if (ceph_fsid_compare(&m->fsid, &mon->monmap->fsid)) {
dout(0) << "handle_osd_getmap on fsid " << m->fsid << " != " << mon->monmap->fsid << dendl;
goto out;
}
// who is failed
int badboy = m->get_failed().name.num();
- if (!ceph_fsid_equal(&m->fsid, &mon->monmap->fsid)) {
+ if (ceph_fsid_compare(&m->fsid, &mon->monmap->fsid)) {
dout(0) << "preprocess_failure on fsid " << m->fsid << " != " << mon->monmap->fsid << dendl;
goto didit;
}
bool OSDMonitor::preprocess_boot(MOSDBoot *m)
{
- if (!ceph_fsid_equal(&m->sb.fsid, &mon->monmap->fsid)) {
+ if (ceph_fsid_compare(&m->sb.fsid, &mon->monmap->fsid)) {
dout(0) << "preprocess_boot on fsid " << m->sb.fsid << " != " << mon->monmap->fsid << dendl;
delete m;
return true;
else if (m->cmd[1] == "setmap") {
OSDMap map;
map.decode(m->get_data());
- if (ceph_fsid_equal(&map.fsid, &mon->monmap->fsid)) {
+ if (ceph_fsid_compare(&map.fsid, &mon->monmap->fsid) == 0) {
map.epoch = pending_inc.epoch; // make sure epoch is correct
map.encode(pending_inc.fullmap);
string rs = "set osd map";
dout(10) << "handle_statfs " << *statfs << " from " << statfs->get_orig_source() << dendl;
- if (!ceph_fsid_equal(&statfs->fsid, &mon->monmap->fsid)) {
+ if (ceph_fsid_compare(&statfs->fsid, &mon->monmap->fsid)) {
dout(0) << "handle_statfs on fsid " << statfs->fsid << " != " << mon->monmap->fsid << dendl;
goto out;
}
dout(10) << "prepare_pg_stats " << *stats << " from " << stats->get_orig_source() << dendl;
int from = stats->get_orig_source().num();
- if (!ceph_fsid_equal(&stats->fsid, &mon->monmap->fsid)) {
+ if (ceph_fsid_compare(&stats->fsid, &mon->monmap->fsid)) {
dout(0) << "handle_statfs on fsid " << stats->fsid << " != " << mon->monmap->fsid << dendl;
delete stats;
return false;
}
-int OSD::mkfs(const char *dev, ceph_fsid fsid, int whoami)
+int OSD::mkfs(const char *dev, ceph_fsid_t fsid, int whoami)
{
ObjectStore *store = create_object_store(dev);
if (!store)
return 0;
}
-int OSD::peek_super(const char *dev, nstring& magic, ceph_fsid& fsid, int& whoami)
+int OSD::peek_super(const char *dev, nstring& magic, ceph_fsid_t& fsid, int& whoami)
{
ObjectStore *store = create_object_store(dev);
if (!store)
dout(10) << "read_superblock " << superblock << dendl;
- if (!ceph_fsid_equal(&superblock.fsid, &monmap->fsid)) {
+ if (ceph_fsid_compare(&superblock.fsid, &monmap->fsid)) {
derr(0) << "read_superblock fsid " << superblock.fsid << " != monmap " << monmap->fsid << dendl;
return -1;
}
return;
}
- if (!ceph_fsid_equal(&superblock.fsid, &m->fsid)) {
+ if (ceph_fsid_compare(&superblock.fsid, &m->fsid)) {
dout(20) << "handle_osd_ping from " << m->get_source()
<< " bad fsid " << m->fsid << " != " << superblock.fsid << dendl;
delete m;
{
dout(10) << "handle_scrub " << *m << dendl;
- if (!ceph_fsid_equal(&m->fsid, &monmap->fsid)) {
+ if (ceph_fsid_compare(&m->fsid, &monmap->fsid)) {
dout(0) << "handle_scrub fsid " << m->fsid << " != " << monmap->fsid << dendl;
delete m;
return;
void OSD::handle_osd_map(MOSDMap *m)
{
assert(osd_lock.is_locked());
- if (!ceph_fsid_equal(&m->fsid, &monmap->fsid)) {
+ if (ceph_fsid_compare(&m->fsid, &monmap->fsid)) {
dout(0) << "handle_osd_map fsid " << m->fsid << " != " << monmap->fsid << dendl;
delete m;
return;
// static bits
static int find_osd_dev(char *result, int whoami);
static ObjectStore *create_object_store(const char *dev);
- static int mkfs(const char *dev, ceph_fsid fsid, int whoami);
- static int peek_super(const char *dev, nstring& magic, ceph_fsid& fsid, int& whoami);
+ static int mkfs(const char *dev, ceph_fsid_t fsid, int whoami);
+ static int peek_super(const char *dev, nstring& magic, ceph_fsid_t& fsid, int& whoami);
// startup/shutdown
int init();
}
-void OSDMap::build_simple(epoch_t e, ceph_fsid &fsid,
+void OSDMap::build_simple(epoch_t e, ceph_fsid_t &fsid,
int num_osd, int num_dom, int pg_bits, int lpg_bits,
int mds_local_osd)
{
public:
class Incremental {
public:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
epoch_t epoch; // new epoch; we are a diff from epoch-1 to epoch
utime_t ctime;
int32_t new_flags;
Incremental(epoch_t e=0) : epoch(e), new_flags(-1), new_max_osd(-1),
new_pg_num(0), new_pgp_num(0), new_lpg_num(0), new_lpgp_num(0) {
- fsid.major = fsid.minor = 0;
+ memset(&fsid, 0, sizeof(fsid));
}
Incremental(bufferlist &bl) {
bufferlist::iterator p = bl.begin();
};
private:
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
epoch_t epoch; // what epoch of the osd cluster descriptor is this
utime_t ctime, mtime; // epoch start time
last_pg_change(0),
flags(0),
max_osd(0), max_snap(0) {
- fsid.major = fsid.minor = 0;
+ memset(&fsid, 0, sizeof(fsid));
calc_pg_masks();
}
// map info
- ceph_fsid& get_fsid() { return fsid; }
- void set_fsid(ceph_fsid& f) { fsid = f; }
+ ceph_fsid_t& get_fsid() { return fsid; }
+ void set_fsid(ceph_fsid_t& f) { fsid = f; }
epoch_t get_epoch() const { return epoch; }
void inc_epoch() { epoch++; }
if (inc.epoch == 1)
fsid = inc.fsid;
else
- assert(ceph_fsid_equal(&inc.fsid, &fsid));
+ assert(ceph_fsid_compare(&inc.fsid, &fsid) == 0);
assert(inc.epoch == epoch+1);
epoch++;
ctime = inc.ctime;
/*
* handy helpers to build simple maps...
*/
- void build_simple(epoch_t e, ceph_fsid &fsid,
+ void build_simple(epoch_t e, ceph_fsid_t &fsid,
int num_osd, int num_dom,
int pg_bits, int lpg_bits,
int mds_local_osd);
class OSDSuperblock {
public:
nstring magic;
- ceph_fsid fsid;
+ ceph_fsid_t fsid;
int32_t whoami; // my role in this fs.
epoch_t current_epoch; // most recent epoch
epoch_t oldest_map, newest_map; // oldest/newest maps we have.
{
assert(osdmap);
- if (!ceph_fsid_equal(&m->fsid, &monmap->fsid)) {
+ if (ceph_fsid_compare(&m->fsid, &monmap->fsid)) {
dout(0) << "handle_osd_map fsid " << m->fsid << " != " << monmap->fsid << dendl;
delete m;
return;