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 14, 2015
1 parent f573f47 commit 7f2d967
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/osd/osd_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4225,7 +4225,16 @@ 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 & FLAG_OMAP_DIGEST) &&
!(flags & FLAG_DATA_DIGEST) &&
local_mtime == utime_t()) {
ev = 13;
}

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 @@ -4250,9 +4259,13 @@ void object_info_t::encode(bufferlist& bl) const
::encode(watchers, bl);
__u32 _flags = flags;
::encode(_flags, bl);
::encode(local_mtime, bl);
::encode(data_digest, bl);
::encode(omap_digest, 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 +4340,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 7f2d967

Please sign in to comment.