From: Sage Weil Date: Mon, 24 Mar 2008 17:19:48 +0000 (-0700) Subject: osd: le notation in osd op structs X-Git-Tag: v0.2~229^2^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3ab32f102840969f9de9546db9d20955c6787bbe;p=ceph.git osd: le notation in osd op structs --- diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index 31ca6dec552..3ecf46736c2 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -1730,7 +1730,7 @@ int SyntheticClient::overload_osd_0(int n, int size, int wrsize) { int SyntheticClient::check_first_primary(int fh) { list extents; client->enumerate_layout(fh, extents, 1, 0); - return client->osdmap->get_pg_primary((extents.begin())->layout.ol_pgid); + return client->osdmap->get_pg_primary(pg_t(le64_to_cpu((extents.begin())->layout.ol_pgid))); } int SyntheticClient::write_file(string& fn, int size, int wrsize) // size is in MB, wrsize in bytes diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index c67773d3399..21403b582bb 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -152,8 +152,8 @@ static inline int ceph_stable_mod(int x, int b, int bmask) { * object layout - how a given object should be stored. */ struct ceph_object_layout { - union ceph_pg ol_pgid; - __u32 ol_stripe_unit; + __le64 ol_pgid; + __le32 ol_stripe_unit; } __attribute__ ((packed)); /* @@ -529,14 +529,15 @@ struct ceph_osd_peer_stat { struct ceph_osd_request_head { struct ceph_entity_inst client_inst; ceph_tid_t tid; - __u32 client_inc; - __u32 op; - __u64 offset, length; + __le32 client_inc; + __le32 op; + __le64 offset, length; struct ceph_object oid; struct ceph_object_layout layout; ceph_epoch_t osdmap_epoch; - __u32 flags; + __le32 flags; + __le32 inc_lock; struct ceph_eversion reassert_version; @@ -547,13 +548,13 @@ struct ceph_osd_request_head { struct ceph_osd_reply_head { ceph_tid_t tid; - __u32 op; - __u32 flags; + __le32 op; + __le32 flags; struct ceph_object oid; struct ceph_object_layout layout; ceph_epoch_t osdmap_epoch; - __s32 result; - __u64 offset, length; + __le32 result; + __le64 offset, length; struct ceph_eversion reassert_version; } __attribute__ ((packed)); diff --git a/src/kernel/mdsmap.c b/src/kernel/mdsmap.c index 7402ee27e71..690da8789fb 100644 --- a/src/kernel/mdsmap.c +++ b/src/kernel/mdsmap.c @@ -65,6 +65,7 @@ struct ceph_mdsmap *ceph_mdsmap_decode(void **p, void *end) ceph_decode_need(p, end, 10*sizeof(__u32), bad); ceph_decode_32(p, m->m_epoch); ceph_decode_32(p, m->m_client_epoch); + ceph_decode_32(p, m->m_last_failure); ceph_decode_32(p, m->m_created.tv_sec); ceph_decode_32(p, m->m_created.tv_usec); ceph_decode_32(p, m->m_anchortable); diff --git a/src/kernel/mdsmap.h b/src/kernel/mdsmap.h index 9e414f845d5..6c879d91058 100644 --- a/src/kernel/mdsmap.h +++ b/src/kernel/mdsmap.h @@ -9,7 +9,7 @@ * fields limited to those the client cares about */ struct ceph_mdsmap { - ceph_epoch_t m_epoch, m_client_epoch; + ceph_epoch_t m_epoch, m_client_epoch, m_last_failure; struct ceph_timeval m_created; __u32 m_anchortable; __u32 m_root; diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index d8d9af145e5..6a18667888a 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -101,6 +101,7 @@ class MDSMap { protected: epoch_t epoch; epoch_t client_epoch; // incremented only when change is significant to client. + epoch_t last_failure; // epoch of last failure. for inclocks utime_t created; int32_t max_mds; @@ -343,6 +344,7 @@ class MDSMap { void encode(bufferlist& bl) { ::_encode(epoch, bl); ::_encode(client_epoch, bl); + ::_encode(last_failure, bl); ::_encode(created, bl); ::_encode(anchortable, bl); ::_encode(root, bl); @@ -362,6 +364,7 @@ class MDSMap { int off = 0; ::_decode(epoch, bl, off); ::_decode(client_epoch, bl, off); + ::_decode(last_failure, bl, off); ::_decode(created, bl, off); ::_decode(anchortable, bl, off); ::_decode(root, bl, off); diff --git a/src/messages/MOSDOp.h b/src/messages/MOSDOp.h index 57828abdd60..79a92d00138 100644 --- a/src/messages/MOSDOp.h +++ b/src/messages/MOSDOp.h @@ -66,9 +66,9 @@ private: public: osd_reqid_t get_reqid() { return osd_reqid_t(head.client_inst.name, - head.client_inc, + le32_to_cpu(head.client_inc), le64_to_cpu(head.tid)); } - int get_client_inc() { return head.client_inc; } + int get_client_inc() { return le32_to_cpu(head.client_inc); } tid_t get_client_tid() { return le64_to_cpu(head.tid); } entity_name_t get_client() { return head.client_inst.name; } @@ -76,20 +76,20 @@ public: void set_client_addr(const entity_addr_t& a) { head.client_inst.addr = a; } object_t get_oid() { return object_t(head.oid); } - pg_t get_pg() { return head.layout.ol_pgid; } + pg_t get_pg() { return pg_t(le64_to_cpu(head.layout.ol_pgid)); } ceph_object_layout get_layout() { return head.layout; } epoch_t get_map_epoch() { return le32_to_cpu(head.osdmap_epoch); } eversion_t get_version() { return head.reassert_version; } - const int get_op() { return head.op; } - void set_op(int o) { head.op = o; } + const int get_op() { return le32_to_cpu(head.op); } + void set_op(int o) { head.op = cpu_to_le32(o); } bool is_read() { - return head.op < 10; + return get_op() < 10; } - const off_t get_length() { return head.length; } - const off_t get_offset() { return head.offset; } + off_t get_length() const { return le64_to_cpu(head.length); } + off_t get_offset() const { return le64_to_cpu(head.offset); } void set_peer_stat(const osd_peer_stat_t& stat) { head.peer_stat = stat; } const ceph_osd_peer_stat& get_peer_stat() { return head.peer_stat; } @@ -107,28 +107,33 @@ public: head.client_inst.name = asker.name; head.client_inst.addr = asker.addr; head.tid = cpu_to_le64(tid); - head.client_inc = inc; + head.client_inc = cpu_to_le32(inc); head.oid = oid; head.layout = ol; head.osdmap_epoch = cpu_to_le32(mapepoch); - head.op = op; - head.flags = flags; + head.op = cpu_to_le32(op); + head.flags = cpu_to_le32(flags); } MOSDOp() {} + void set_inc_lock(__u32 l) { + head.inc_lock = cpu_to_le32(l); + } + void set_layout(const ceph_object_layout& l) { head.layout = l; } - void set_length(off_t l) { head.length = l; } - void set_offset(off_t o) { head.offset = o; } + void set_length(off_t l) { head.length = cpu_to_le64(l); } + void set_offset(off_t o) { head.offset = cpu_to_le64(o); } void set_version(eversion_t v) { head.reassert_version = v; } - bool wants_ack() { return head.flags & CEPH_OSD_OP_ACK; } - bool wants_commit() { return head.flags & CEPH_OSD_OP_SAFE; } - bool is_retry_attempt() const { return head.flags & CEPH_OSD_OP_RETRY; } + int get_flags() const { return le32_to_cpu(head.flags); } + bool wants_ack() const { return get_flags() & CEPH_OSD_OP_ACK; } + bool wants_commit() const { return get_flags() & CEPH_OSD_OP_SAFE; } + bool is_retry_attempt() const { return get_flags() & CEPH_OSD_OP_RETRY; } - void set_want_ack(bool b) { head.flags |= CEPH_OSD_OP_ACK; } - void set_want_commit(bool b) { head.flags |= CEPH_OSD_OP_SAFE; } - void set_retry_attempt(bool a) { head.flags |= CEPH_OSD_OP_RETRY; } + void set_want_ack(bool b) { head.flags = cpu_to_le32(get_flags() | CEPH_OSD_OP_ACK); } + void set_want_commit(bool b) { head.flags = cpu_to_le32(get_flags() | CEPH_OSD_OP_SAFE); } + void set_retry_attempt(bool a) { head.flags = cpu_to_le32(get_flags() | CEPH_OSD_OP_RETRY); } // marshalling virtual void decode_payload() { @@ -138,15 +143,15 @@ public: virtual void encode_payload() { ::_encode(head, payload); - env.data_off = cpu_to_le32(head.offset); + env.data_off = cpu_to_le32(get_offset()); } const char *get_type_name() { return "osd_op"; } void print(ostream& out) { out << "osd_op(" << get_reqid() - << " " << get_opname(head.op) + << " " << get_opname(get_op()) << " " << head.oid; - if (head.length) out << " " << head.offset << "~" << head.length; + if (get_length()) out << " " << get_offset() << "~" << get_length(); if (is_retry_attempt()) out << " RETRY"; out << ")"; } diff --git a/src/messages/MOSDOpReply.h b/src/messages/MOSDOpReply.h index 9b85b80bf87..262ea842b04 100644 --- a/src/messages/MOSDOpReply.h +++ b/src/messages/MOSDOpReply.h @@ -35,37 +35,38 @@ class MOSDOpReply : public Message { public: long get_tid() { return le64_to_cpu(head.tid); } object_t get_oid() { return head.oid; } - pg_t get_pg() { return head.layout.ol_pgid; } - int get_op() { return head.op; } - bool is_safe() { return head.flags & CEPH_OSD_OP_SAFE; } + pg_t get_pg() { return pg_t(le64_to_cpu(head.layout.ol_pgid)); } + int get_op() { return le32_to_cpu(head.op); } + int get_flags() { return le32_to_cpu(head.flags); } + bool is_safe() { return get_flags() & CEPH_OSD_OP_SAFE; } - int get_result() { return head.result; } - off_t get_length() { return head.length; } - off_t get_offset() { return head.offset; } + __s32 get_result() { return le32_to_cpu(head.result); } + __u64 get_length() { return le64_to_cpu(head.length); } + __u64 get_offset() { return le64_to_cpu(head.offset); } eversion_t get_version() { return head.reassert_version; } - void set_result(int r) { head.result = r; } - void set_length(off_t s) { head.length = s; } - void set_offset(off_t o) { head.offset = o; } + void set_result(int r) { head.result = cpu_to_le32(r); } + void set_length(off_t s) { head.length = cpu_to_le64(s); } + void set_offset(off_t o) { head.offset = cpu_to_le64(o); } void set_version(eversion_t v) { head.reassert_version = v; } - void set_op(int op) { head.op = op; } + void set_op(int op) { head.op = cpu_to_le32(op); } // osdmap epoch_t get_map_epoch() { return le32_to_cpu(head.osdmap_epoch); } public: - MOSDOpReply(MOSDOp *req, int result, epoch_t e, bool commit) : + MOSDOpReply(MOSDOp *req, __s32 result, epoch_t e, bool commit) : Message(CEPH_MSG_OSD_OPREPLY) { memset(&head, 0, sizeof(head)); head.tid = req->head.tid; head.op = req->head.op; - head.flags = commit ? CEPH_OSD_OP_SAFE:0; + head.flags = cpu_to_le32(commit ? CEPH_OSD_OP_SAFE:0); head.oid = req->head.oid; head.layout = req->head.layout; head.osdmap_epoch = cpu_to_le32(e); - head.result = result; + head.result = cpu_to_le32(result); head.offset = req->head.offset; head.length = req->head.length; // speculative... OSD should ensure these are correct head.reassert_version = req->head.reassert_version; @@ -80,23 +81,23 @@ public: } virtual void encode_payload() { ::_encode(head, payload); - env.data_off = cpu_to_le32(head.offset); + env.data_off = cpu_to_le32(get_offset()); } const char *get_type_name() { return "osd_op_reply"; } void print(ostream& out) { out << "osd_op_reply(" << get_tid() - << " " << MOSDOp::get_opname(head.op) + << " " << MOSDOp::get_opname(get_op()) << " " << head.oid; - if (head.length) out << " " << head.offset << "~" << head.length; - if (head.op >= 10) { + if (get_length()) out << " " << get_offset() << "~" << get_length(); + if (get_op() >= 10) { if (is_safe()) out << " commit"; else out << " ack"; } - out << " = " << head.result; + out << " = " << get_result(); out << ")"; } diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 985fc3bebb4..05203eace70 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1886,8 +1886,8 @@ void OSD::split_pg(PG *parent, map& children, ObjectStore::Transaction ceph_object_layout l = osdmap->make_object_layout(poid.oid, parentid.type(), parentid.size(), parentid.pool(), parentid.preferred()); - if (l.ol_pgid.pg64 != parentid.u.pg64) { - pg_t pgid(l.ol_pgid); + if (le64_to_cpu(l.ol_pgid) != parentid.u.pg64) { + pg_t pgid(le64_to_cpu(l.ol_pgid)); dout(20) << " moving " << poid << " from " << parentid << " -> " << pgid << dendl; PG *child = children[pgid]; assert(child); diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 5cbea9cdbb4..26e4364403c 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -479,8 +479,8 @@ private: // construct object layout pg_t pgid = pg_t(pg_type, pg_size, ps, pg_pool, preferred); ceph_object_layout layout; - layout.ol_pgid = pgid.u; - layout.ol_stripe_unit = object_stripe_unit; + layout.ol_pgid = cpu_to_le64(pgid.u.pg64); + layout.ol_stripe_unit = cpu_to_le32(object_stripe_unit); return layout; } diff --git a/src/osd/RAID4PG.cc b/src/osd/RAID4PG.cc index 67b9b6dd364..84a9f2c2e41 100644 --- a/src/osd/RAID4PG.cc +++ b/src/osd/RAID4PG.cc @@ -48,13 +48,14 @@ void RAID4PG::do_op(MOSDOp *op) off_t left = op->get_length(); // map data onto pobjects + int su = le32_to_cpu(layout.ol_stripe_unit); int n = pg.size() - 1; // n+1 raid4 - int rank = (off % layout.ol_stripe_unit) % n; + int rank = (off % su) % n; off_t off_in_bl = 0; while (left > 0) { pobject_t po(0, rank, oid); - off_t off_in_po = off % layout.ol_stripe_unit; - off_t stripe_unit_end = off - off_in_po + layout.ol_stripe_unit; + off_t off_in_po = off % su; + off_t stripe_unit_end = off - off_in_po + su; off_t len_in_po = MAX(left, stripe_unit_end-off); bufferlist data_in_po; data_in_po.substr_of(data, off_in_bl, len_in_po); diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 81abe4db0d8..5603e8054fc 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -158,8 +158,8 @@ bool ReplicatedPG::preprocess_op(MOSDOp *op, utime_t now) dout(-10) << "preprocess_op balance-reads on " << oid << dendl; balancing_reads.insert(oid); ceph_object_layout layout; - layout.ol_pgid = info.pgid.u; - layout.ol_stripe_unit = 0; + layout.ol_pgid = cpu_to_le64(info.pgid.u.pg64); + layout.ol_stripe_unit = cpu_to_le32(0); MOSDOp *pop = new MOSDOp(osd->messenger->get_myinst(), 0, osd->get_tid(), oid, layout, @@ -172,8 +172,8 @@ bool ReplicatedPG::preprocess_op(MOSDOp *op, utime_t now) dout(-10) << "preprocess_op unbalance-reads on " << oid << dendl; unbalancing_reads.insert(oid); ceph_object_layout layout; - layout.ol_pgid = info.pgid.u; - layout.ol_stripe_unit = 0; + layout.ol_pgid = cpu_to_le64(info.pgid.u.pg64); + layout.ol_stripe_unit = cpu_to_le32(0); MOSDOp *pop = new MOSDOp(osd->messenger->get_myinst(), 0, osd->get_tid(), oid, layout, @@ -1153,8 +1153,8 @@ void ReplicatedPG::op_modify(MOSDOp *op) unbalancing_reads.insert(poid.oid); ceph_object_layout layout; - layout.ol_pgid = info.pgid.u; - layout.ol_stripe_unit = 0; + layout.ol_pgid = cpu_to_le64(info.pgid.u.pg64); + layout.ol_stripe_unit = cpu_to_le32(0); MOSDOp *pop = new MOSDOp(osd->messenger->get_myinst(), 0, osd->get_tid(), poid.oid, layout, diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index c2b1a6693b2..fec36a6499c 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -160,9 +160,10 @@ namespace __gnu_cxx { inline ostream& operator<<(ostream& out, const ceph_object_layout &ol) { - out << "pg" << ol.ol_pgid; - if (ol.ol_stripe_unit) - out << ".su=" << ol.ol_stripe_unit; + out << pg_t(le64_to_cpu(ol.ol_pgid)); + int su = le32_to_cpu(ol.ol_stripe_unit); + if (su) + out << ".su=" << su; return out; } diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 12abe419b64..31d660c16b9 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -346,7 +346,7 @@ tid_t Objecter::stat_submit(OSDStat *st) { // find OSD ObjectExtent &ex = st->extents.front(); - PG &pg = get_pg( ex.layout.ol_pgid ); + PG &pg = get_pg( pg_t(le64_to_cpu(ex.layout.ol_pgid)) ); // pick tid last_tid++; @@ -464,7 +464,7 @@ tid_t Objecter::readx(OSDRead *rd, Context *onfinish) tid_t Objecter::readx_submit(OSDRead *rd, ObjectExtent &ex, bool retry) { // find OSD - PG &pg = get_pg( ex.layout.ol_pgid ); + PG &pg = get_pg( pg_t(le64_to_cpu(ex.layout.ol_pgid)) ); // pick tid last_tid++; @@ -736,7 +736,7 @@ tid_t Objecter::modifyx(OSDModify *wr, Context *onack, Context *oncommit) tid_t Objecter::modifyx_submit(OSDModify *wr, ObjectExtent &ex, tid_t usetid) { // find - PG &pg = get_pg( ex.layout.ol_pgid ); + PG &pg = get_pg( pg_t(le64_to_cpu(ex.layout.ol_pgid)) ); // pick tid tid_t tid;