From: Matt Benjamin Date: Fri, 11 Dec 2015 21:19:57 +0000 (-0500) Subject: librgw: fix last enumeration bug, move tracing to debug X-Git-Tag: v10.1.0~382^2~112 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=57938d8c7d85b6fa9332f4cf85f6965a7ff48f28;p=ceph.git librgw: fix last enumeration bug, move tracing to debug 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 --- diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index de20e8c55f46..46e0231c8c4d 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -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; diff --git a/src/test/librgw_file_nfsns.cc b/src/test/librgw_file_nfsns.cc index bc1744fd5782..2c65bc496612 100644 --- a/src/test/librgw_file_nfsns.cc +++ b/src/test/librgw_file_nfsns.cc @@ -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(fs->fs_private)->get_context(); } extern "C" { @@ -103,11 +106,11 @@ extern "C" { struct rgw_file_handle* parent_fh = static_cast(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);