librgw: add diagnostic dump_buckets() call.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
This commit is contained in:
Matt Benjamin 2015-11-06 16:55:57 -05:00
parent a5e6d559f0
commit 0e5f5e2bcf
2 changed files with 39 additions and 0 deletions

View 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)
*/

View 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);
}
}
}