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: v18.2.5~530^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=95911dbe06048212d42f985b11cf153a872a7ef3;p=ceph.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 b6df94fca956..2fd1cea24b5c 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -861,7 +861,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()) { @@ -872,11 +872,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; @@ -931,12 +934,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; @@ -1055,10 +1061,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); @@ -1168,7 +1174,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); @@ -1183,11 +1188,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 8d610a8665f1..ac4258b89e43 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);