]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test: add test case for MDS privated inos accessing 40856/head
authorXiubo Li <xiubli@redhat.com>
Wed, 28 Apr 2021 01:32:24 +0000 (09:32 +0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Mon, 28 Jun 2021 19:18:48 +0000 (12:18 -0700)
Fixes: https://tracker.ceph.com/issues/50216
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 0ec4d781787df777bbfdeb742b394c73a0d76e08)

Conflicts:
src/test/libcephfs/test.cc: trivial conflict of mixed tests

src/test/libcephfs/test.cc

index cf673de1245a7dac63dbe8fe0a217ebfc2fd744b..1c28bb051b2e59ab6b0532e4ebc02ac16bb62296 100644 (file)
@@ -3508,6 +3508,30 @@ TEST(LibCephFS, SetMountTimeout) {
   ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
   ASSERT_EQ(0, ceph_set_mount_timeout(cmount, 5));
   ASSERT_EQ(ceph_mount(cmount, NULL), 0);
-
   ceph_shutdown(cmount);
 }
+
+TEST(LibCephFS, LookupMdsPrivateInos) {
+  struct ceph_mount_info *cmount;
+  ASSERT_EQ(ceph_create(&cmount, NULL), 0);
+  ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0);
+  ASSERT_EQ(0, ceph_conf_parse_env(cmount, NULL));
+  ASSERT_EQ(ceph_mount(cmount, NULL), 0);
+
+  Inode *inode;
+  for (int ino = 0; ino < MDS_INO_SYSTEM_BASE; ino++) {
+    if (MDS_IS_PRIVATE_INO(ino)) {
+      ASSERT_EQ(-ESTALE, ceph_ll_lookup_inode(cmount, ino, &inode));
+    } else if (ino == CEPH_INO_ROOT || ino == CEPH_INO_GLOBAL_SNAPREALM) {
+      ASSERT_EQ(0, ceph_ll_lookup_inode(cmount, ino, &inode));
+    } else if (ino == CEPH_INO_LOST_AND_FOUND) {
+      // the ino 3 will only exists after the recovery tool ran, so
+      // it may return -ESTALE with a fresh fs cluster
+      int r = ceph_ll_lookup_inode(cmount, ino, &inode);
+      ASSERT_TRUE(r == -ESTALE || r == 0);
+    } else {
+      // currently the ino 0 and 4~99 is not useded yet.
+      ASSERT_EQ(-ESTALE, ceph_ll_lookup_inode(cmount, ino, &inode));
+    }
+  }
+}