Merge branch 'unstable' into asyncmds

Conflicts:

	src/mon/OSDMonitor.cc
This commit is contained in:
Sage Weil 2008-12-31 11:30:08 -08:00
commit a58d31ca46
45 changed files with 192 additions and 142 deletions

View File

@ -22,7 +22,6 @@ big items
- client, user authentication
- cas
- osd failure declarations
- libuuid?
repair

View File

@ -99,7 +99,7 @@ int main(int argc, const char **argv)
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;
@ -109,7 +109,7 @@ int main(int argc, const char **argv)
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);
}

View File

@ -2493,6 +2493,11 @@ unsigned Ebofs::_apply_transaction(Transaction& t)
int op = t.get_op();
switch (op) {
case Transaction::OP_STARTSYNC:
dirty = true;
commit_cond.Signal();
break;
case Transaction::OP_TOUCH:
{
coll_t cid = t.get_cid();

View File

@ -61,19 +61,15 @@ typedef __le64 ceph_version_t;
typedef __le64 ceph_tid_t; /* transaction id */
typedef __le32 ceph_epoch_t;
/*
* 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));
}
@ -541,7 +537,7 @@ struct ceph_msg_footer {
struct ceph_mon_statfs {
struct ceph_fsid fsid;
ceph_fsid_t fsid;
__le64 tid;
};
@ -553,18 +549,18 @@ struct ceph_statfs {
};
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));
@ -1115,6 +1111,7 @@ enum {
/* fancy write */
CEPH_OSD_OP_APPEND = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 6,
CEPH_OSD_OP_STARTSYNC = CEPH_OSD_OP_MODE_WR | CEPH_OSD_OP_TYPE_DATA | 7,
};
static inline int ceph_osd_op_type_lock(int op)

View File

@ -197,7 +197,7 @@ struct ltstr
#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)
@ -370,8 +370,12 @@ inline ostream& operator<<(ostream& out, const SnapContext& snapc) {
// --
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) {

View File

@ -2199,9 +2199,10 @@ void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
void *p = msg->front.iov_base;
void *end = p + msg->front.iov_len;
struct ceph_mdsmap *newmap, *oldmap;
struct ceph_fsid fsid;
ceph_fsid_t fsid;
int err = -EINVAL;
int from;
__le64 major, minor;
if (le32_to_cpu(msg->hdr.src.name.type) == CEPH_ENTITY_TYPE_MDS)
from = le32_to_cpu(msg->hdr.src.name.num);
@ -2209,9 +2210,11 @@ void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
from = -1;
ceph_decode_need(&p, end, sizeof(fsid)+2*sizeof(u32), bad);
ceph_decode_64_le(&p, fsid.major);
ceph_decode_64_le(&p, fsid.minor);
if (!ceph_fsid_equal(&fsid, &mdsc->client->monc.monmap->fsid)) {
ceph_decode_64_le(&p, major);
__ceph_fsid_set_major(&fsid, major);
ceph_decode_64_le(&p, minor);
__ceph_fsid_set_minor(&fsid, minor);
if (ceph_fsid_compare(&fsid, &mdsc->client->monc.monmap->fsid)) {
derr(0, "got mdsmap with wrong fsid\n");
return;
}

View File

@ -19,6 +19,7 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
{
struct ceph_monmap *m;
int i, err = -EINVAL;
__le64 major, minor;
dout(30, "monmap_decode %p %p len %d\n", p, end, (int)(end-p));
@ -28,8 +29,10 @@ struct ceph_monmap *ceph_monmap_decode(void *p, void *end)
return ERR_PTR(-ENOMEM);
ceph_decode_need(&p, end, 2*sizeof(u32) + 2*sizeof(u64), bad);
ceph_decode_64_le(&p, m->fsid.major);
ceph_decode_64_le(&p, m->fsid.minor);
ceph_decode_64_le(&p, major);
__ceph_fsid_set_major(&m->fsid, major);
ceph_decode_64_le(&p, minor);
__ceph_fsid_set_minor(&m->fsid, minor);
ceph_decode_32(&p, m->epoch);
ceph_decode_32(&p, m->num_mon);
ceph_decode_need(&p, end, m->num_mon*sizeof(m->mon_inst[0]), bad);

View File

@ -29,7 +29,7 @@ struct ceph_mount_args;
* ceph_monmap_decode().
*/
struct ceph_monmap {
struct ceph_fsid fsid;
ceph_fsid_t fsid;
u32 epoch;
u32 num_mon;
struct ceph_entity_inst mon_inst[0];

View File

@ -442,7 +442,8 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg)
u32 epoch;
struct ceph_osdmap *newmap = NULL, *oldmap;
int err;
struct ceph_fsid fsid;
ceph_fsid_t fsid;
__le64 major, minor;
dout(2, "handle_map have %u\n", osdc->osdmap ? osdc->osdmap->epoch : 0);
p = msg->front.iov_base;
@ -450,9 +451,11 @@ void ceph_osdc_handle_map(struct ceph_osd_client *osdc, struct ceph_msg *msg)
/* verify fsid */
ceph_decode_need(&p, end, sizeof(fsid), bad);
ceph_decode_64_le(&p, fsid.major);
ceph_decode_64_le(&p, fsid.minor);
if (!ceph_fsid_equal(&fsid, &osdc->client->monc.monmap->fsid)) {
ceph_decode_64_le(&p, major);
__ceph_fsid_set_major(&fsid, major);
ceph_decode_64_le(&p, minor);
__ceph_fsid_set_minor(&fsid, minor);
if (ceph_fsid_compare(&fsid, &osdc->client->monc.monmap->fsid)) {
derr(0, "got map with wrong fsid, ignoring\n");
return;
}

View File

@ -341,6 +341,7 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
u32 len, max, i;
int err = -EINVAL;
void *start = *p;
__le64 major, minor;
dout(30, "osdmap_decode %p to %p len %d\n", *p, end, (int)(end - *p));
@ -349,8 +350,10 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
return ERR_PTR(-ENOMEM);
ceph_decode_need(p, end, 2*sizeof(u64)+11*sizeof(u32), bad);
ceph_decode_64_le(p, map->fsid.major);
ceph_decode_64_le(p, map->fsid.minor);
ceph_decode_64_le(p, major);
__ceph_fsid_set_major(&map->fsid, major);
ceph_decode_64_le(p, minor);
__ceph_fsid_set_minor(&map->fsid, minor);
ceph_decode_32(p, map->epoch);
ceph_decode_32_le(p, map->ctime.tv_sec);
ceph_decode_32_le(p, map->ctime.tv_nsec);
@ -422,18 +425,21 @@ struct ceph_osdmap *apply_incremental(void **p, void *end,
{
struct ceph_osdmap *newmap = map;
struct crush_map *newcrush = NULL;
struct ceph_fsid fsid;
ceph_fsid_t fsid;
u32 epoch = 0;
struct ceph_timespec ctime;
u32 len, x;
__s32 new_flags, max;
void *start = *p;
int err = -EINVAL;
__le64 major, minor;
ceph_decode_need(p, end, sizeof(fsid)+sizeof(ctime)+2*sizeof(u32),
bad);
ceph_decode_64_le(p, fsid.major);
ceph_decode_64_le(p, fsid.minor);
ceph_decode_64_le(p, major);
__ceph_fsid_set_major(&fsid, major);
ceph_decode_64_le(p, minor);
__ceph_fsid_set_minor(&fsid, minor);
ceph_decode_32(p, epoch);
BUG_ON(epoch != map->epoch+1);
ceph_decode_32_le(p, ctime.tv_sec);

View File

@ -2,6 +2,7 @@
#define _FS_CEPH_OSDMAP_H
#include "types.h"
#include "ceph_fs.h"
#include "crush/crush.h"
/*
@ -17,7 +18,7 @@
* the change between two successive epochs, or as a fully encoded map.
*/
struct ceph_osdmap {
struct ceph_fsid fsid;
ceph_fsid_t fsid;
u32 epoch;
u32 mkfs_epoch;
struct ceph_timespec ctime, mtime;

View File

@ -105,7 +105,7 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
buf->f_frsize = PAGE_CACHE_SIZE;
/* leave in little-endian, regardless of host endianness */
fsid = monmap->fsid.major ^ monmap->fsid.minor;
fsid = __ceph_fsid_major(&monmap->fsid) ^ __ceph_fsid_minor(&monmap->fsid);
buf->f_fsid.val[0] = le64_to_cpu(fsid) & 0xffffffff;
buf->f_fsid.val[1] = le64_to_cpu(fsid) >> 32;
@ -134,7 +134,7 @@ static int ceph_show_options(struct seq_file *m, struct vfsmount *mnt)
seq_printf(m, ",debug=%d", ceph_debug);
if (args->flags & CEPH_MOUNT_FSID)
seq_printf(m, ",fsidmajor=%llu,fsidminor%llu",
args->fsid.major, args->fsid.minor);
__ceph_fsid_major(&args->fsid), __ceph_fsid_minor(&args->fsid));
if (args->flags & CEPH_MOUNT_NOSHARE)
seq_puts(m, ",noshare");
if (args->flags & CEPH_MOUNT_UNSAFE_WRITEBACK)
@ -252,8 +252,8 @@ static void handle_monmap(struct ceph_client *client, struct ceph_msg *msg)
client->msgr->inst.name = msg->hdr.dst.name;
sprintf(name, "client%d", client->whoami);
dout(1, "i am %s, fsid is %llx.%llx\n", name,
le64_to_cpu(client->monc.monmap->fsid.major),
le64_to_cpu(client->monc.monmap->fsid.minor));
le64_to_cpu(__ceph_fsid_major(&client->monc.monmap->fsid)),
le64_to_cpu(__ceph_fsid_minor(&client->monc.monmap->fsid)));
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
client->client_kobj = kobject_create_and_add(name, ceph_kobj);
@ -523,10 +523,10 @@ static int parse_mount_args(int flags, char *options, const char *dev_name,
}
switch (token) {
case Opt_fsidmajor:
args->fsid.major = cpu_to_le64(intval);
__ceph_fsid_set_major(&args->fsid, cpu_to_le64(intval));
break;
case Opt_fsidminor:
args->fsid.minor = cpu_to_le64(intval);
__ceph_fsid_set_minor(&args->fsid, cpu_to_le64(intval));
break;
case Opt_port:
args->my_addr.ipaddr.sin_port = htons(intval);
@ -953,7 +953,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
/* either compare fsid, or specified mon_hostname */
if (args->flags & CEPH_MOUNT_FSID) {
if (!ceph_fsid_equal(&args->fsid, &other->fsid)) {
if (ceph_fsid_compare(&args->fsid, &other->fsid)) {
dout(30, "fsid doesn't match\n");
return 0;
}

View File

@ -16,6 +16,7 @@
#include "mon_client.h"
#include "mds_client.h"
#include "osd_client.h"
#include "ceph_fs.h"
/* f_type in struct statfs */
#define CEPH_SUPER_MAGIC 0x00c36400
@ -57,7 +58,7 @@ struct ceph_mount_args {
int sb_flags;
int flags;
int mount_timeout;
struct ceph_fsid fsid;
ceph_fsid_t fsid;
struct ceph_entity_addr my_addr;
int num_mon;
struct ceph_entity_addr mon_addr[MAX_MON_MOUNT_ADDR];
@ -89,7 +90,7 @@ struct ceph_client {
struct mutex mount_mutex; /* serialize mount attempts */
struct ceph_mount_args mount_args;
struct ceph_fsid fsid;
ceph_fsid_t fsid;
struct super_block *sb;
@ -573,6 +574,26 @@ static inline bool __ceph_have_pending_cap_snap(struct ceph_inode_info *ci)
/* super.c */
extern const char *ceph_msg_type_name(int type);
static inline __le64 __ceph_fsid_minor(ceph_fsid_t *fsid)
{
return *(__le64 *)&fsid->fsid[8];
}
static inline __le64 __ceph_fsid_major(ceph_fsid_t *fsid)
{
return *(__le64 *)&fsid->fsid[0];
}
static inline void __ceph_fsid_set_minor(ceph_fsid_t *fsid, __le64 val)
{
*(__le64 *)&fsid->fsid[8] = val;
}
static inline void __ceph_fsid_set_major(ceph_fsid_t *fsid, __le64 val)
{
*(__le64 *)&fsid->fsid[0] = val;
}
/* inode.c */
extern const struct inode_operations ceph_file_iops;
extern struct kmem_cache *ceph_inode_cachep;

View File

@ -19,14 +19,14 @@
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"; }

View File

@ -22,7 +22,7 @@
#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;
@ -30,11 +30,11 @@ class MMDSBeacon : public Message {
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; }

View File

@ -21,11 +21,11 @@
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) { }

View File

@ -45,7 +45,7 @@ class MMDSMap : public Message {
}
*/
ceph_fsid fsid;
ceph_fsid_t fsid;
epoch_t epoch;
bufferlist encoded;
@ -54,7 +54,7 @@ class MMDSMap : public Message {
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();

View File

@ -22,11 +22,11 @@ using std::vector;
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) { }

View File

@ -22,12 +22,12 @@ using std::vector;
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) { }

View File

@ -21,12 +21,12 @@
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) {}

View File

@ -21,11 +21,11 @@
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) { }

View File

@ -22,7 +22,7 @@
class MOSDMap : public Message {
public:
ceph_fsid fsid;
ceph_fsid_t fsid;
map<epoch_t, bufferlist> maps;
map<epoch_t, bufferlist> incremental_maps;
@ -47,7 +47,7 @@ class MOSDMap : public Message {
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()]);

View File

@ -23,12 +23,12 @@
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() {}

View File

@ -23,15 +23,15 @@
*/
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) {}

View File

@ -19,14 +19,14 @@
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"; }

View File

@ -20,7 +20,7 @@
class MStatfs : public Message {
public:
ceph_fsid fsid;
ceph_fsid_t fsid;
tid_t tid;
MStatfs() : Message(CEPH_MSG_STATFS) {}

View File

@ -21,7 +21,7 @@ public:
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;
}

View File

@ -211,7 +211,7 @@ bool LogMonitor::prepare_log(MLog *m)
{
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;

View File

@ -159,7 +159,7 @@ bool MDSMonitor::preprocess_beacon(MMDSBeacon *m)
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;
}

View File

@ -24,7 +24,7 @@
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
@ -33,7 +33,7 @@ class MonMap {
generate_fsid();
}
ceph_fsid& get_fsid() { return fsid; }
ceph_fsid_t& get_fsid() { return fsid; }
unsigned size() {
return mon_inst.size();
@ -99,8 +99,8 @@ class MonMap {
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

View File

@ -198,7 +198,7 @@ void Monitor::lose_election(epoch_t epoch, set<int> &q, int l)
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;

View File

@ -340,7 +340,7 @@ void OSDMonitor::handle_osd_getmap(MOSDGetMap *m)
<< " 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;
}
@ -369,7 +369,7 @@ bool OSDMonitor::preprocess_failure(MOSDFailure *m)
// 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;
}
@ -457,7 +457,7 @@ void OSDMonitor::_reported_failure(MOSDFailure *m)
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;
@ -975,7 +975,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
OSDMap map;
map.decode(m->get_data());
epoch_t e = atoi(m->cmd[2].c_str());
if (ceph_fsid_equal(&map.fsid, &mon->monmap->fsid)) {
if (ceph_fsid_compare(&map.fsid, &mon->monmap->fsid) == 0) {
if (pending_inc.epoch == e) {
map.epoch = pending_inc.epoch; // make sure epoch is correct
map.encode(pending_inc.fullmap);

View File

@ -203,7 +203,7 @@ void PGMonitor::handle_statfs(MStatfs *statfs)
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;
}
@ -261,7 +261,7 @@ bool PGMonitor::prepare_pg_stats(MPGStats *stats)
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;

View File

@ -694,6 +694,10 @@ unsigned FileStore::_apply_transaction(Transaction& t)
_collection_rmattr(t.get_cid(), t.get_attrname());
break;
case Transaction::OP_STARTSYNC:
_start_sync();
break;
default:
cerr << "bad op " << op << std::endl;
assert(0);
@ -1431,6 +1435,12 @@ void FileStore::sync_entry()
lock.Unlock();
}
void FileStore::_start_sync()
{
dout(10) << "start_sync" << dendl;
sync_cond.Signal();
}
void FileStore::sync()
{
Mutex::Locker l(lock);

View File

@ -115,6 +115,8 @@ class FileStore : public JournalingObjectStore {
int _do_clone_range(int from, int to, __u64 off, __u64 len);
int _remove(coll_t cid, pobject_t oid);
void _start_sync();
void sync();
void sync(Context *onsafe);

View File

@ -98,6 +98,9 @@ public:
static const int OP_COLL_RMATTR = 25; // cid, attrname
static const int OP_COLL_SETATTRS = 26; // cid, attrset
static const int OP_STARTSYNC = 27; // start a sync
private:
/*
int len;
@ -158,6 +161,10 @@ public:
return attrsets[attrsetp++];
}
void start_sync() {
int op = OP_STARTSYNC;
ops.push_back(op);
}
void touch(coll_t cid, pobject_t oid) {
int op = OP_TOUCH;
ops.push_back(op);

View File

@ -149,7 +149,7 @@ ObjectStore *OSD::create_object_store(const char *dev)
}
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)
@ -217,7 +217,7 @@ int OSD::mkfs(const char *dev, ceph_fsid fsid, int whoami)
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)
@ -561,7 +561,7 @@ int OSD::read_superblock()
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;
}
@ -982,7 +982,7 @@ void OSD::handle_osd_ping(MOSDPing *m)
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;
@ -1633,7 +1633,7 @@ void OSD::handle_scrub(MOSDScrub *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;
@ -1724,7 +1724,7 @@ void OSD::note_up_osd(int osd)
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;
@ -2098,8 +2098,7 @@ void OSD::advance_map(ObjectStore::Transaction& t, interval_set<snapid_t>& remov
pg->on_role_change();
// interrupt backlog generation
pg->generate_backlog_epoch = 0;
backlog_wq.dequeue(pg);
cancel_generate_backlog(pg);
// take active waiters
take_waiters(pg->waiting_for_active);
@ -3130,6 +3129,13 @@ void OSD::queue_generate_backlog(PG *pg)
}
}
void OSD::cancel_generate_backlog(PG *pg)
{
dout(10) << *pg << " cancel_generate_backlog" << dendl;
pg->generate_backlog_epoch = 0;
backlog_wq.dequeue(pg);
}
void OSD::generate_backlog(PG *pg)
{
pg->lock();

View File

@ -539,6 +539,7 @@ private:
} backlog_wq;
void queue_generate_backlog(PG *pg);
void cancel_generate_backlog(PG *pg);
void generate_backlog(PG *pg);
@ -693,8 +694,8 @@ private:
// 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();

View File

@ -74,7 +74,7 @@ void OSDMap::print_summary(ostream& out)
}
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)
{

View File

@ -132,7 +132,7 @@ class OSDMap {
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;
@ -227,7 +227,7 @@ public:
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();
@ -239,7 +239,7 @@ public:
};
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
@ -294,13 +294,13 @@ private:
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++; }
@ -484,7 +484,7 @@ private:
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;
@ -899,7 +899,7 @@ private:
/*
* 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);

View File

@ -341,7 +341,7 @@ void PG::merge_log(ObjectStore::Transaction& t,
list<Log::Entry>::iterator p = log.log.end();
while (p != log.log.begin()) {
p--;
if (p->version <= log.top) {
if (p->version.version <= log.top.version) {
dout(10) << "merge_log split point is " << *p << dendl;
if (p->version < log.top && p->version < oldest_update) {
@ -371,9 +371,8 @@ void PG::merge_log(ObjectStore::Transaction& t,
p++) {
Log::Entry &oe = *p; // old entry
if (old_objects.count(oe.oid) &&
old_objects[oe.oid] == &oe) {
old_objects[oe.oid] == &oe)
merge_old_entry(t, oe);
}
}
info.last_update = log.top = olog.top;
@ -1179,7 +1178,6 @@ void PG::peer(ObjectStore::Transaction& t,
// let's pull info+logs from _everyone_ (strays included, this
// time) in search of missing objects.
bool waiting = false;
for (map<int,Info>::iterator it = peer_info.begin();
it != peer_info.end();
it++) {
@ -1190,19 +1188,17 @@ void PG::peer(ObjectStore::Transaction& t,
if (peer_summary_requested.count(peer)) {
dout(10) << " already requested summary/backlog from osd" << peer << dendl;
waiting = true;
continue;
}
dout(10) << " requesting summary/backlog from osd" << peer << dendl;
query_map[peer][info.pgid] = Query(Query::BACKLOG, info.history);
peer_summary_requested.insert(peer);
waiting = true;
return;
}
if (!waiting)
dout(10) << (missing.num_missing() - missing_loc.size())
<< " objects are still lost, waiting+hoping for a notify from someone else!" << dendl;
dout(10) << (missing.num_missing() - missing_loc.size())
<< " objects are still lost, waiting+hoping for a notify from someone else!" << dendl;
return;
}
@ -1282,6 +1278,9 @@ void PG::activate(ObjectStore::Transaction& t,
// clear prior set (and dependency info)... we are done peering!
clear_prior();
// if we are building a backlog, cancel it!
osd->cancel_generate_backlog(this);
// write pg info, log
write_info(t);
write_log(t);
@ -1782,7 +1781,9 @@ void PG::read_log(ObjectStore *store)
pobject_t poid(info.pgid.pool(), 0, i->oid);
bufferlist bv;
int r = osd->store->getattr(info.pgid.to_coll(), poid, "version", bv);
eversion_t v(bv);
eversion_t v;
if (r >= 0)
v = eversion_t(bv);
if (r < 0 || v < i->version) {
dout(15) << "read_log missing " << *i << dendl;
missing.add(i->oid, i->version, v);

View File

@ -1131,6 +1131,9 @@ int ReplicatedPG::prepare_simple_op(ObjectStore::Transaction& t, osd_reqid_t req
}
break;
case CEPH_OSD_OP_STARTSYNC:
t.start_sync();
break;
default:
return -EINVAL;
@ -2584,30 +2587,8 @@ void ReplicatedPG::on_change()
}
}
// remove strays from pushing map
{
map<object_t, set<int> >::iterator p = pushing.begin();
while (p != pushing.end()) {
set<int>::iterator q = p->second.begin();
while (q != p->second.end()) {
int o = *q++;
bool have = false;
for (unsigned i=1; i<acting.size(); i++)
if (acting[i] == o) {
have = true;
break;
}
if (!have) {
dout(10) << " forgetting push of " << p->first << " to (now stray) osd" << o << dendl;
p->second.erase(o);
}
}
if (p->second.empty())
pushing.erase(p++);
else
p++;
}
}
// clear pushing map
pushing.clear();
}
void ReplicatedPG::on_role_change()

View File

@ -614,7 +614,7 @@ struct ObjectMutation {
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.

View File

@ -72,7 +72,7 @@ void Objecter::handle_osd_map(MOSDMap *m)
{
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;

View File

@ -91,7 +91,7 @@ fi
# lockdep everywhere?
export CEPH_ARGS="--lockdep 1"
# export CEPH_ARGS="--lockdep 1"
# sudo if btrfs