From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/test/fs/test_trim_caps.cc | 85 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/test/fs/test_trim_caps.cc (limited to 'src/test/fs/test_trim_caps.cc') diff --git a/src/test/fs/test_trim_caps.cc b/src/test/fs/test_trim_caps.cc new file mode 100644 index 00000000..11acabb0 --- /dev/null +++ b/src/test/fs/test_trim_caps.cc @@ -0,0 +1,85 @@ +#define _FILE_OFFSET_BITS 64 +#if defined(__linux__) +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + char buf; + int pipefd[2]; + int rc [[maybe_unused]] = 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 [[maybe_unused]] = 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 [[maybe_unused]] = 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; +} -- cgit v1.2.3