From c68266969cc5100d4db17575ca547e16d174b12e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 20 Dec 2007 16:29:12 -0800 Subject: [PATCH] less typedef --- src/client/SyntheticClient.cc | 12 ++++++------ src/include/ceph_fs.h | 28 +++++++++++----------------- src/include/object.h | 4 ++-- src/include/types.h | 2 +- src/kernel/osd_client.h | 2 +- src/messages/MOSDOp.h | 8 ++++---- src/mon/MonMap.h | 2 +- src/osd/OSD.cc | 2 +- src/osd/OSDMap.h | 14 +++++++------- src/osd/RAID4PG.cc | 2 +- src/osd/ReplicatedPG.cc | 6 +++--- src/osd/osd_types.h | 12 ++++++------ src/osdc/ObjectCacher.h | 10 +++++----- src/osdc/Objecter.cc | 10 +++++----- src/osdc/Objecter.h | 11 +++++------ 15 files changed, 59 insertions(+), 66 deletions(-) diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index c33265512fb12..8cd41a598bf44 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -1258,7 +1258,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) int64_t ol = t.get_int(); object_t oid(oh, ol); lock.Lock(); - ceph_object_layout_t layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, 2); + ceph_object_layout layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, 2); off_t size; client->objecter->stat(oid, &size, layout, new C_SafeCond(&lock, &cond, &ack)); while (!ack) cond.Wait(lock); @@ -1271,7 +1271,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) int64_t len = t.get_int(); object_t oid(oh, ol); lock.Lock(); - ceph_object_layout_t layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, 2); + ceph_object_layout layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, 2); bufferlist bl; client->objecter->read(oid, off, len, layout, &bl, new C_SafeCond(&lock, &cond, &ack)); while (!ack) cond.Wait(lock); @@ -1284,7 +1284,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) int64_t len = t.get_int(); object_t oid(oh, ol); lock.Lock(); - ceph_object_layout_t layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, 2); + ceph_object_layout layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, 2); bufferptr bp(len); bufferlist bl; bl.push_back(bp); @@ -1301,7 +1301,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) int64_t len = t.get_int(); object_t oid(oh, ol); lock.Lock(); - ceph_object_layout_t layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, 2); + ceph_object_layout layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, 2); client->objecter->zero(oid, off, len, layout, new C_SafeCond(&lock, &cond, &ack), safeg->new_sub()); @@ -1943,7 +1943,7 @@ int SyntheticClient::create_objects(int nobj, int osize, int inflight) if (time_to_stop()) break; object_t oid(0x1000, i); - ceph_object_layout_t layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, g_OSD_FileLayout.fl_pg_size); + ceph_object_layout layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, g_OSD_FileLayout.fl_pg_size); if (i % inflight == 0) { dout(6) << "create_objects " << i << "/" << (nobj+1) << dendl; @@ -2045,7 +2045,7 @@ int SyntheticClient::object_rw(int nobj, int osize, int wrpc, } object_t oid(0x1000, o); - ceph_object_layout_t layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, g_OSD_FileLayout.fl_pg_size); + ceph_object_layout layout = client->osdmap->make_object_layout(oid, pg_t::TYPE_REP, g_OSD_FileLayout.fl_pg_size); client->client_lock.Lock(); utime_t start = g_clock.now(); diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index df10567e815a3..efd51d39b69b7 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -28,9 +28,8 @@ struct ceph_fsid { __u64 major; __u64 minor; }; -typedef struct ceph_fsid ceph_fsid_t; -static inline int ceph_fsid_equal(const ceph_fsid_t *a, const ceph_fsid_t *b) { +static inline int ceph_fsid_equal(const struct ceph_fsid *a, const struct ceph_fsid *b) { return a->major == b->major && a->minor == b->minor; } @@ -45,7 +44,6 @@ struct ceph_object { __u32 bno; /* "block" (object) in that "file" */ __u32 rev; /* revision. normally ctime (as epoch). */ }; -typedef struct ceph_object ceph_object_t; #define CEPH_INO_ROOT 1 @@ -119,7 +117,6 @@ union ceph_pg { __u8 size; } pg; }; -typedef union ceph_pg ceph_pg_t; #define ceph_pg_is_rep(pg) (pg.pg.type == CEPH_PG_TYPE_REP) #define ceph_pg_is_raid4(pg) (pg.pg.type == CEPH_PG_TYPE_RAID4) @@ -128,10 +125,9 @@ typedef union ceph_pg ceph_pg_t; * object layout - how a given object should be stored. */ struct ceph_object_layout { - ceph_pg_t pgid; - __u32 stripe_unit; + union ceph_pg pgid; + __u32 stripe_unit; } __attribute__ ((packed)); -typedef struct ceph_object_layout ceph_object_layout_t; /* * compound epoch+version, used by rados to serialize mutations @@ -140,7 +136,6 @@ struct ceph_eversion { ceph_epoch_t epoch; __u64 version; } __attribute__ ((packed)); -typedef struct ceph_eversion ceph_eversion_t; /* * osd map bits @@ -426,7 +421,6 @@ struct ceph_osd_peer_stat { float frac_rd_ops_shed_in; float frac_rd_ops_shed_out; } __attribute__ ((packed)); -typedef struct ceph_osd_peer_stat ceph_osd_peer_stat_t; struct ceph_osd_request_head { struct ceph_entity_inst client_inst; @@ -434,29 +428,29 @@ struct ceph_osd_request_head { __u32 client_inc; __u32 op; __u64 offset, length; - ceph_object_t oid; - ceph_object_layout_t layout; + struct ceph_object oid; + struct ceph_object_layout layout; ceph_epoch_t osdmap_epoch; __u32 flags; - ceph_eversion_t reassert_version; + struct ceph_eversion reassert_version; /* semi-hack, fix me */ - __u32 shed_count; - ceph_osd_peer_stat_t peer_stat; + __u32 shed_count; + struct ceph_osd_peer_stat peer_stat; } __attribute__ ((packed)); struct ceph_osd_reply_head { ceph_tid_t tid; __u32 op; __u32 flags; - ceph_object_t oid; - ceph_object_layout_t layout; + struct ceph_object oid; + struct ceph_object_layout layout; ceph_epoch_t osdmap_epoch; __s32 result; __u64 offset, length; - ceph_eversion_t reassert_version; + struct ceph_eversion reassert_version; } __attribute__ ((packed)); #endif diff --git a/src/include/object.h b/src/include/object.h index 9153bd951b8dc..f1b247b01681e 100644 --- a/src/include/object.h +++ b/src/include/object.h @@ -47,8 +47,8 @@ struct object_t { bno = co.bno; rev = co.rev; } - operator ceph_object_t() { - ceph_object_t oid; + operator ceph_object() { + ceph_object oid; oid.ino = ino; oid.bno = bno; oid.rev = rev; diff --git a/src/include/types.h b/src/include/types.h index 0752db3360e3e..020a5e7e52d21 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -224,7 +224,7 @@ struct inode_t { // -- -inline ostream& operator<<(ostream& out, ceph_fsid_t& f) { +inline ostream& operator<<(ostream& out, ceph_fsid& f) { return out << hex << f.major << '.' << f.minor << dec; } diff --git a/src/kernel/osd_client.h b/src/kernel/osd_client.h index 3f554ad907000..47291ed64a557 100644 --- a/src/kernel/osd_client.h +++ b/src/kernel/osd_client.h @@ -40,7 +40,7 @@ struct ceph_osd_request { struct ceph_osd_client { spinlock_t lock; - struct ceph_client *client; + struct ceph_client *client; struct ceph_osdmap *osdmap; /* current map */ __u64 last_requested_map; __u64 last_tid; /* tid of last request */ diff --git a/src/messages/MOSDOp.h b/src/messages/MOSDOp.h index 3ce6071fcf240..c7c16d067dbd8 100644 --- a/src/messages/MOSDOp.h +++ b/src/messages/MOSDOp.h @@ -76,7 +76,7 @@ public: object_t get_oid() { return object_t(head.oid); } pg_t get_pg() { return head.layout.pgid; } - ceph_object_layout_t get_layout() { return head.layout; } + ceph_object_layout get_layout() { return head.layout; } epoch_t get_map_epoch() { return head.osdmap_epoch; } eversion_t get_version() { return head.reassert_version; } @@ -94,7 +94,7 @@ public: void set_attrset(map &as) { attrset.swap(as); } void set_peer_stat(const osd_peer_stat_t& stat) { head.peer_stat = stat; } - const ceph_osd_peer_stat_t& get_peer_stat() { return head.peer_stat; } + const ceph_osd_peer_stat& get_peer_stat() { return head.peer_stat; } void inc_shed_count() { head.shed_count++; } int get_shed_count() { return head.shed_count; } @@ -102,7 +102,7 @@ public: MOSDOp(entity_inst_t asker, int inc, long tid, - object_t oid, ceph_object_layout_t ol, epoch_t mapepoch, int op) : + object_t oid, ceph_object_layout ol, epoch_t mapepoch, int op) : Message(CEPH_MSG_OSD_OP) { memset(&head, 0, sizeof(head)); head.client_inst.name = asker.name.v; @@ -118,7 +118,7 @@ public: } MOSDOp() {} - void set_layout(const ceph_object_layout_t& l) { head.layout = 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; } diff --git a/src/mon/MonMap.h b/src/mon/MonMap.h index f8adebd3f405d..acfaa69c886bb 100644 --- a/src/mon/MonMap.h +++ b/src/mon/MonMap.h @@ -25,7 +25,7 @@ class MonMap { public: epoch_t epoch; // what epoch/version of the monmap - ceph_fsid_t fsid; + ceph_fsid fsid; vector mon_inst; int last_mon; // last mon i talked to diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index c2c2c8dd967ca..2c4b708ff0a6e 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1324,7 +1324,7 @@ void OSD::advance_map(ObjectStore::Transaction& t) // is this okay? assert(superblock.current_epoch == 2); - ceph_fsid_t nullfsid; + ceph_fsid nullfsid; memset(&nullfsid, 0, sizeof(nullfsid)); if (memcmp(&nullfsid, &superblock.fsid, sizeof(nullfsid)) != 0) { derr(0) << "will not mkfs, my superblock fsid is not zeroed" << dendl; diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 17ee4f20c5322..0252f0444be67 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -83,7 +83,7 @@ class OSDMap { public: class Incremental { public: - ceph_fsid_t fsid; + ceph_fsid fsid; epoch_t epoch; // new epoch; we are a diff from epoch-1 to epoch epoch_t mon_epoch; // monitor epoch (election iteration) utime_t ctime; @@ -135,7 +135,7 @@ public: }; private: - ceph_fsid_t fsid; + ceph_fsid fsid; epoch_t epoch; // what epoch of the osd cluster descriptor is this epoch_t mon_epoch; // monitor epoch (election iteration) utime_t ctime, mtime; // epoch start time @@ -165,8 +165,8 @@ private: } // map info - ceph_fsid_t& get_fsid() { return fsid; } - void set_fsid(ceph_fsid_t& f) { fsid = f; } + ceph_fsid& get_fsid() { return fsid; } + void set_fsid(ceph_fsid& f) { fsid = f; } epoch_t get_epoch() const { return epoch; } void inc_epoch() { epoch++; } @@ -387,11 +387,11 @@ private: /**** mapping facilities ****/ // oid -> pg - ceph_object_layout_t file_to_object_layout(object_t oid, FileLayout& layout) { + ceph_object_layout file_to_object_layout(object_t oid, FileLayout& layout) { return make_object_layout(oid, layout.fl_pg_type, layout.fl_pg_size, layout.fl_pg_preferred, layout.fl_object_stripe_unit); } - ceph_object_layout_t make_object_layout(object_t oid, int pg_type, int pg_size, int preferred=-1, int object_stripe_unit = 0) { + ceph_object_layout make_object_layout(object_t oid, int pg_type, int pg_size, int preferred=-1, int object_stripe_unit = 0) { int num = preferred >= 0 ? localized_pg_num:pg_num; int num_mask = preferred >= 0 ? localized_pg_num_mask:pg_num_mask; @@ -422,7 +422,7 @@ private: // construct object layout pg_t pgid = pg_t(pg_type, pg_size, ps, preferred); - ceph_object_layout_t layout; + ceph_object_layout layout; layout.pgid = pgid.u; layout.stripe_unit = object_stripe_unit; return layout; diff --git a/src/osd/RAID4PG.cc b/src/osd/RAID4PG.cc index d882fd3ff095b..165dca1726935 100644 --- a/src/osd/RAID4PG.cc +++ b/src/osd/RAID4PG.cc @@ -42,7 +42,7 @@ void RAID4PG::do_op(MOSDOp *op) // a write will do something like object_t oid = op->get_oid(); // logical object pg_t pg = op->get_pg(); - ceph_object_layout_t layout = op->get_layout(); + ceph_object_layout layout = op->get_layout(); bufferlist data = op->get_data(); off_t off = op->get_offset(); off_t left = op->get_length(); diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 7b48093739b70..7309b8f6de94a 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -153,7 +153,7 @@ bool ReplicatedPG::preprocess_op(MOSDOp *op, utime_t now) balancing_reads.count(oid) == 0) { dout(-10) << "preprocess_op balance-reads on " << oid << dendl; balancing_reads.insert(oid); - ceph_object_layout_t layout; + ceph_object_layout layout; layout.pgid = info.pgid.u; layout.stripe_unit = 0; MOSDOp *pop = new MOSDOp(osd->messenger->get_myinst(), 0, osd->get_tid(), @@ -167,7 +167,7 @@ bool ReplicatedPG::preprocess_op(MOSDOp *op, utime_t now) !unbalancing_reads.count(oid) == 0) { dout(-10) << "preprocess_op unbalance-reads on " << oid << dendl; unbalancing_reads.insert(oid); - ceph_object_layout_t layout; + ceph_object_layout layout; layout.pgid = info.pgid.u; layout.stripe_unit = 0; MOSDOp *pop = new MOSDOp(osd->messenger->get_myinst(), 0, osd->get_tid(), @@ -1130,7 +1130,7 @@ void ReplicatedPG::op_modify(MOSDOp *op) dout(-10) << "preprocess_op unbalancing-reads on " << op->get_oid() << dendl; unbalancing_reads.insert(op->get_oid()); - ceph_object_layout_t layout; + ceph_object_layout layout; layout.pgid = info.pgid.u; layout.stripe_unit = 0; MOSDOp *pop = new MOSDOp(osd->messenger->get_myinst(), 0, osd->get_tid(), diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 08de55b59e871..723d58b982c67 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -98,7 +98,7 @@ public: assert(sizeof(u.pg) == sizeof(u.pg64)); } pg_t(uint64_t v) { u.pg64 = v; } - pg_t(const ceph_pg_t& cpg) { + pg_t(const ceph_pg& cpg) { u = cpg; } @@ -163,7 +163,7 @@ namespace __gnu_cxx { -inline ostream& operator<<(ostream& out, const ceph_object_layout_t &ol) +inline ostream& operator<<(ostream& out, const ceph_object_layout &ol) { out << "pg" << ol.pgid; if (ol.stripe_unit) @@ -182,8 +182,8 @@ public: eversion_t(epoch_t e, version_t v) : epoch(e), version(v) {} eversion_t(const ceph_eversion& ce) : epoch(ce.epoch), version(ce.version) {} - operator ceph_eversion_t() { - ceph_eversion_t c; + operator ceph_eversion() { + ceph_eversion c; c.epoch = epoch; c.version = version; return c; @@ -260,7 +260,7 @@ class ObjectExtent { off_t start; // in object size_t length; // in object - ceph_object_layout_t layout; // object layout (pgid, etc.) + ceph_object_layout layout; // object layout (pgid, etc.) map buffer_extents; // off -> len. extents in buffer being mapped (may be fragmented bc of striping!) @@ -284,7 +284,7 @@ class OSDSuperblock { public: const static uint64_t MAGIC = 0xeb0f505dULL; uint64_t magic; - ceph_fsid_t fsid; + ceph_fsid 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. diff --git a/src/osdc/ObjectCacher.h b/src/osdc/ObjectCacher.h index 4a7c5d42fd365..7d300da70f470 100644 --- a/src/osdc/ObjectCacher.h +++ b/src/osdc/ObjectCacher.h @@ -101,7 +101,7 @@ class ObjectCacher { object_t oid; // this _always_ is oid.rev=0 inodeno_t ino; objectrev_t rev; // last rev we're written - ceph_object_layout_t layout; + ceph_object_layout layout; public: map data; @@ -130,7 +130,7 @@ class ObjectCacher { int rdlock_ref; // how many ppl want or are using a READ lock public: - Object(ObjectCacher *_oc, object_t o, inodeno_t i, ceph_object_layout_t& l) : + Object(ObjectCacher *_oc, object_t o, inodeno_t i, ceph_object_layout& l) : oc(_oc), oid(o), ino(i), layout(l), last_write_tid(0), last_ack_tid(0), last_commit_tid(0), @@ -143,8 +143,8 @@ class ObjectCacher { object_t get_oid() { return oid; } inodeno_t get_ino() { return ino; } - ceph_object_layout_t& get_layout() { return layout; } - void set_layout(ceph_object_layout_t& l) { layout = l; } + ceph_object_layout& get_layout() { return layout; } + void set_layout(ceph_object_layout& l) { layout = l; } bool can_close() { return data.empty() && lock_state == LOCK_NONE && @@ -227,7 +227,7 @@ class ObjectCacher { // objects - Object *get_object(object_t oid, inodeno_t ino, ceph_object_layout_t &l) { + Object *get_object(object_t oid, inodeno_t ino, ceph_object_layout &l) { // have it? if (objects.count(oid)) return objects[oid]; diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index 99a16d32c8da7..1ae785fc78444 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -320,7 +320,7 @@ void Objecter::handle_osd_op_reply(MOSDOpReply *m) // stat ----------------------------------- -tid_t Objecter::stat(object_t oid, off_t *size, ceph_object_layout_t ol, Context *onfinish) +tid_t Objecter::stat(object_t oid, off_t *size, ceph_object_layout ol, Context *onfinish) { OSDStat *st = new OSDStat(size); st->extents.push_back(ObjectExtent(oid, 0, 0)); @@ -422,7 +422,7 @@ void Objecter::handle_osd_stat_reply(MOSDOpReply *m) // read ----------------------------------- -tid_t Objecter::read(object_t oid, off_t off, size_t len, ceph_object_layout_t ol, bufferlist *bl, +tid_t Objecter::read(object_t oid, off_t off, size_t len, ceph_object_layout ol, bufferlist *bl, Context *onfinish) { OSDRead *rd = new OSDRead(bl); @@ -660,7 +660,7 @@ void Objecter::handle_osd_read_reply(MOSDOpReply *m) // write ------------------------------------ -tid_t Objecter::write(object_t oid, off_t off, size_t len, ceph_object_layout_t ol, bufferlist &bl, +tid_t Objecter::write(object_t oid, off_t off, size_t len, ceph_object_layout ol, bufferlist &bl, Context *onack, Context *oncommit) { OSDWrite *wr = new OSDWrite(bl); @@ -674,7 +674,7 @@ tid_t Objecter::write(object_t oid, off_t off, size_t len, ceph_object_layout_t // zero -tid_t Objecter::zero(object_t oid, off_t off, size_t len, ceph_object_layout_t ol, +tid_t Objecter::zero(object_t oid, off_t off, size_t len, ceph_object_layout ol, Context *onack, Context *oncommit) { OSDModify *z = new OSDModify(CEPH_OSD_OP_ZERO); @@ -687,7 +687,7 @@ tid_t Objecter::zero(object_t oid, off_t off, size_t len, ceph_object_layout_t o // lock ops -tid_t Objecter::lock(int op, object_t oid, ceph_object_layout_t ol, +tid_t Objecter::lock(int op, object_t oid, ceph_object_layout ol, Context *onack, Context *oncommit) { OSDModify *l = new OSDModify(op); diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 0c7dd89756f54..c076b080f9e3b 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -209,18 +209,17 @@ class Objecter { // med level tid_t readx(OSDRead *read, Context *onfinish); tid_t modifyx(OSDModify *wr, Context *onack, Context *oncommit); - //tid_t lockx(OSDLock *l, Context *onack, Context *oncommit); // even lazier - tid_t read(object_t oid, off_t off, size_t len, ceph_object_layout_t ol, bufferlist *bl, + tid_t read(object_t oid, off_t off, size_t len, ceph_object_layout ol, bufferlist *bl, Context *onfinish); - tid_t write(object_t oid, off_t off, size_t len, ceph_object_layout_t ol, bufferlist &bl, + tid_t write(object_t oid, off_t off, size_t len, ceph_object_layout ol, bufferlist &bl, Context *onack, Context *oncommit); - tid_t zero(object_t oid, off_t off, size_t len, ceph_object_layout_t ol, + tid_t zero(object_t oid, off_t off, size_t len, ceph_object_layout ol, Context *onack, Context *oncommit); - tid_t stat(object_t oid, off_t *size, ceph_object_layout_t ol, Context *onfinish); + tid_t stat(object_t oid, off_t *size, ceph_object_layout ol, Context *onfinish); - tid_t lock(int op, object_t oid, ceph_object_layout_t ol, Context *onack, Context *oncommit); + tid_t lock(int op, object_t oid, ceph_object_layout ol, Context *onack, Context *oncommit); void ms_handle_failure(Message *m, entity_name_t dest, const entity_inst_t& inst); -- 2.39.5