]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
src/test: test async I/O if the client is not mounted
authorDhairya Parmar <dparmar@redhat.com>
Wed, 6 Dec 2023 09:51:59 +0000 (15:21 +0530)
committerDhairya Parmar <dparmar@redhat.com>
Tue, 30 Jan 2024 09:20:57 +0000 (14:50 +0530)
Fixes: https://tracker.ceph.com/issues/63629
Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
src/test/client/nonblocking.cc

index 4b689dd868794d26a93c99bf12f1be16b2726b73..edb5c547396f669532029159216f42bc1fd5ee9e 100644 (file)
@@ -335,3 +335,63 @@ TEST_F(TestClient, LlreadvLlwritevReadOnlyFile) {
   client->ll_release(fh);
   ASSERT_EQ(0, client->ll_unlink(root, filename, myperm));
 }
+
+TEST_F(TestClient, LlreadvLlwritevIOClientNotMounted) {
+  /* Test that performing async I/O if the client is not mounted returns
+  ENOTCONN; callback is finished and thus the caller is not stalled .*/
+
+  int mypid = getpid();
+  char filename[256];
+
+  client->unmount();
+  TearDown();
+  SetUp();
+
+  sprintf(filename, "test_llreadvllwritevioclientnotmountedfile%u", mypid);
+
+  Inode *root, *file;
+  root = client->get_root();
+  ASSERT_NE(root, (Inode *)NULL);
+
+  Fh *fh;
+  struct ceph_statx stx;
+
+  ASSERT_EQ(0, client->ll_createx(root, filename, 0666,
+                                 O_RDWR | O_CREAT | O_TRUNC,
+                                 &file, &fh, &stx, 0, 0, myperm));
+
+  char out0[] = "hello ";
+  char out1[] = "world\n";
+  struct iovec iov_out[2] = {
+         {out0, sizeof(out0)},
+         {out1, sizeof(out1)},
+  };
+
+  char in0[sizeof(out0)];
+  char in1[sizeof(out1)];
+  struct iovec iov_in[2] = {
+         {in0, sizeof(in0)},
+         {in1, sizeof(in1)},
+  };
+
+  std::unique_ptr<C_SaferCond> writefinish = nullptr;
+  std::unique_ptr<C_SaferCond> readfinish = nullptr;
+
+  writefinish.reset(new C_SaferCond("test-nonblocking-writefinish-io-client-not-mounted"));
+  readfinish.reset(new C_SaferCond("test-nonblocking-readfinish-io-client-not-mounted"));
+
+  int64_t rc;
+  bufferlist bl;
+
+  ASSERT_EQ(client->ll_release(fh), 0);
+  client->unmount();
+  rc = client->ll_preadv_pwritev(fh, iov_out, 2, 0, true, writefinish.get(), nullptr);
+  ASSERT_EQ(rc, 0);
+  rc = writefinish->wait();
+  ASSERT_EQ(rc, -CEPHFS_ENOTCONN);
+
+  rc = client->ll_preadv_pwritev(fh, iov_in, 2, 0, false, readfinish.get(), &bl);
+  ASSERT_EQ(rc, 0);
+  rc = readfinish->wait();
+  ASSERT_EQ(rc, -CEPHFS_ENOTCONN);
+}