]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: Add function to fetch inode from metadata pool
authorKotresh HR <khiremat@redhat.com>
Sat, 1 Mar 2025 19:09:41 +0000 (00:39 +0530)
committerKotresh HR <khiremat@redhat.com>
Tue, 4 Mar 2025 11:15:55 +0000 (16:45 +0530)
Add a function to fetch the inode from the metadata
pool. This is done by fetching the omap value from
the directory object and decode it to the in-memory
inode format using ceph-dencoder.

Fixes: https://tracker.ceph.com/issues/69339
Signed-off-by: Kotresh HR <khiremat@redhat.com>
qa/tasks/cephfs/filesystem.py

index 85eac792ca8e98cb50d8aae422ee58e0e841d7a3..3671ed06d13ab576f1c8be40fc3a17f2a26657c2 100644 (file)
@@ -1322,8 +1322,10 @@ class FilesystemBase(MDSClusterBase):
 
             status = self.status()
 
-    def dencoder(self, obj_type, obj_blob, skip=0):
+    def dencoder(self, obj_type, obj_blob, skip=0, stray_okay=False):
         args = [os.path.join(self._prefix, "ceph-dencoder"), 'type', obj_type]
+        if stray_okay:
+            args.extend(["stray_okay"])
         if skip != 0 :
             args.extend(["skip", str(skip)])
         args.extend(['import', '-', 'decode', 'dump_json'])
@@ -1545,6 +1547,24 @@ class FilesystemBase(MDSClusterBase):
         args = ["setxattr", obj_name, xattr_name, data]
         self.rados(args, pool=pool)
 
+    def read_meta_inode(self, dir_ino, file_name, pool=None):
+        """
+        Get decoded in-memory inode from the metadata pool
+        """
+        if pool is None:
+            pool = self.get_metadata_pool_name()
+
+        dirfrag_obj_name = "{0:x}.00000000".format(dir_ino)
+        args=["getomapval", dirfrag_obj_name, file_name+"_head", "-"]
+        try:
+            proc = self.rados(args, pool=pool, stdout=BytesIO())
+        except CommandFailedError as e:
+            log.error(e.__str__())
+            raise ObjectNotFound(dirfrag_obj_name)
+
+        obj_blob = proc.stdout.getvalue()
+        return json.loads(self.dencoder("inode_t<std::allocator>", obj_blob, 25, True).strip())
+
     def read_remote_inode(self, ino_no, pool=None):
         """
         Read the remote_inode xattr from the data pool, return a dict in the