]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: fix last enumeration bug, move tracing to debug
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 11 Dec 2015 21:19:57 +0000 (16:19 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:06:36 +0000 (12:06 -0500)
The last issue with enumeration was caused by inserting objects
into handle cache with their key-ified full_object_name()--this
should be the base name.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.h
src/test/librgw_file_nfsns.cc

index de20e8c55f464cd8abb0b5baa0d05606f4a7c40f..46e0231c8c4dd242e7dc5cca833471b7f0287433 100644 (file)
@@ -512,11 +512,12 @@ namespace rgw {
     /* find or create an RGWFileHandle */
     LookupFHResult lookup_fh(RGWFileHandle* parent, const char *name,
                             const uint32_t cflags = RGWFileHandle::FLAG_NONE) {
-
       using std::get;
 
       RGWFileHandle::FHCache::Latch lat;
+      std::string obj_name{name};
       std::string key_name{parent->make_key_name(name)};
+
       fh_key fhk = parent->make_fhk(key_name);
       LookupFHResult fhr { nullptr, RGWFileHandle::FLAG_NONE };
 
@@ -527,7 +528,7 @@ namespace rgw {
       /* LATCHED */
       if (! fh) {
        if (cflags & RGWFileHandle::FLAG_CREATE) {
-         fh = new RGWFileHandle(this, get_inst(), parent, fhk, key_name,
+         fh = new RGWFileHandle(this, get_inst(), parent, fhk, obj_name,
                                 cflags);
          intrusive_ptr_add_ref(fh); /* sentinel ref */
          fh_cache.insert_latched(fh, lat,
@@ -790,13 +791,15 @@ public:
        * empty directory */
       if (sref=="")
        continue;
-       
-      std::cout << "RGWListBucketRequest "
-               << __func__ << " " << "list uri=" << s->relative_uri << " "
-               << " prefix=" << prefix << " "
-               << " obj path=" << iter.key.name
-               << " (" << sref << ")" << ""
-               << std::endl;
+
+      lsubdout(cct, rgw, 15) << "RGWListBucketRequest "
+                            << __func__ << " "
+                            << "list uri=" << s->relative_uri << " "
+                            << " prefix=" << prefix << " "
+                            << " obj path=" << iter.key.name
+                            << " (" << sref << ")" << ""
+                            << dendl;
+
       /* call me maybe */
       this->operator()(sref.data(), sref.data(),
                       (ix == size-1) ? true : false);
@@ -814,11 +817,13 @@ public:
       else
        sref = boost::string_ref{iter.first};
 
-      std::cout << "RGWListBucketRequest "
-               << __func__ << " " << "list uri=" << s->relative_uri << " "
-               << " prefix=" << prefix << " "
-               << " cpref=" << sref << " (not chomped)"
-               << std::endl;
+      lsubdout(cct, rgw, 15) << "RGWListBucketRequest "
+                            << __func__ << " "
+                            << "list uri=" << s->relative_uri << " "
+                            << " prefix=" << prefix << " "
+                            << " cpref=" << sref
+                            << dendl;
+
       this->operator()(sref.data(), sref.data(), (ix == size-1) ? true : false);
       ++ix;
     }
@@ -1399,11 +1404,12 @@ public:
     // try objects
     for (const auto& iter : objs) {
       auto& name = iter.key.name;
-      std::cout << "RGWStatLeafRequest "
-               << __func__ << " " << "list uri=" << s->relative_uri << " "
-               << " prefix=" << prefix << " "
-               << " obj path=" << name << ""
-               << std::endl;
+      lsubdout(cct, rgw, 15) << "RGWStatLeafRequest "
+                            << __func__ << " "
+                            << "list uri=" << s->relative_uri << " "
+                            << " prefix=" << prefix << " "
+                            << " obj path=" << name << ""
+                            << dendl;
       /* XXX is there a missing match-dir case (trailing '/')? */
       matched = true;
       return;
@@ -1411,11 +1417,12 @@ public:
     // try prefixes
     for (auto& iter : common_prefixes) {
       auto& name = iter.first;
-      std::cout << "RGWStatLeafRequest "
-               << __func__ << " " << "list uri=" << s->relative_uri << " "
-               << " prefix=" << prefix << " "
-               << " pref path=" << name << " (not chomped)"
-               << std::endl;
+      lsubdout(cct, rgw, 15) << "RGWStatLeafRequest "
+                            << __func__ << " "
+                            << "list uri=" << s->relative_uri << " "
+                            << " prefix=" << prefix << " "
+                            << " pref path=" << name << " (not chomped)"
+                            << dendl;
       matched = true;
       is_dir = true;
       break;
index bc1744fd57822eaa9d4534cddae5664bf7627f82..2c65bc49661208d13c92c4ff62f82164b4108400 100644 (file)
@@ -25,6 +25,7 @@
 #include "common/ceph_argparse.h"
 #include "common/debug.h"
 #include "global/global_init.h"
+#include "include/assert.h"
 
 #define dout_subsys ceph_subsys_rgw
 
@@ -39,6 +40,7 @@ namespace {
   string access_key("");
   string secret_key("");
   struct rgw_fs *fs = nullptr;
+  CephContext* cct = nullptr;
 
   string bucket_name = "nfsroot";
 
@@ -69,8 +71,7 @@ namespace {
     if (rgw_fh) {
       const char* type = rgw_fh->is_dir() ? "DIR " : "FILE ";
       os << rec.rgw_fh->full_object_name()
-        << " (" << rec.rgw_fh->object_name() << ", "
-        << " " << rec.name << "): "
+        << " (" << rec.rgw_fh->object_name() << "): "
         << type;
     }
     return os;
@@ -96,6 +97,8 @@ TEST(LibRGW, MOUNT) {
                      secret_key.c_str(), &fs);
   ASSERT_EQ(ret, 0);
   ASSERT_NE(fs, nullptr);
+
+  cct = static_cast<RGWLibFS*>(fs->fs_private)->get_context();
 }
 
 extern "C" {
@@ -103,11 +106,11 @@ extern "C" {
     struct rgw_file_handle* parent_fh
       = static_cast<struct rgw_file_handle*>(arg);
     RGWFileHandle* rgw_fh = get_rgwfh(parent_fh);
-    std::cout << __func__
-             << " bucket=" << rgw_fh->bucket_name()
-             << " dir=" << rgw_fh->full_object_name()
-             << " called back name=" << name
-             << std::endl;
+    lsubdout(cct, rgw, 10) << __func__
+                          << " bucket=" << rgw_fh->bucket_name()
+                          << " dir=" << rgw_fh->full_object_name()
+                          << " called back name=" << name
+                          << dendl;
     obj_stack.push(
       obj_rec{name, nullptr, parent_fh, nullptr});
     return true; /* XXX */
@@ -123,9 +126,27 @@ TEST(LibRGW, ENUMERATE1) {
     if (! elt.fh) {
       struct rgw_file_handle* parent_fh = elt.parent_fh
        ? elt.parent_fh : fs->root_fh;
+      RGWFileHandle* pfh = get_rgwfh(parent_fh);
+      rgw::ignore(pfh);
+      lsubdout(cct, rgw, 10)
+       << "rgw_lookup:"
+       << " parent object_name()=" << pfh->object_name()
+       << " parent full_object_name()=" << pfh->full_object_name()
+       << " elt.name=" << elt.name
+       << dendl;
       rc = rgw_lookup(fs, parent_fh, elt.name.c_str(), &elt.fh,
                      RGW_LOOKUP_FLAG_NONE);
       ASSERT_EQ(rc, 0);
+      // XXXX
+      RGWFileHandle* efh = get_rgwfh(elt.fh);
+      rgw::ignore(efh);
+      lsubdout(cct, rgw, 10)
+       << "rgw_lookup result:"
+       << " elt object_name()=" << efh->object_name()
+       << " elt full_object_name()=" << efh->full_object_name()
+       << " elt.name=" << elt.name
+       << dendl;
+
       ASSERT_NE(elt.fh, nullptr);
       elt.rgw_fh = get_rgwfh(elt.fh);
       elt.parent_fh = elt.rgw_fh->get_parent()->get_fh();
@@ -139,11 +160,12 @@ TEST(LibRGW, ENUMERATE1) {
          // descending
          uint64_t offset;
          bool eof; // XXX
-         std::cout << "readdir in"
-                   << " bucket: " << elt.rgw_fh->bucket_name()
-                   << " object_name: " << elt.rgw_fh->object_name()
-                   << " full_name: " << elt.rgw_fh->full_object_name()
-                   << std::endl;
+         lsubdout(cct, rgw, 10)
+           << "readdir in"
+           << " bucket: " << elt.rgw_fh->bucket_name()
+           << " object_name: " << elt.rgw_fh->object_name()
+           << " full_name: " << elt.rgw_fh->full_object_name()
+           << dendl;
          rc = rgw_readdir(fs, elt.fh, &offset, r1_cb, elt.fh, &eof);
          elt.state.readdir = true;
          ASSERT_EQ(rc, 0);