]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: propagate an error back when failed to invalidating
authorsongweibin <song.weibin@zte.com.cn>
Tue, 24 Mar 2020 14:14:42 +0000 (22:14 +0800)
committerJason Dillaman <dillaman@redhat.com>
Mon, 20 Jul 2020 22:38:26 +0000 (18:38 -0400)
Signed-off-by: songweibin <song.weibin@zte.com.cn>
src/librbd/object_map/InvalidateRequest.h
src/librbd/object_map/Request.cc
src/test/librbd/object_map/test_mock_InvalidateRequest.cc
src/test/librbd/object_map/test_mock_SnapshotCreateRequest.cc

index 11c420372ace5d5f51ac3ca665e56013fd58f6a1..ce15bb2d337bb2c3a2ebe2a78778be9d3014bdd2 100644 (file)
@@ -31,10 +31,6 @@ public:
 
 protected:
   bool should_complete(int r) override;
-  int filter_return_code(int r) const override{
-    // never propagate an error back to the caller
-    return 0;
-  }
 
 private:
   uint64_t m_snap_id;
index 6677882eae54a8790179c17acfef095db3dfb8d4..1e1aab2ae5c03d6b3f55afa087274bb77850fbaf 100644 (file)
@@ -55,7 +55,7 @@ bool Request::invalidate() {
   bool flags_set;
   int r = m_image_ctx.test_flags(m_snap_id, RBD_FLAG_OBJECT_MAP_INVALID,
                                  &flags_set);
-  if (r == 0 && flags_set) {
+  if (r < 0 || flags_set) {
     return true;
   }
 
index 4867c4e2321e6bb9fc6884b1a789760a82678b22..5ea40c03d69511f01cb2157768322f663090f035 100644 (file)
@@ -33,12 +33,12 @@ TEST_F(TestMockObjectMapInvalidateRequest, UpdatesInMemoryFlag) {
   ASSERT_FALSE(flags_set);
 
   C_SaferCond cond_ctx;
-  AsyncRequest<> *request = new InvalidateRequest<>(*ictx, CEPH_NOSNAP, false, &cond_ctx);
+  AsyncRequest<> *request = new InvalidateRequest<>(*ictx, CEPH_NOSNAP, true, &cond_ctx);
 
   EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
               exec(ictx->header_oid, _, StrEq("rbd"), StrEq("set_flags"), _, _,
                    _, _))
-                .Times(0);
+                .WillOnce(DoDefault());
 
   {
     std::shared_lock owner_locker{ictx->owner_lock};
@@ -105,7 +105,7 @@ TEST_F(TestMockObjectMapInvalidateRequest, UpdatesSnapOnDiskFlag) {
   ASSERT_EQ(0, cond_ctx.wait());
 }
 
-TEST_F(TestMockObjectMapInvalidateRequest, SkipOnDiskUpdateWithoutLock) {
+TEST_F(TestMockObjectMapInvalidateRequest, ErrorOnDiskUpdateWithoutLock) {
   REQUIRE_FEATURE(RBD_FEATURE_OBJECT_MAP);
 
   librbd::ImageCtx *ictx;
@@ -124,12 +124,12 @@ TEST_F(TestMockObjectMapInvalidateRequest, SkipOnDiskUpdateWithoutLock) {
     std::unique_lock image_locker{ictx->image_lock};
     request->send();
   }
-  ASSERT_EQ(0, cond_ctx.wait());
+  ASSERT_EQ(-EROFS, cond_ctx.wait());
 
   expect_unlock_exclusive_lock(*ictx);
 }
 
-TEST_F(TestMockObjectMapInvalidateRequest, IgnoresOnDiskUpdateFailure) {
+TEST_F(TestMockObjectMapInvalidateRequest, ErrorOnDiskUpdateFailure) {
   REQUIRE_FEATURE(RBD_FEATURE_OBJECT_MAP);
 
   librbd::ImageCtx *ictx;
@@ -149,7 +149,7 @@ TEST_F(TestMockObjectMapInvalidateRequest, IgnoresOnDiskUpdateFailure) {
     std::unique_lock image_locker{ictx->image_lock};
     request->send();
   }
-  ASSERT_EQ(0, cond_ctx.wait());
+  ASSERT_EQ(-EINVAL, cond_ctx.wait());
 
   expect_unlock_exclusive_lock(*ictx);
 }
index ed3658c51eba7c138f29be87c72a78c1f431f959..b49f7419d5dc318f2aad9cf23450fc60d2dfe335 100644 (file)
@@ -134,7 +134,7 @@ TEST_F(TestMockObjectMapSnapshotCreateRequest, ReadMapError) {
     std::shared_lock image_locker{ictx->image_lock};
     request->send();
   }
-  ASSERT_EQ(0, cond_ctx.wait());
+  ASSERT_EQ(-ENOENT, cond_ctx.wait());
 
   expect_unlock_exclusive_lock(*ictx);
 }
@@ -162,7 +162,7 @@ TEST_F(TestMockObjectMapSnapshotCreateRequest, WriteMapError) {
     std::shared_lock image_locker{ictx->image_lock};
     request->send();
   }
-  ASSERT_EQ(0, cond_ctx.wait());
+  ASSERT_EQ(-ENOENT, cond_ctx.wait());
 
   expect_unlock_exclusive_lock(*ictx);
 }
@@ -191,7 +191,7 @@ TEST_F(TestMockObjectMapSnapshotCreateRequest, AddSnapshotError) {
     std::shared_lock image_locker{ictx->image_lock};
     request->send();
   }
-  ASSERT_EQ(0, cond_ctx.wait());
+  ASSERT_EQ(-ENOENT, cond_ctx.wait());
 
   expect_unlock_exclusive_lock(*ictx);
 }