Skip to content

Commit

Permalink
osd/osd_types: skip encoding newer object_info_t fields if they are u…
Browse files Browse the repository at this point in the history
…nused

This reduces the size of the encoded object_info_t in most cases,
enough to get us under the 255 byte limit for a single inline
xattr in XFS.

Note that we lose the local_mtime, but that this field is only
important for objects in the cache pool.

Note that we drop the unconditional clearing of the digest flags if the
encoding was old; this was not strictly correct anyway.  And now that we
may encode the old way with FLAG_OMAP_DIGEST, we need to leave it set (and
force the value to -1).

Signed-off-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Dec 8, 2015
1 parent 3047f2b commit 2895bb6
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions src/osd/osd_types.cc
Expand Up @@ -4225,7 +4225,18 @@ void object_info_t::encode(bufferlist& bl) const
++i) {
old_watchers.insert(make_pair(i->first.second, i->second));
}
ENCODE_START(15, 8, bl);

// kludge to reduce xattr size for most rbd objects
int ev = 15;
if ((flags & ~0xff) == 0 && // no flags outside low 8 bits set
(!(flags & FLAG_OMAP) || !(flags & FLAG_OMAP_DIGEST)) &&
!(flags & FLAG_DATA_DIGEST) &&
watchers.empty()) { // no watchers
// note: we dropped local_mtime too, even though it may have been used.
ev = 10;
}

ENCODE_START(ev, 8, bl);
::encode(soid, bl);
::encode(myoloc, bl); //Retained for compatibility
::encode((__u32)0, bl); // was category, no longer used
Expand All @@ -4240,19 +4251,33 @@ void object_info_t::encode(bufferlist& bl) const
::encode(snaps, bl);
::encode(truncate_seq, bl);
::encode(truncate_size, bl);
::encode(is_lost(), bl);
{
__u8 lo = is_lost();
if (ev < 13) {
lo = flags; // all flags fit in 8 bits!
}
::encode(lo, bl);
}
::encode(old_watchers, bl);
/* shenanigans to avoid breaking backwards compatibility in the disk format.
* When we can, switch this out for simply putting the version_t on disk. */
eversion_t user_eversion(0, user_version);
::encode(user_eversion, bl);
::encode(test_flag(FLAG_USES_TMAP), bl);
::encode(watchers, bl);
__u32 _flags = flags;
::encode(_flags, bl);
::encode(local_mtime, bl);
::encode(data_digest, bl);
::encode(omap_digest, bl);
if (ev >= 11) {
::encode(watchers, bl);
}
if (ev >= 13) {
__u32 _flags = flags;
::encode(_flags, bl);
}
if (ev >= 14) {
::encode(local_mtime, bl);
}
if (ev >= 15) {
::encode(data_digest, bl);
::encode(omap_digest, bl);
}
ENCODE_FINISH(bl);
}

Expand Down Expand Up @@ -4327,8 +4352,6 @@ void object_info_t::decode(bufferlist::iterator& bl)
::decode(omap_digest, bl);
} else {
data_digest = omap_digest = -1;
clear_flag(FLAG_DATA_DIGEST);
clear_flag(FLAG_OMAP_DIGEST);
}
DECODE_FINISH(bl);
}
Expand Down

0 comments on commit 2895bb6

Please sign in to comment.