This will unify all the same work in different places.
Fixes: https://tracker.ceph.com/issues/47162
Signed-off-by: Xiubo Li <xiubli@redhat.com>
}
}
+void CDentry::encode_remote(inodeno_t& ino, unsigned char d_type, bufferlist &bl)
+{
+ bl.append("l", 1); // remote link
+
+ // marker, name, ino
+ ENCODE_START(1, 1, bl);
+ encode(ino, bl);
+ encode(d_type, bl);
+ ENCODE_FINISH(bl);
+}
+
+void CDentry::decode_remote(char icode, inodeno_t& ino, unsigned char& d_type,
+ ceph::buffer::list::const_iterator& bl)
+{
+ if (icode == 'l') {
+ DECODE_START(1, bl);
+ decode(ino, bl);
+ decode(d_type, bl);
+ DECODE_FINISH(bl);
+ } else if (icode == 'L') {
+ decode(ino, bl);
+ decode(d_type, bl);
+ } else ceph_assert(0);
+}
+
void CDentry::dump(Formatter *f) const
{
ceph_assert(f != NULL);
void print(std::ostream& out) override;
void dump(ceph::Formatter *f) const;
+ static void encode_remote(inodeno_t& ino, unsigned char d_type, bufferlist &bl);
+ static void decode_remote(char icode, inodeno_t& ino, unsigned char& d_type,
+ ceph::buffer::list::const_iterator& bl);
__u32 hash;
snapid_t first, last;
inodeno_t ino;
unsigned char d_type;
- if (type == 'l') {
- DECODE_START(1, q);
- decode(ino, q);
- decode(d_type, q);
- DECODE_FINISH(q);
- } else {
- decode(ino, q);
- decode(d_type, q);
- }
+ CDentry::decode_remote(type, ino, d_type, q);
if (stale) {
if (!dn) {
for (auto &item : to_set) {
encode(item.first, bl);
if (item.is_remote) {
- // marker, name, ino
- bl.append('l'); // remote link
- ENCODE_START(1, 1, bl);
- encode(item.ino, bl);
- encode(item.d_type, bl);
- ENCODE_FINISH(bl);
+ CDentry::encode_remote(item.ino, item.d_type, bl); // remote link
} else {
// marker, name, inode, [symlink string]
bl.append('i'); // inode
}
if (dn->get_linkage()->is_remote()) {
- // remote link
- exportbl.append("l", 1); // remote link
-
inodeno_t ino = dn->get_linkage()->get_remote_ino();
unsigned char d_type = dn->get_linkage()->get_remote_d_type();
- ENCODE_START(1, 1, exportbl);
- encode(ino, exportbl);
- encode(d_type, exportbl);
- ENCODE_FINISH(exportbl);
+ CDentry::encode_remote(ino, d_type, exportbl); // remote link
continue;
}
// remote link
inodeno_t ino;
unsigned char d_type;
- if (icode == 'l') {
- DECODE_START(1, blp);
- decode(ino, blp);
- decode(d_type, blp);
- DECODE_FINISH(blp);
- } else {
- decode(ino, blp);
- decode(d_type, blp);
- }
+ CDentry::decode_remote(icode, ino, d_type, blp);
if (dn->get_linkage()->is_remote()) {
ceph_assert(dn->get_linkage()->get_remote_ino() == ino);
} else {
#include <fstream>
#include "include/util.h"
+#include "mds/CDentry.h"
#include "mds/CInode.h"
#include "mds/InoTable.h"
#include "mds/SnapServer.h"
} else if (dentry_type == 'L' || dentry_type == 'l') {
inodeno_t ino;
unsigned char d_type;
- if (dentry_type == 'l') {
- DECODE_START(1, q);
- decode(ino, q);
- decode(d_type, q);
- DECODE_FINISH(q);
- } else {
- decode(ino, q);
- decode(d_type, q);
- }
+ CDentry::decode_remote(dentry_type, ino, d_type, q);
if (step == SCAN_INOS) {
remote_links[ino]++;
#include "mds/mdstypes.h"
#include "mds/LogEvent.h"
#include "mds/InoTable.h"
+#include "mds/CDentry.h"
#include "mds/events/ENoOp.h"
#include "mds/events/EUpdate.h"
// hard link
inodeno_t ino;
unsigned char d_type;
- if (type == 'l') {
- DECODE_START(1, q);
- ::decode(ino, q);
- ::decode(d_type, q);
- DECODE_FINISH(q);
- } else {
- ::decode(ino, q);
- ::decode(d_type, q);
- }
+
+ CDentry::decode_remote(type, ino, d_type, q);
if (sp_ino > 0) {
if (sp_ino == ino) {