Skip to content

Commit 7e6ff07

Browse files
committed
Merge PR ceph#60252 into main
* refs/pull/60252/head: mds: combine several fixed-size `encode()` calls common/fs_types: combine several fixed-size `encode()` calls Reviewed-by: Dhairya Parmar <[email protected]> Reviewed-by: Patrick Donnelly <[email protected]>
2 parents d5a269d + 4ebdd59 commit 7e6ff07

File tree

4 files changed

+74
-50
lines changed

4 files changed

+74
-50
lines changed

src/common/fs_types.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "common/Formatter.h"
66
#include "include/ceph_features.h"
77
#include "common/ceph_json.h"
8+
#include "include/denc.h"
89

910
void dump(const ceph_file_layout& l, ceph::Formatter *f)
1011
{
@@ -86,10 +87,12 @@ void file_layout_t::encode(ceph::buffer::list& bl, uint64_t features) const
8687
}
8788

8889
ENCODE_START(2, 2, bl);
89-
encode(stripe_unit, bl);
90-
encode(stripe_count, bl);
91-
encode(object_size, bl);
92-
encode(pool_id, bl);
90+
encode(std::tuple{
91+
stripe_unit,
92+
stripe_count,
93+
object_size,
94+
pool_id,
95+
}, bl, 0);
9396
encode(pool_ns, bl);
9497
ENCODE_FINISH(bl);
9598
}

src/mds/Anchor.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
#include "mds/Anchor.h"
1616

1717
#include "common/Formatter.h"
18+
#include "include/denc.h"
1819

1920
void Anchor::encode(bufferlist &bl) const
2021
{
2122
ENCODE_START(2, 1, bl);
22-
encode(ino, bl);
23-
encode(dirino, bl);
23+
encode(std::tuple{
24+
ino,
25+
dirino,
26+
}, bl, 0);
2427
encode(d_name, bl);
2528
encode(d_type, bl);
2629
encode(frags, bl);

src/mds/CInode.cc

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#include "common/config.h"
4242
#include "global/global_context.h"
43+
#include "include/denc.h"
4344
#include "include/ceph_assert.h"
4445

4546
#include "mds/MDSContinuation.h"
@@ -4110,35 +4111,39 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,
41104111
*/
41114112
if (session->info.has_feature(CEPHFS_FEATURE_REPLY_ENCODING)) {
41124113
ENCODE_START(7, 1, bl);
4113-
encode(oi->ino, bl);
4114-
encode(snapid, bl);
4115-
encode(oi->rdev, bl);
4116-
encode(version, bl);
4117-
encode(xattr_version, bl);
4114+
encode(std::tuple{
4115+
oi->ino,
4116+
snapid,
4117+
oi->rdev,
4118+
version,
4119+
xattr_version,
4120+
}, bl, 0);
41184121
encode(ecap, bl);
41194122
{
41204123
ceph_file_layout legacy_layout;
41214124
layout.to_legacy(&legacy_layout);
41224125
encode(legacy_layout, bl);
41234126
}
4124-
encode(any_i->ctime, bl);
4125-
encode(file_i->mtime, bl);
4126-
encode(file_i->atime, bl);
4127-
encode(file_i->time_warp_seq, bl);
4128-
encode(file_i->size, bl);
4129-
encode(max_size, bl);
4130-
encode(file_i->truncate_size, bl);
4131-
encode(file_i->truncate_seq, bl);
4132-
encode(auth_i->mode, bl);
4133-
encode((uint32_t)auth_i->uid, bl);
4134-
encode((uint32_t)auth_i->gid, bl);
4135-
encode(link_i->nlink, bl);
4136-
encode(file_i->dirstat.nfiles, bl);
4137-
encode(file_i->dirstat.nsubdirs, bl);
4138-
encode(file_i->rstat.rbytes, bl);
4139-
encode(file_i->rstat.rfiles, bl);
4140-
encode(file_i->rstat.rsubdirs, bl);
4141-
encode(file_i->rstat.rctime, bl);
4127+
encode(std::tuple{
4128+
any_i->ctime,
4129+
file_i->mtime,
4130+
file_i->atime,
4131+
file_i->time_warp_seq,
4132+
file_i->size,
4133+
max_size,
4134+
file_i->truncate_size,
4135+
file_i->truncate_seq,
4136+
auth_i->mode,
4137+
(uint32_t)auth_i->uid,
4138+
(uint32_t)auth_i->gid,
4139+
link_i->nlink,
4140+
file_i->dirstat.nfiles,
4141+
file_i->dirstat.nsubdirs,
4142+
file_i->rstat.rbytes,
4143+
file_i->rstat.rfiles,
4144+
file_i->rstat.rsubdirs,
4145+
file_i->rstat.rctime,
4146+
}, bl, 0);
41424147
dirfragtree.encode(bl);
41434148
encode(symlink, bl);
41444149
encode(file_i->dir_layout, bl);

src/mds/journal.cc

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "events/ESegment.h"
3939
#include "events/ELid.h"
4040

41+
#include "include/denc.h"
4142
#include "include/stringify.h"
4243

4344
#include "LogSegment.h"
@@ -686,12 +687,14 @@ void EMetaBlob::remotebit::encode(bufferlist& bl) const
686687
{
687688
ENCODE_START(3, 2, bl);
688689
encode(dn, bl);
689-
encode(dnfirst, bl);
690-
encode(dnlast, bl);
691-
encode(dnv, bl);
692-
encode(ino, bl);
693-
encode(d_type, bl);
694-
encode(dirty, bl);
690+
encode(std::tuple{
691+
dnfirst,
692+
dnlast,
693+
dnv,
694+
ino,
695+
d_type,
696+
dirty,
697+
}, bl, 0);
695698
encode(alternate_name, bl);
696699
ENCODE_FINISH(bl);
697700
}
@@ -758,10 +761,12 @@ void EMetaBlob::nullbit::encode(bufferlist& bl) const
758761
{
759762
ENCODE_START(2, 2, bl);
760763
encode(dn, bl);
761-
encode(dnfirst, bl);
762-
encode(dnlast, bl);
763-
encode(dnv, bl);
764-
encode(dirty, bl);
764+
encode(std::tuple{
765+
dnfirst,
766+
dnlast,
767+
dnv,
768+
dirty,
769+
}, bl, 0);
765770
ENCODE_FINISH(bl);
766771
}
767772

@@ -799,10 +804,12 @@ void EMetaBlob::dirlump::encode(bufferlist& bl, uint64_t features) const
799804
{
800805
ENCODE_START(2, 2, bl);
801806
encode(*fnode, bl);
802-
encode(state, bl);
803-
encode(nfull, bl);
804-
encode(nremote, bl);
805-
encode(nnull, bl);
807+
encode(std::tuple{
808+
state,
809+
nfull,
810+
nremote,
811+
nnull,
812+
}, bl, 0);
806813
_encode_bits(features);
807814
encode(dnbl, bl);
808815
ENCODE_FINISH(bl);
@@ -879,13 +886,17 @@ void EMetaBlob::encode(bufferlist& bl, uint64_t features) const
879886
encode(lump_map, bl, features);
880887
encode(roots, bl, features);
881888
encode(table_tids, bl);
882-
encode(opened_ino, bl);
883-
encode(allocated_ino, bl);
884-
encode(used_preallocated_ino, bl);
889+
encode(std::tuple{
890+
opened_ino,
891+
allocated_ino,
892+
used_preallocated_ino,
893+
}, bl, 0);
885894
encode(preallocated_inos, bl);
886895
encode(client_name, bl);
887-
encode(inotablev, bl);
888-
encode(sessionmapv, bl);
896+
encode(std::tuple{
897+
inotablev,
898+
sessionmapv,
899+
}, bl, 0);
889900
encode(truncate_start, bl);
890901
encode(truncate_finish, bl);
891902
encode(destroyed_inodes, bl);
@@ -896,8 +907,10 @@ void EMetaBlob::encode(bufferlist& bl, uint64_t features) const
896907
// make MDSRank use v6 format happy
897908
int64_t i = -1;
898909
bool b = false;
899-
encode(i, bl);
900-
encode(b, bl);
910+
encode(std::tuple{
911+
i,
912+
b,
913+
}, bl, 0);
901914
}
902915
encode(client_flushes, bl);
903916
ENCODE_FINISH(bl);

0 commit comments

Comments
 (0)