Skip to content

Commit bebec1f

Browse files
committed
tools/cephfs: recover alternate_name of dentries from journal
Right now the cephfs-journal-tool always uses the legacy encoding for dentries which will drop the alternate_name if ever set. Fixes: 39f3440 Fixes: https://tracker.ceph.com/issues/64602 Signed-off-by: Patrick Donnelly <[email protected]>
1 parent ac092f6 commit bebec1f

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/tools/cephfs/JournalTool.cc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ int JournalTool::recover_dentries(
888888
}
889889

890890
if ((other_pool || write_dentry) && !dry_run) {
891-
dout(4) << "writing I dentry " << key << " into frag "
891+
dout(4) << "writing i dentry " << key << " into frag "
892892
<< frag_oid.name << dendl;
893893
dout(20) << " dnfirst = " << fb.dnfirst << dendl;
894894
if (!fb.alternate_name.empty()) {
@@ -899,11 +899,14 @@ int JournalTool::recover_dentries(
899899
dout(20) << " alternate_name = b64:" << encoded << dendl;
900900
}
901901

902-
// Compose: Dentry format is dnfirst, [I|L], InodeStore(bare=true)
902+
// Compose: Dentry format is dnfirst, [i|l], InodeStore
903903
bufferlist dentry_bl;
904904
encode(fb.dnfirst, dentry_bl);
905-
encode('I', dentry_bl);
906-
encode_fullbit_as_inode(fb, true, &dentry_bl);
905+
encode('i', dentry_bl);
906+
ENCODE_START(2, 1, dentry_bl);
907+
encode(fb.alternate_name, dentry_bl);
908+
encode_fullbit_as_inode(fb, &dentry_bl);
909+
ENCODE_FINISH(dentry_bl);
907910

908911
// Record for writing to RADOS
909912
write_vals[key] = dentry_bl;
@@ -958,12 +961,15 @@ int JournalTool::recover_dentries(
958961
dout(4) << "writing L dentry " << key << " into frag "
959962
<< frag_oid.name << dendl;
960963

961-
// Compose: Dentry format is dnfirst, [I|L], InodeStore(bare=true)
964+
// Compose: Dentry format is dnfirst, [I|L], ino, d_type, alternate_name
962965
bufferlist dentry_bl;
963966
encode(rb.dnfirst, dentry_bl);
964-
encode('L', dentry_bl);
967+
encode('l', dentry_bl);
968+
ENCODE_START(2, 1, dentry_bl);
965969
encode(rb.ino, dentry_bl);
966970
encode(rb.d_type, dentry_bl);
971+
encode(rb.alternate_name, dentry_bl);
972+
ENCODE_FINISH(dentry_bl);
967973

968974
// Record for writing to RADOS
969975
write_vals[key] = dentry_bl;
@@ -1082,10 +1088,10 @@ int JournalTool::recover_dentries(
10821088
dout(4) << "writing root ino " << root_oid.name
10831089
<< " version " << fb.inode->version << dendl;
10841090

1085-
// Compose: root ino format is magic,InodeStore(bare=false)
1091+
// Compose: root ino format is magic,InodeStore
10861092
bufferlist new_root_ino_bl;
10871093
encode(std::string(CEPH_FS_ONDISK_MAGIC), new_root_ino_bl);
1088-
encode_fullbit_as_inode(fb, false, &new_root_ino_bl);
1094+
encode_fullbit_as_inode(fb, &new_root_ino_bl);
10891095

10901096
// Write to RADOS
10911097
r = output.write_full(root_oid.name, new_root_ino_bl);
@@ -1195,7 +1201,6 @@ int JournalTool::erase_region(JournalScanner const &js, uint64_t const pos, uint
11951201
*/
11961202
void JournalTool::encode_fullbit_as_inode(
11971203
const EMetaBlob::fullbit &fb,
1198-
const bool bare,
11991204
bufferlist *out_bl)
12001205
{
12011206
ceph_assert(out_bl != NULL);
@@ -1210,11 +1215,7 @@ void JournalTool::encode_fullbit_as_inode(
12101215
new_inode.old_inodes = fb.old_inodes;
12111216

12121217
// Serialize InodeStore
1213-
if (bare) {
1214-
new_inode.encode_bare(*out_bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
1215-
} else {
1216-
new_inode.encode(*out_bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
1217-
}
1218+
new_inode.encode(*out_bl, CEPH_FEATURES_SUPPORTED_DEFAULT);
12181219
}
12191220

12201221
/**

src/tools/cephfs/JournalTool.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class JournalTool : public MDSUtility
7878
// Backing store helpers
7979
void encode_fullbit_as_inode(
8080
const EMetaBlob::fullbit &fb,
81-
const bool bare,
8281
bufferlist *out_bl);
8382
int consume_inos(const std::set<inodeno_t> &inos);
8483

0 commit comments

Comments
 (0)