mirror of
https://github.com/ceph/ceph
synced 2025-01-01 08:32:24 +00:00
librgw: add diagnostic dump_buckets() call.
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
This commit is contained in:
parent
a5e6d559f0
commit
0e5f5e2bcf
@ -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)
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user