From abb2fa4d5bcba7ae7318c384cd10da348f68fd78 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 17 May 2018 19:36:42 -0700 Subject: [PATCH] qa: test for trim_caps segfault for trimmed dentries Test case by Yan Zheng [1]. [1] http://tracker.ceph.com/issues/24137#note-6 Signed-off-by: Patrick Donnelly --- qa/suites/fs/bugs/client_trim_caps/% | 0 qa/suites/fs/bugs/client_trim_caps/begin.yaml | 1 + .../clusters/small-cluster.yaml | 9 ++ .../objectstore/bluestore.yaml | 1 + .../fs/bugs/client_trim_caps/overrides/+ | 0 .../client_trim_caps/overrides/debug.yaml | 1 + .../overrides/frag_enable.yaml | 1 + .../overrides/no_client_pidfile.yaml | 1 + .../overrides/whitelist_health.yaml | 1 + .../whitelist_wrongly_marked_down.yaml | 1 + .../client_trim_caps/tasks/trim-i22073.yaml | 20 +++++ src/test/fs/CMakeLists.txt | 20 +++-- src/test/fs/test_trim_caps.cc | 83 +++++++++++++++++++ 13 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 qa/suites/fs/bugs/client_trim_caps/% create mode 120000 qa/suites/fs/bugs/client_trim_caps/begin.yaml create mode 100644 qa/suites/fs/bugs/client_trim_caps/clusters/small-cluster.yaml create mode 120000 qa/suites/fs/bugs/client_trim_caps/objectstore/bluestore.yaml create mode 100644 qa/suites/fs/bugs/client_trim_caps/overrides/+ create mode 120000 qa/suites/fs/bugs/client_trim_caps/overrides/debug.yaml create mode 120000 qa/suites/fs/bugs/client_trim_caps/overrides/frag_enable.yaml create mode 120000 qa/suites/fs/bugs/client_trim_caps/overrides/no_client_pidfile.yaml create mode 120000 qa/suites/fs/bugs/client_trim_caps/overrides/whitelist_health.yaml create mode 120000 qa/suites/fs/bugs/client_trim_caps/overrides/whitelist_wrongly_marked_down.yaml create mode 100644 qa/suites/fs/bugs/client_trim_caps/tasks/trim-i22073.yaml create mode 100644 src/test/fs/test_trim_caps.cc diff --git a/qa/suites/fs/bugs/client_trim_caps/% b/qa/suites/fs/bugs/client_trim_caps/% new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/qa/suites/fs/bugs/client_trim_caps/begin.yaml b/qa/suites/fs/bugs/client_trim_caps/begin.yaml new file mode 120000 index 0000000000000..3279455ceb085 --- /dev/null +++ b/qa/suites/fs/bugs/client_trim_caps/begin.yaml @@ -0,0 +1 @@ +../../../../cephfs/begin.yaml \ No newline at end of file diff --git a/qa/suites/fs/bugs/client_trim_caps/clusters/small-cluster.yaml b/qa/suites/fs/bugs/client_trim_caps/clusters/small-cluster.yaml new file mode 100644 index 0000000000000..12047bd7ac667 --- /dev/null +++ b/qa/suites/fs/bugs/client_trim_caps/clusters/small-cluster.yaml @@ -0,0 +1,9 @@ +roles: +- [mon.a, mgr.x, osd.0, osd.1, osd.2, mds.a, mds.b, client.0] +openstack: +- volumes: # attached to each instance + count: 2 + size: 10 # GB +log-rotate: + ceph-mds: 10G + ceph-osd: 10G diff --git a/qa/suites/fs/bugs/client_trim_caps/objectstore/bluestore.yaml b/qa/suites/fs/bugs/client_trim_caps/objectstore/bluestore.yaml new file mode 120000 index 0000000000000..1728accf9c80c --- /dev/null +++ b/qa/suites/fs/bugs/client_trim_caps/objectstore/bluestore.yaml @@ -0,0 +1 @@ +../../../../../cephfs/objectstore-ec/bluestore.yaml \ No newline at end of file diff --git a/qa/suites/fs/bugs/client_trim_caps/overrides/+ b/qa/suites/fs/bugs/client_trim_caps/overrides/+ new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/qa/suites/fs/bugs/client_trim_caps/overrides/debug.yaml b/qa/suites/fs/bugs/client_trim_caps/overrides/debug.yaml new file mode 120000 index 0000000000000..4fdb9dd1213c3 --- /dev/null +++ b/qa/suites/fs/bugs/client_trim_caps/overrides/debug.yaml @@ -0,0 +1 @@ +../../../../../cephfs/overrides/debug.yaml \ No newline at end of file diff --git a/qa/suites/fs/bugs/client_trim_caps/overrides/frag_enable.yaml b/qa/suites/fs/bugs/client_trim_caps/overrides/frag_enable.yaml new file mode 120000 index 0000000000000..9e0f15fc29ac9 --- /dev/null +++ b/qa/suites/fs/bugs/client_trim_caps/overrides/frag_enable.yaml @@ -0,0 +1 @@ +../../../../../cephfs/overrides/frag_enable.yaml \ No newline at end of file diff --git a/qa/suites/fs/bugs/client_trim_caps/overrides/no_client_pidfile.yaml b/qa/suites/fs/bugs/client_trim_caps/overrides/no_client_pidfile.yaml new file mode 120000 index 0000000000000..46263867b154b --- /dev/null +++ b/qa/suites/fs/bugs/client_trim_caps/overrides/no_client_pidfile.yaml @@ -0,0 +1 @@ +../../../../../overrides/no_client_pidfile.yaml \ No newline at end of file diff --git a/qa/suites/fs/bugs/client_trim_caps/overrides/whitelist_health.yaml b/qa/suites/fs/bugs/client_trim_caps/overrides/whitelist_health.yaml new file mode 120000 index 0000000000000..42fa3ea7a1fbe --- /dev/null +++ b/qa/suites/fs/bugs/client_trim_caps/overrides/whitelist_health.yaml @@ -0,0 +1 @@ +../../../../../cephfs/overrides/whitelist_health.yaml \ No newline at end of file diff --git a/qa/suites/fs/bugs/client_trim_caps/overrides/whitelist_wrongly_marked_down.yaml b/qa/suites/fs/bugs/client_trim_caps/overrides/whitelist_wrongly_marked_down.yaml new file mode 120000 index 0000000000000..3728aacfd15cf --- /dev/null +++ b/qa/suites/fs/bugs/client_trim_caps/overrides/whitelist_wrongly_marked_down.yaml @@ -0,0 +1 @@ +../../../../../cephfs/overrides/whitelist_wrongly_marked_down.yaml \ No newline at end of file diff --git a/qa/suites/fs/bugs/client_trim_caps/tasks/trim-i22073.yaml b/qa/suites/fs/bugs/client_trim_caps/tasks/trim-i22073.yaml new file mode 100644 index 0000000000000..410606225f031 --- /dev/null +++ b/qa/suites/fs/bugs/client_trim_caps/tasks/trim-i22073.yaml @@ -0,0 +1,20 @@ +# Note this test is unlikely to exercise the code as expected in the future: +# "It's too tricky to arrange inodes in session->caps. we don't know if it +# still works in the future." -Zheng + +overrides: + ceph: + log-whitelist: + - MDS cache is too large + - \(MDS_CACHE_OVERSIZED\) +tasks: +- exec: + mon.a: + - "ceph tell mds.* config set mds_max_ratio_caps_per_client 1" + - "ceph tell mds.* config set mds_min_caps_per_client 1" +- background_exec: + mon.a: + - "sleep 30 && ceph tell mds.* config set mds_cache_memory_limit 1" +- exec: + client.0: + - ceph_test_trim_caps diff --git a/src/test/fs/CMakeLists.txt b/src/test/fs/CMakeLists.txt index 2108843b4e0af..df47e74fff176 100644 --- a/src/test/fs/CMakeLists.txt +++ b/src/test/fs/CMakeLists.txt @@ -1,6 +1,16 @@ -# unittest_mds_types -add_executable(unittest_mds_types - mds_types.cc +if(${WITH_CEPHFS}) + + # unittest_mds_types + add_executable(unittest_mds_types + mds_types.cc + ) + add_ceph_unittest(unittest_mds_types) + target_link_libraries(unittest_mds_types global) + + add_executable(ceph_test_trim_caps + test_trim_caps.cc ) -add_ceph_unittest(unittest_mds_types) -target_link_libraries(unittest_mds_types global) + target_link_libraries(ceph_test_trim_caps ceph-common cephfs) + install(TARGETS ceph_test_trim_caps DESTINATION ${CMAKE_INSTALL_BINDIR}) + +endif(${WITH_CEPHFS}) diff --git a/src/test/fs/test_trim_caps.cc b/src/test/fs/test_trim_caps.cc new file mode 100644 index 0000000000000..a7fd8149238d3 --- /dev/null +++ b/src/test/fs/test_trim_caps.cc @@ -0,0 +1,83 @@ +#define _FILE_OFFSET_BITS 64 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + char buf; + int pipefd[2]; + int rc = pipe(pipefd); + assert(rc >= 0); + + pid_t pid = fork(); + assert(pid >= 0); + if (pid == 0) + close(pipefd[1]); + else + close(pipefd[0]); + + struct ceph_mount_info *cmount = NULL; + + ceph_create(&cmount, "admin"); + ceph_conf_read_file(cmount, NULL); + + int ret = ceph_mount(cmount, NULL); + assert(ret >= 0); + + if (pid == 0) { + ret = read(pipefd[0], &buf, 1); + assert(ret == 1); + + ret = ceph_rename(cmount, "1", "3"); + assert(ret >= 0); + + ret = ceph_rename(cmount, "2", "1"); + assert(ret >= 0); + + ceph_unmount(cmount); + printf("child exits\n"); + } else { + ret = ceph_mkdirs(cmount, "1/2", 0755); + assert(ret >= 0); + + struct ceph_statx stx; + ret = ceph_statx(cmount, "1", &stx, 0, 0); + assert(ret >= 0); + uint64_t orig_ino = stx.stx_ino; + + + ret = ceph_mkdir(cmount, "2", 0755); + assert(ret >= 0); + + ret = write(pipefd[1], &buf, 1); + assert(ret == 1); + + int wstatus; + ret = waitpid(pid, &wstatus, 0); + assert(ret >= 0); + assert(wstatus == 0); + + // make origin '1' no parent dentry + ret = ceph_statx(cmount, "1", &stx, 0, 0); + assert(ret >= 0); + assert(orig_ino != stx.stx_ino); + + // move root inode's cap_item to tail of session->caps + ret = ceph_statx(cmount, ".", &stx, 0, 0); + assert(ret >= 0); + + printf("waiting for crash\n"); + sleep(60); + } + return 0; +} -- 2.39.5