]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: add diagnostic dump_buckets() call.
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 6 Nov 2015 21:55:57 +0000 (16:55 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:05:43 +0000 (12:05 -0500)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc
src/test/librgw_file.cc

index 54d920c3c015d41140313bfcae6484c8de549b5f..f5f7a3b08e8b8b004aa10d22cf774835c8d9c847 100644 (file)
@@ -191,6 +191,36 @@ int rgw_unlink(struct rgw_fs *rgw_fs, struct rgw_file_handle* parent,
   return rc;
 }
 
+void dump_buckets(void) {
+  /* get the bucket list */
+  string marker; // XXX need to match offset
+  string end_marker;
+  uint64_t bucket_count, bucket_objcount;
+
+  RGWUserBuckets buckets;
+  uint64_t max_buckets = g_ceph_context->_conf->rgw_list_buckets_max_chunk;
+
+  RGWRados* store = librgw.get_store();
+
+  /* XXX check offsets */
+  uint64_t ix = 3;
+  rgw_user uid("testuser");
+  int rc = rgw_read_user_buckets(store, uid, buckets, marker, end_marker,
+                                max_buckets, true);
+  if (rc == 0) {
+    bucket_count = 0;
+    bucket_objcount = 0;
+    map<string, RGWBucketEnt>& m = buckets.get_buckets();
+    for (auto& ib : m) {
+      RGWBucketEnt& bent = ib.second;
+      bucket_objcount += bent.count;
+      marker = ib.first;
+      std::cout << bent.bucket.name.c_str() << " ix: " << ix++ << std::endl;
+    }
+    bucket_count += m.size();
+  }
+} /* dump_buckets */
+
 /*
   lookup object by name (POSIX style)
 */
index d007b5c2bbc6d738e1d42c9c8961959c9551db7f..cdb7ed0ccfe375ea831b22ca2f8abdfac5aac172 100644 (file)
@@ -55,6 +55,14 @@ TEST(LibRGW, MOUNT) {
   ASSERT_NE(fs, nullptr);
 }
 
+extern "C" {
+extern void dump_buckets(void);
+}
+
+TEST(LibRGW, DUMP_BUCKETS) {
+  dump_buckets();
+}
+
 extern "C" {
   static bool r1_cb(const char* name, void *arg, uint64_t offset) {
     // don't need arg--it would point to fids1
@@ -137,6 +145,7 @@ TEST(LibRGW, CLEANUP) {
       rgw_fh = get<2>(fid);
       if (rgw_fh)
        ret = rgw_fh_rele(fs, rgw_fh, 0 /* flags */);
+      ASSERT_EQ(ret, 0);
     }
   }
 }