From: Xinze Chi Date: Mon, 14 Dec 2015 16:29:15 +0000 (+0800) Subject: common: eversion_t encoding optimization X-Git-Tag: v10.0.3~206^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3b08500159d0c3186c9d1a80ec49658a04eb6339;p=ceph.git common: eversion_t encoding optimization There is no padding between version and epoch, no matter 32-bit or 64-bit machine. Signed-off-by: Xinze Chi --- diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index cb712188b76..c8c9a422278 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -673,6 +673,10 @@ inline ostream& operator<<(ostream& out, const ceph_object_layout &ol) // compound rados version type +/* WARNING: If add member in eversion_t, please make sure the encode/decode function + * work well. For little-endian machine, we should make sure there is no padding + * in 32-bit machine and 64-bit machine. + */ class eversion_t { public: version_t version; @@ -705,12 +709,20 @@ public: string get_key_name() const; void encode(bufferlist &bl) const { +#if defined(CEPH_LITTLE_ENDIAN) + bl.append((char *)this, sizeof(version_t) + sizeof(epoch_t)); +#else ::encode(version, bl); ::encode(epoch, bl); +#endif } void decode(bufferlist::iterator &bl) { +#if defined(CEPH_LITTLE_ENDIAN) + bl.copy(sizeof(version_t) + sizeof(epoch_t), (char *)this); +#else ::decode(version, bl); ::decode(epoch, bl); +#endif } void decode(bufferlist& bl) { bufferlist::iterator p = bl.begin();