From: Patrick Donnelly Date: Sat, 8 Jun 2024 19:01:12 +0000 (-0400) Subject: tools/cephfs: recover alternate_name of dentries from journal X-Git-Tag: testing/wip-jcollin-testing-20240701.061036-squid~5^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e0fe1f4293860eca15358714cd37d632946d8989;p=ceph-ci.git 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 (cherry picked from commit bebec1f9c7f61d598e9e82448cdd23b1f3561601) --- diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index 703bf69c7a4..b204cbef1b0 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -888,7 +888,7 @@ int JournalTool::recover_dentries( } if ((other_pool || write_dentry) && !dry_run) { - dout(4) << "writing I dentry " << key << " into frag " + dout(4) << "writing i dentry " << key << " into frag " << frag_oid.name << dendl; dout(20) << " dnfirst = " << fb.dnfirst << dendl; if (!fb.alternate_name.empty()) { @@ -899,11 +899,14 @@ int JournalTool::recover_dentries( dout(20) << " alternate_name = b64:" << encoded << dendl; } - // Compose: Dentry format is dnfirst, [I|L], InodeStore(bare=true) + // Compose: Dentry format is dnfirst, [i|l], InodeStore bufferlist dentry_bl; encode(fb.dnfirst, dentry_bl); - encode('I', dentry_bl); - encode_fullbit_as_inode(fb, true, &dentry_bl); + encode('i', dentry_bl); + ENCODE_START(2, 1, dentry_bl); + encode(fb.alternate_name, dentry_bl); + encode_fullbit_as_inode(fb, &dentry_bl); + ENCODE_FINISH(dentry_bl); // Record for writing to RADOS write_vals[key] = dentry_bl; @@ -958,12 +961,15 @@ int JournalTool::recover_dentries( dout(4) << "writing L dentry " << key << " into frag " << frag_oid.name << dendl; - // Compose: Dentry format is dnfirst, [I|L], InodeStore(bare=true) + // Compose: Dentry format is dnfirst, [I|L], ino, d_type, alternate_name bufferlist dentry_bl; encode(rb.dnfirst, dentry_bl); - encode('L', dentry_bl); + encode('l', dentry_bl); + ENCODE_START(2, 1, dentry_bl); encode(rb.ino, dentry_bl); encode(rb.d_type, dentry_bl); + encode(rb.alternate_name, dentry_bl); + ENCODE_FINISH(dentry_bl); // Record for writing to RADOS write_vals[key] = dentry_bl; @@ -1082,10 +1088,10 @@ int JournalTool::recover_dentries( dout(4) << "writing root ino " << root_oid.name << " version " << fb.inode->version << dendl; - // Compose: root ino format is magic,InodeStore(bare=false) + // Compose: root ino format is magic,InodeStore bufferlist new_root_ino_bl; encode(std::string(CEPH_FS_ONDISK_MAGIC), new_root_ino_bl); - encode_fullbit_as_inode(fb, false, &new_root_ino_bl); + encode_fullbit_as_inode(fb, &new_root_ino_bl); // Write to RADOS 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 */ void JournalTool::encode_fullbit_as_inode( const EMetaBlob::fullbit &fb, - const bool bare, bufferlist *out_bl) { ceph_assert(out_bl != NULL); @@ -1210,11 +1215,7 @@ void JournalTool::encode_fullbit_as_inode( new_inode.old_inodes = fb.old_inodes; // Serialize InodeStore - if (bare) { - new_inode.encode_bare(*out_bl, CEPH_FEATURES_SUPPORTED_DEFAULT); - } else { - new_inode.encode(*out_bl, CEPH_FEATURES_SUPPORTED_DEFAULT); - } + new_inode.encode(*out_bl, CEPH_FEATURES_SUPPORTED_DEFAULT); } /** diff --git a/src/tools/cephfs/JournalTool.h b/src/tools/cephfs/JournalTool.h index 8d610a8665f..ac4258b89e4 100644 --- a/src/tools/cephfs/JournalTool.h +++ b/src/tools/cephfs/JournalTool.h @@ -78,7 +78,6 @@ class JournalTool : public MDSUtility // Backing store helpers void encode_fullbit_as_inode( const EMetaBlob::fullbit &fb, - const bool bare, bufferlist *out_bl); int consume_inos(const std::set &inos);