Skip to content

tentacle: test/libcephfs: validate asynchronous write and fsync executing concurrently - #65648

Merged
batrick merged 5 commits into
ceph:tentaclefrom
vshankar:wip-72931-tentacle
Sep 1, 2026
Merged

batrick merged 5 commits into
ceph:tentaclefrom
vshankar:wip-72931-tentacle

Conversation

@vshankar

Copy link
Copy Markdown
Contributor

@vshankar vshankar added this to the tentacle milestone Sep 24, 2025
@vshankar vshankar added the cephfs Ceph File System label Sep 24, 2025
@joscollin

Copy link
Copy Markdown
Member

jenkins test make check

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@joscollin

Copy link
Copy Markdown
Member

@vshankar Please resolve the conflicts

@joscollin

Copy link
Copy Markdown
Member

@vshankar ping

@vshankar

vshankar commented Sep 25, 2025 •

Copy link
Copy Markdown
Contributor Author

@vshankar ping

@joscollin -- give me sometime. Switching branches frequently in mid-dev cycle is a bit of a pain for me.

@joscollin

Copy link
Copy Markdown
Member

@vshankar ping

@joscollin -- give me sometime. Switching branches frequently in mid-dev cycle is a bit of a pain for me.

You don't have to checkout branches for doing this.

@vshankar

vshankar commented Oct 1, 2025

Copy link
Copy Markdown
Contributor Author

@vshankar ping

@joscollin -- give me sometime. Switching branches frequently in mid-dev cycle is a bit of a pain for me.

You don't have to checkout branches for doing this.

I know I can use a git worktree but that's not the point. I have to get others things out released and this is just a test case change that I didn't want to prioritize getting tested.

Signed-off-by: Venky Shankar <[email protected]>
(cherry picked from commit f29c63e)
To allow the client to hold Fb caps for an extended period of
time, to allow an asynchronous fsync to intervene and block, so
as to hunt [0].

[0]: https://tracker.ceph.com/issues/71510

Signed-off-by: Venky Shankar <[email protected]>
(cherry picked from commit 7ab995b)
With the prior commit that introduces a synthetic delay in write
operation so as to write a test reproducer which would interleave
asynchronous fsync and an operation that makes the MDS send a early
reply to the client (therefore, having the client track the early
replied response for an inode in Inode::unsafe_ops). Now, this is
enough to trick the client into the code path that causes a buggy
reference drop for the request (MetaRequest), but, hitting the
_exact_ crash backtrace requires the request to be a in various
[x]list's.

This last bit is tricky to synthetically massage in the test. So,
in order to catch the buggy reference drop, it would suffice to
assert on the reference count dropping to less than zero (0).

Signed-off-by: Venky Shankar <[email protected]>
(cherry picked from commit 3254208)
…rrently

This synthetic reproducer does three things:

- setup a client mount with a configuration to delay write operations and
  initiates a write operation via a thread.
- a thread that invokes asynchronous fsync
- a thread that invokes setxattr for the client to track early replies

Without the fix[0], the test reproduces the following crash:

```
/home/vshankar/ceph/src/client/Client.cc: In function 'void Client::put_request(MetaRequest*)' thread 7f7210ff9640 time 2025-06-03T09:34:45.634974+0000
/home/vshankar/ceph/src/client/Client.cc: 2290: FAILED ceph_assert(request->ref >= 1)
 ceph version 20.3.0-673-gdd152807f7e (dd152807f7e7f7a82df6cfc0159f5fc65f60ecd5) tentacle (dev - Debug)
 1: (ceph::__ceph_assert_fail(char const*, char const*, int, char const*)+0x119) [0x7f72222ebb98]
 2: (ceph::__ceph_assert_fail(ceph::assert_data const&)+0x17) [0x7f72222ebedc]
 3: /home/vshankar/ceph/build/lib/libcephfs.so.2(+0x6a075) [0x7f7222e6a075]
 4: /home/vshankar/ceph/build/lib/libcephfs.so.2(+0xb8289) [0x7f7222eb8289]
 5: /home/vshankar/ceph/build/lib/libcephfs.so.2(+0xee951) [0x7f7222eee951]
 6: /home/vshankar/ceph/build/lib/libcephfs.so.2(+0xf167c) [0x7f7222ef167c]
 7: (Context::complete(int)+0x9) [0x7f7222e5949d]
 8: /home/vshankar/ceph/build/lib/libcephfs.so.2(+0x16a853) [0x7f7222f6a853]
 9: /home/vshankar/ceph/build/lib/libcephfs.so.2(+0xa7cc5) [0x7f7222ea7cc5]
 10: /home/vshankar/ceph/build/lib/libcephfs.so.2(+0xf128d) [0x7f7222ef128d]
 11: /home/vshankar/ceph/build/lib/libcephfs.so.2(+0x16e09d) [0x7f7222f6e09d]
 12: (Context::complete(int)+0x9) [0x7f7222e5949d]
 13: /home/vshankar/ceph/build/lib/libcephfs.so.2(+0x6d108) [0x7f7222e6d108]
 14: (Context::complete(int)+0x9) [0x7f7222e5949d]
 15: (Finisher::finisher_thread_entry()+0x665) [0x7f722226fdc1]
 16: (Finisher::FinisherThread::entry()+0xd) [0x7f7222270ddf]
 17: (Thread::entry_wrapper()+0x2f) [0x7f72222b88f5]
 18: (Thread::_entry_func(void*)+0x9) [0x7f72222b8907]
 19: /lib64/libc.so.6(+0x89e92) [0x7f7221089e92]
 20: /lib64/libc.so.6(+0x10ef20) [0x7f722110ef20]
[1]    2162689 IOT instruction (core dumped)  ./bin/ceph_test_libcephfs --gtest_filter=LibCephFS.ConcurrentWriteAndFsync
```

[0]: ceph#63619

Fixes: http://tracker.ceph.com/issues/71515
Signed-off-by: Venky Shankar <[email protected]>
(cherry picked from commit e2fe5f1)

 Conflicts:
	src/test/libcephfs/test.cc

Adjust for missing tests in tentacle branch.
@vshankar

Copy link
Copy Markdown
Contributor Author

@vshankar Please resolve the conflicts

Done.

@joscollin

Copy link
Copy Markdown
Member

@batrick batrick modified the milestones: tentacle, v20.2.2 Apr 28, 2026
@batrick batrick added releng-audit-queue Release engineering: queued for backport verification audit. and removed pdonnell-tentacle-RFA releng-audit-queue Release engineering: queued for backport verification audit. labels Apr 28, 2026
@batrick batrick removed the releng-audit-pass Release engineering: passed backport verification audit. label May 15, 2026
github-actions[bot]

This comment was marked as outdated.

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label May 15, 2026
@batrick batrick added the releng-audit-queue Release engineering: queued for backport verification audit. label Jul 13, 2026
@github-actions github-actions Bot removed releng-audit-queue Release engineering: queued for backport verification audit. releng-audit-fail Release engineering: failed backport verification audit. labels Jul 13, 2026
github-actions[bot]

This comment was marked as outdated.

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label Jul 13, 2026
@github-actions github-actions Bot removed the releng-audit-fail Release engineering: failed backport verification audit. label Jul 17, 2026
@github-actions

Copy link
Copy Markdown

✅ Audit Override Applied by @batrick.

View workflow run

@batrick batrick added the releng-audit-queue Release engineering: queued for backport verification audit. label Jul 21, 2026
@github-actions github-actions Bot removed releng-audit-queue Release engineering: queued for backport verification audit. releng-audit-override labels Jul 21, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ceph Release Engineering Audit Report

Commit Parity Visualizer

BACKPORT PR #65648 SOURCE PR SOURCE STATUS
7aa8801 libcephfs/client: asynchronous fsync interface PR #63636 c88a21c libcephfs/client: asynchronous fsync interface
14d47b7 client: log unsafe operation count (for debugging) f29c63e client: log unsafe operation count (for debugging)
fb91f03 client: synthetically delay write operation 7ab995b client: synthetically delay write operation
d3faf79 client: catch buggy reference count drop for MetaRequest 3254208 client: catch buggy reference count drop for MetaRequest
563219f test/libcephfs: validate asynchronous write and fsync executing concurrently e2fe5f1 test/libcephfs: validate asynchronous write and fsync executing concurrently

Automated Backport Parity Review - Cherry-Pick Conflicts / Deviations

⚠️ WARNING: Cherry-pick conflicts or deviations were found that require component lead review.

A conflict or deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.

This does not necessarily indicate an issue but a maintainer should review.

**Click to expand conflict summaries.**

Deviation in Backport 563219f (cherry-pick of e2fe5f1)

Affected File(s)

Range Diff

Click to expand
--- Original (e2fe5f17)
+++ Backport (563219f0)
@@ -40,3 +40,9 @@
 
 Fixes: http://tracker.ceph.com/issues/71515
 Signed-off-by: Venky Shankar <[email protected]>
+(cherry picked from commit e2fe5f1719897c78565e12c748ab08c57a327016)
+
+ Conflicts:
+	src/test/libcephfs/test.cc
+
+Adjust for missing tests in tentacle branch.

================================================================================
RANGE DIFF
================================================================================

1:  e2fe5f17198 ! 1:  563219f09ff test/libcephfs: validate asynchronous write and fsync executing concurrently
    @@ Commit message
     
         Fixes: http://tracker.ceph.com/issues/71515
         Signed-off-by: Venky Shankar <[email protected]>
    +    (cherry picked from commit e2fe5f1719897c78565e12c748ab08c57a327016)
    +
    +     Conflicts:
    +            src/test/libcephfs/test.cc
    +
    +    Adjust for missing tests in tentacle branch.
     
      ## src/test/libcephfs/test.cc ##
    -@@ src/test/libcephfs/test.cc: TEST(LibCephFS, InodeGetPut) {
    +@@ src/test/libcephfs/test.cc: TEST(LibCephFS, SubdirLookupAfterReaddir_ll) {
      }
      
      static bool write_done = false;
    @@ src/test/libcephfs/test.cc: TEST(LibCephFS, InodeGetPut) {
      static bool read_done = false;
      static std::mutex mtx;
      static std::condition_variable cond;
    -@@ src/test/libcephfs/test.cc: TEST(LibCephFS, UnmountHangAfterOpenatFilePath) {
    - 
    -   ASSERT_EQ(0, ceph_release(cmount));
    +@@ src/test/libcephfs/test.cc: TEST(LibCephFS, AsyncReadAndWriteMultiClient) {
    +   ceph_shutdown(r_cmount);
      }
    -+
    + 
    +-TEST(LibCephFS, UmountHangAfterLlLookupFilePath) {
    +-  struct ceph_statx stx;
    +-  struct ceph_mount_info *cmount;
    +-  UserPerm *perms;
    +-  Inode *root, *file, *tmp;
    +-  Fh *fh;
    +-
    +-  int mypid = getpid();
    +-  char filename[NAME_MAX];
    +-
    +-  sprintf(filename, "test_umounthangafterlookup%u", mypid);
    +-
    +-  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(0, ceph_mount(cmount, NULL));
    +-
    +-  perms = ceph_userperm_new(0, 0, 0, NULL);
     +void write_fsync_io_callback(struct ceph_ll_io_info *io_info) {
     +  std::unique_lock lock(mtx);
     +  if (io_info->write) {
    @@ src/test/libcephfs/test.cc: TEST(LibCephFS, UnmountHangAfterOpenatFilePath) {
     +  }
     +  cond.notify_one();
     +}
    -+
    + 
    +-  ASSERT_EQ(ceph_ll_lookup_root(cmount, &root), 0);
     +static void writer_func(struct ceph_mount_info *cmount, Fh *fh) {
     +  int iterations = 2;
     +  uint8_t buf[131072];
     +  struct ceph_ll_io_info io_info;
     +  struct iovec iov;
    -+
    + 
    +-  ASSERT_EQ(ceph_ll_create(cmount, root, filename, 0777,
    +-                 O_CREAT | O_TRUNC | O_RDWR, &file, &fh, &stx,
    +-                 CEPH_STATX_INO, 0, perms), 0);
    +-  ASSERT_EQ(ceph_ll_close(cmount, fh), 0);
     +  io_info.callback = write_fsync_io_callback;
     +  io_info.iov = &iov;
     +  io_info.iovcnt = 1;
    @@ src/test/libcephfs/test.cc: TEST(LibCephFS, UnmountHangAfterOpenatFilePath) {
     +    ASSERT_EQ(io_info.result, sizeof(buf));
     +  }
     +}
    -+
    + 
    +-  ASSERT_EQ(ceph_ll_lookup(cmount, file, ".", &tmp, &stx, CEPH_STATX_INO,
    +-            0 , perms), -ENOTDIR);
     +static void fsync_func(struct ceph_mount_info *cmount, Inode *in) {
     +  int iterations = 1000;
     +  struct ceph_ll_io_info io_info;
    -+
    + 
    +-  ASSERT_EQ(ceph_ll_unlink(cmount, root, filename, perms), 0);
     +  io_info.callback = write_fsync_io_callback;
     +
     +  std::cout << ": fsync thread sleeping" << std::endl;
    @@ src/test/libcephfs/test.cc: TEST(LibCephFS, UnmountHangAfterOpenatFilePath) {
     +    std::cout << ": fsync finished" << std::endl;
     +  }
     +}
    -+
    + 
    +-  ceph_ll_put(cmount, file);
    +-  ceph_ll_put(cmount, root);
     +static void do_unsafe_ops(struct ceph_mount_info *cmount, std::string path) {
     +  int iterations = 200;
    -+
    + 
    +-  std::cout << "Before ceph_unmount()" << std::endl;
    +-  ASSERT_EQ(0, ceph_unmount(cmount));
    +-  std::cout << "After ceph_unmount()" << std::endl;
     +  std::cout << ": setxattr thread sleeping" << std::endl;
     +  sleep(2);
     +  std::cout << ": setxattr thread wokeup" << std::endl;
    -+
    + 
    +-  ceph_release(cmount);
    +-  ceph_userperm_destroy(perms);
     +  while (--iterations > 0) {
     +    ASSERT_EQ(0, ceph_setxattr(cmount, path.c_str(), "user.key1", "value1", 6, 0));
     +    sleep(1);
     +  }
    -+}
    -+
    + }
    + 
    +-TEST(LibCephFS, UnmountHangAfterOpenatFilePath) {
     +TEST(LibCephFS, ConcurrentWriteAndFsync) {
    -+  pid_t mypid = getpid();
    -+  struct ceph_mount_info *cmount;
    +   pid_t mypid = getpid();
    +   struct ceph_mount_info *cmount;
    +-  ASSERT_EQ(ceph_create(&cmount, NULL), 0);
    +-  ASSERT_EQ(ceph_conf_read_file(cmount, NULL), 0);
    +-  ASSERT_EQ(ceph_conf_parse_env(cmount, NULL), 0);
    +-  ASSERT_EQ(ceph_mount(cmount, "/"), 0);
     +  UserPerm *perms = NULL;
     +  Inode *parent, *inode = NULL;
     +  struct ceph_statx stx = {0};
     +  struct Fh *fh;
     +  char filename[PATH_MAX];
    -+
    + 
    +-  char c_rel_dir[64];
    +-  char c_dir[128];
    +-  sprintf(c_rel_dir, "open_test_%d", mypid);
    +-  sprintf(c_dir, "/%s", c_rel_dir);
    +-  ASSERT_EQ(ceph_mkdir(cmount, c_dir, 0777), 0);
     +  // for now use a single thread for performing write and fsync (each).
     +  // in the future if we need to increase operation concurrency adjust
     +  // @nthreads as required.
     +  const int nthreads = 2;
     +  std::thread unsafe_ops;
     +  std::thread threads[nthreads];
    -+
    + 
    +-  int root_fd = ceph_open(cmount, "/", O_DIRECTORY, 0777);
    +-  ASSERT_GT(root_fd, 0);
     +  sprintf(filename, "/contest_%d", mypid);
    -+
    + 
    +-  int dir_fd = ceph_openat(cmount, root_fd, c_rel_dir, O_DIRECTORY, 0777);
    +-  ASSERT_GT(dir_fd, 0);
     +  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(0, ceph_conf_set(cmount, "client_oc", "0"));
     +  ASSERT_EQ(0, ceph_conf_set(cmount, "client_inject_write_delay_secs", "10"));
     +  ASSERT_EQ(0, ceph_mount(cmount, NULL));
    -+
    + 
    +-  struct ceph_statx stx;
    +-  ASSERT_EQ(ceph_statxat(cmount, root_fd, c_rel_dir, &stx, 0, 0), 0);
     +  perms = ceph_mount_perms(cmount);
     +  ASSERT_EQ(ceph_ll_lookup_root(cmount, &parent), 0);
    -+
    + 
    +-  char c_rel_path[PATH_MAX];
    +-  char c_path[PATH_MAX];
    +-  sprintf(c_rel_path, "created_file_%d", mypid);
    +-  sprintf(c_path, "%s/%s", c_dir, c_rel_path);
    +-  int file_fd = ceph_openat(cmount, dir_fd, c_rel_path, O_RDONLY | O_CREAT, 0777);
    +-  ASSERT_GT(file_fd, 0);
    +-  int fd = ceph_openat(cmount, file_fd, ".", O_RDONLY, 0777);
    +-  ASSERT_EQ(fd, -ENOTDIR);
     +  ASSERT_EQ(ceph_ll_create(cmount, parent, filename, 0744,
     +                           O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW,
     +                           &inode, &fh, &stx, CEPH_STATX_INO, 0, perms), 0);
    -+
    + 
    +-  ASSERT_EQ(ceph_close(cmount, file_fd), 0);
    +-  ASSERT_EQ(ceph_close(cmount, dir_fd), 0);
    +-  ASSERT_EQ(ceph_close(cmount, root_fd), 0);
     +  unsafe_ops = std::thread(do_unsafe_ops, cmount, std::string(filename));
    -+
    + 
    +-  ASSERT_EQ(0, ceph_unlink(cmount, c_path));
    +-  ASSERT_EQ(0, ceph_rmdir(cmount, c_dir));
     +  for (int i = 0; i < nthreads/2; ++i) {
     +    threads[i] = std::thread(writer_func, cmount, fh);
     +  }
     +  for (int i = 1; i < nthreads; ++i) {
     +    threads[i] = std::thread(fsync_func, cmount, inode);
     +  }
    -+
    + 
    +-  std::cout << "Before ceph_unmount()" << std::endl;
    +-  ASSERT_EQ(0, ceph_unmount(cmount));
    +-  std::cout << "After ceph_unmount()" << std::endl;
     +  for (int i = 0; i < nthreads; ++i) {
     +    threads[i].join();
     +  }
     +  unsafe_ops.join();
    -+
    + 
    +-  ASSERT_EQ(0, ceph_release(cmount));
     +  ASSERT_EQ(0, ceph_unmount(cmount));
     +  ceph_shutdown(cmount);
    -+}
    + }

How to proceed:

  • Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git Conflicts: block intact) and include an explanation for changes.
  • Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
  • Component Leads (Review): Please review the Range Diff(s) above to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting /audit override.

Be familiar with the rules and guidelines for writing backports.


🛟 Need Help?

If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.

📋 Component Lead / Release Manager

To override the audit failure, apply releng-audit-override label or comment /audit override.


⚠️ Note: Automated audit checks will be suspended on future pushes to prevent comment spam while you work.

When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.

View workflow run

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label Jul 21, 2026
@batrick batrick modified the milestones: v20.2.3, v20.2.4 Jul 23, 2026
@yuriw

yuriw commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-yuri9-testing-20260831.150649-tentacle.

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vshankar

vshankar commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

/audit override

@github-actions github-actions Bot added releng-audit-override and removed releng-audit-fail Release engineering: failed backport verification audit. labels Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

✅ Audit Override Applied by @vshankar.

View workflow run

@vshankar

vshankar commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed-by: Venky Shankar [email protected]

@batrick batrick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@batrick
batrick merged commit 677f1fb into ceph:tentacle Sep 1, 2026
3 of 6 checks passed
@NitzanMordhai

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants