]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: partial getattrs/gc checks
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 10 Jan 2016 23:32:54 +0000 (18:32 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:07:49 +0000 (12:07 -0500)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.h
src/test/librgw_file_nfsns.cc

index 44cee94088c6dfc020b45eab867007b1347259df..64b219bf29889ede9421c5f4a8d3cfd0db36b0eb 100644 (file)
@@ -272,6 +272,10 @@ namespace rgw {
 
     size_t get_size() const { return state.size; }
 
+    const char* stype() {
+      return is_dir() ? "DIR" : "FILE";
+    }
+
     uint16_t get_depth() const { return depth; }
 
     struct rgw_file_handle* get_fh() { return &fh; }
index eadace2a5adf68d2b6141e0607a140a7273f1270..3e15c0ab0150198f947b33c01ca51946777e5be5 100644 (file)
@@ -190,10 +190,6 @@ TEST(LibRGW, SETUP_HIER1)
   }
 }
 
-// create b2
-// create dirs in b2
-// create files in dirs in b2
-// do getattrs (check type and times)
 TEST(LibRGW, SETUP_DIRS1) {
   if (do_dirs1) {
     int rc;
@@ -327,6 +323,36 @@ TEST(LibRGW, BAD_DELETES_DIRS1) {
   }
 }
 
+TEST(LibRGW, RELEASE_DIRS1) {
+  if (do_dirs1) {
+    /* force release of handles for children of dirs1--force subsequent
+     * checks to reload them from the cluster.
+     *
+     * while doing this, verify handle cleanup and correct LRU state
+     * (not reachable)
+     */
+    int rc;
+    for (auto& dirs_rec : dirs_vec) {
+      for (auto& obj : get<1>(dirs_rec)) {
+       if (verbose) {
+         std::cout << "release " << obj.name
+                   << " type: " << obj.rgw_fh->stype()
+                   << " refs: " << obj.rgw_fh->get_refcnt()
+                   << std::endl;
+       }
+       ASSERT_EQ(obj.rgw_fh->get_refcnt(), 2);
+       rc = rgw_fh_rele(fs, obj.fh, 0 /* flags */);
+       ASSERT_EQ(rc, 0);
+       ASSERT_EQ(obj.rgw_fh->get_refcnt(), 1);
+       /* try-discard handle */
+       /* clear obj_rec vec */
+      }
+    }
+  }
+}
+
+// do getattrs (check type and times)
+
 extern "C" {
   static bool r1_cb(const char* name, void *arg, uint64_t offset) {
     struct rgw_file_handle* parent_fh