Merge pull request #20701 from tchaikov/wip-23212

os/bluestore: recalc_allocated() when decoding bluefs_fnode_t

Reviewed-by: Jianpeng Ma <jianpeng.ma@intel.com>
Reviewed-by: Igor Fedotov <ifedotov@suse.com>
This commit is contained in:
Kefu Chai 2018-03-06 08:28:12 +08:00 committed by GitHub
commit a1c4846fbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -873,7 +873,6 @@ int BlueFS::_replay(bool noop, bool to_stdout)
{
bluefs_fnode_t fnode;
decode(fnode, p);
fnode.recalc_allocated();
dout(20) << __func__ << " 0x" << std::hex << pos << std::dec
<< ": op_file_update " << " " << fnode << dendl;
if (unlikely(to_stdout)) {

View File

@ -54,7 +54,22 @@ struct bluefs_fnode_t {
allocated += p.length;
}
DENC(bluefs_fnode_t, v, p) {
DENC_HELPERS
void bound_encode(size_t& p) const {
_denc_friend(*this, p);
}
void encode(bufferlist::contiguous_appender& p) const {
DENC_DUMP_PRE(bluefs_fnode_t);
_denc_friend(*this, p);
DENC_DUMP_POST(bluefs_fnode_t);
}
void decode(buffer::ptr::iterator& p) {
_denc_friend(*this, p);
recalc_allocated();
}
template<typename T, typename P>
friend std::enable_if_t<std::is_same_v<bluefs_fnode_t, std::remove_const_t<T>>>
_denc_friend(T& v, P& p) {
DENC_START(1, 1, p);
denc_varint(v.ino, p);
denc_varint(v.size, p);