From 59f8487b071650f043bbebcce49384e292269a05 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Mon, 29 Sep 2025 06:44:28 +0000 Subject: [PATCH] test/libcephfs: add test for fsync on a write delegated inode Signed-off-by: Venky Shankar --- src/test/libcephfs/deleg.cc | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/test/libcephfs/deleg.cc b/src/test/libcephfs/deleg.cc index 6fb02284665..05e837ff02a 100644 --- a/src/test/libcephfs/deleg.cc +++ b/src/test/libcephfs/deleg.cc @@ -408,3 +408,42 @@ TEST(LibCephFS, RecalledGetattr) { ceph_unmount(cmount1); ceph_release(cmount1); } + +TEST(LibCephFS, DelegTestWithWrite) { + struct ceph_mount_info *cmount1; + ASSERT_EQ(ceph_create(&cmount1, NULL), 0); + ASSERT_EQ(ceph_conf_read_file(cmount1, NULL), 0); + ASSERT_EQ(0, ceph_conf_parse_env(cmount1, NULL)); + ASSERT_EQ(0, ceph_conf_set(cmount1, "client_oc", "0")); + ASSERT_EQ(ceph_mount(cmount1, "/"), 0); + ASSERT_EQ(set_default_deleg_timeout(cmount1), 0); + + Inode *root, *file; + ASSERT_EQ(ceph_ll_lookup_root(cmount1, &root), 0); + + char filename[32]; + sprintf(filename, "delegtestwrite%x", getpid()); + + Fh *fh; + struct ceph_statx stx; + UserPerm *perms = ceph_mount_perms(cmount1); + + ASSERT_EQ(ceph_ll_create(cmount1, root, filename, 0666, + O_RDWR|O_CREAT|O_EXCL, &file, &fh, &stx, 0, 0, perms), 0); + ASSERT_EQ(ceph_ll_write(cmount1, fh, 0, sizeof(filename), filename), + static_cast(sizeof(filename))); + ASSERT_EQ(ceph_ll_close(cmount1, fh), 0); + + std::atomic_bool recalled(false); + ASSERT_EQ(ceph_ll_lookup(cmount1, root, filename, &file, &stx, 0, 0, perms), 0); + ASSERT_EQ(ceph_ll_open(cmount1, file, O_WRONLY, &fh, perms), 0); + ASSERT_EQ(ceph_ll_delegation_wait(cmount1, fh, CEPH_DELEGATION_WR, dummy_deleg_cb, &recalled), 0); + ASSERT_EQ(ceph_ll_write(cmount1, fh, 0, sizeof(filename), filename), + static_cast(sizeof(filename))); + ASSERT_EQ(0, ceph_ll_fsync(cmount1, fh, false)); + ASSERT_EQ(ceph_ll_close(cmount1, fh), 0); + ASSERT_EQ(0, ceph_ll_unlink(cmount1, root, filename, perms)); + + ceph_unmount(cmount1); + ceph_release(cmount1); +} -- 2.39.5