From: Yehuda Sadeh Date: Fri, 10 Jan 2014 05:37:34 +0000 (-0800) Subject: rgw: rename RGWBucketStats to RGWStorageStats X-Git-Tag: v0.78~270^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4aee3fa2285cfae3055c9fc2929b436350326c1b;p=ceph.git rgw: rename RGWBucketStats to RGWStorageStats make it more generic, will be reused for user's stats. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index b739fcd7ef4b..2532fb6cce89 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -478,13 +478,13 @@ static void show_user_info(RGWUserInfo& info, Formatter *formatter) cout << std::endl; } -static void dump_bucket_usage(map& stats, Formatter *formatter) +static void dump_bucket_usage(map& stats, Formatter *formatter) { - map::iterator iter; + map::iterator iter; formatter->open_object_section("usage"); for (iter = stats.begin(); iter != stats.end(); ++iter) { - RGWBucketStats& s = iter->second; + RGWStorageStats& s = iter->second; const char *cat_name = rgw_obj_category_name(iter->first); formatter->open_object_section(cat_name); formatter->dump_int("size_kb", s.num_kb); @@ -504,7 +504,7 @@ int bucket_stats(rgw_bucket& bucket, Formatter *formatter) if (r < 0) return r; - map stats; + map stats; uint64_t bucket_ver, master_ver; string max_marker; int ret = store->get_bucket_stats(bucket, &bucket_ver, &master_ver, stats, &max_marker); diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 10afb70c5d4e..3e7a44e15a42 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -314,7 +314,7 @@ int rgw_remove_object(RGWRados *store, const string& bucket_owner, rgw_bucket& b int rgw_remove_bucket(RGWRados *store, const string& bucket_owner, rgw_bucket& bucket, bool delete_children) { int ret; - map stats; + map stats; std::vector objs; std::string prefix, delim, marker, ns; map common_prefixes; @@ -547,13 +547,13 @@ static void dump_bucket_index(map result, Formatter *f) } } -static void dump_bucket_usage(map& stats, Formatter *formatter) +static void dump_bucket_usage(map& stats, Formatter *formatter) { - map::iterator iter; + map::iterator iter; formatter->open_object_section("usage"); for (iter = stats.begin(); iter != stats.end(); ++iter) { - RGWBucketStats& s = iter->second; + RGWStorageStats& s = iter->second; const char *cat_name = rgw_obj_category_name(iter->first); formatter->open_object_section(cat_name); formatter->dump_int("size_kb", s.num_kb); @@ -564,8 +564,8 @@ static void dump_bucket_usage(map& stats, Format formatter->close_section(); } -static void dump_index_check(map existing_stats, - map calculated_stats, +static void dump_index_check(map existing_stats, + map calculated_stats, Formatter *formatter) { formatter->open_object_section("check_result"); @@ -704,8 +704,8 @@ int RGWBucket::check_object_index(RGWBucketAdminOpState& op_state, int RGWBucket::check_index(RGWBucketAdminOpState& op_state, - map& existing_stats, - map& calculated_stats, + map& existing_stats, + map& calculated_stats, std::string *err_msg) { rgw_bucket bucket = op_state.get_bucket(); @@ -820,8 +820,8 @@ int RGWBucketAdminOp::check_index(RGWRados *store, RGWBucketAdminOpState& op_sta { int ret; map result; - map existing_stats; - map calculated_stats; + map existing_stats; + map calculated_stats; list objs_to_unlink; RGWBucket bucket; @@ -883,7 +883,7 @@ static int bucket_stats(RGWRados *store, std::string& bucket_name, Formatter *f { RGWBucketInfo bucket_info; rgw_bucket bucket; - map stats; + map stats; time_t mtime; int r = store->get_bucket_info(NULL, bucket_name, bucket_info, &mtime); diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index 61b533c5a80e..cc941a595c0e 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -200,8 +200,8 @@ public: map result, std::string *err_msg = NULL); int check_index(RGWBucketAdminOpState& op_state, - map& existing_stats, - map& calculated_stats, + map& existing_stats, + map& calculated_stats, std::string *err_msg = NULL); int remove(RGWBucketAdminOpState& op_state, std::string *err_msg = NULL); diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 4c98e81f8ac7..cc797d66209c 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -784,14 +784,14 @@ struct RGWBucketEntryPoint }; WRITE_CLASS_ENCODER(RGWBucketEntryPoint) -struct RGWBucketStats +struct RGWStorageStats { RGWObjCategory category; uint64_t num_kb; uint64_t num_kb_rounded; uint64_t num_objects; - RGWBucketStats() : num_kb(0), num_kb_rounded(0), num_objects(0) {} + RGWStorageStats() : num_kb(0), num_kb_rounded(0), num_objects(0) {} }; struct req_state; diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index 2b292df5a48e..5c16c7895d16 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -25,7 +25,7 @@ struct RGWQuotaBucketStats { - RGWBucketStats stats; + RGWStorageStats stats; utime_t expiration; utime_t async_refresh_time; }; @@ -35,7 +35,7 @@ class RGWBucketStatsCache { lru_map stats_map; RefCountedWaitObject *async_refcount; - int fetch_bucket_totals(rgw_bucket& bucket, RGWBucketStats& stats); + int fetch_bucket_totals(rgw_bucket& bucket, RGWStorageStats& stats); public: RGWBucketStatsCache(RGWRados *_store) : store(_store), stats_map(store->ctx()->_conf->rgw_bucket_quota_cache_size) { @@ -45,17 +45,17 @@ public: async_refcount->put_wait(); /* wait for all pending async requests to complete */ } - int get_bucket_stats(rgw_bucket& bucket, RGWBucketStats& stats, RGWQuotaInfo& quota); + int get_bucket_stats(rgw_bucket& bucket, RGWStorageStats& stats, RGWQuotaInfo& quota); void adjust_bucket_stats(const string& bucket_owner, rgw_bucket& bucket, int objs_delta, uint64_t added_bytes, uint64_t removed_bytes); - bool can_use_cached_stats(RGWQuotaInfo& quota, RGWBucketStats& stats); + bool can_use_cached_stats(RGWQuotaInfo& quota, RGWStorageStats& stats); - void set_stats(rgw_bucket& bucket, RGWQuotaBucketStats& qs, RGWBucketStats& stats); + void set_stats(rgw_bucket& bucket, RGWQuotaBucketStats& qs, RGWStorageStats& stats); int async_refresh(rgw_bucket& bucket, RGWQuotaBucketStats& qs); - void async_refresh_response(rgw_bucket& bucket, RGWBucketStats& stats); + void async_refresh_response(rgw_bucket& bucket, RGWStorageStats& stats); }; -bool RGWBucketStatsCache::can_use_cached_stats(RGWQuotaInfo& quota, RGWBucketStats& cached_stats) +bool RGWBucketStatsCache::can_use_cached_stats(RGWQuotaInfo& quota, RGWStorageStats& cached_stats) { if (quota.max_size_kb >= 0) { if (quota.max_size_soft_threshold < 0) { @@ -84,25 +84,25 @@ bool RGWBucketStatsCache::can_use_cached_stats(RGWQuotaInfo& quota, RGWBucketSta return true; } -int RGWBucketStatsCache::fetch_bucket_totals(rgw_bucket& bucket, RGWBucketStats& stats) +int RGWBucketStatsCache::fetch_bucket_totals(rgw_bucket& bucket, RGWStorageStats& stats) { RGWBucketInfo bucket_info; uint64_t bucket_ver; uint64_t master_ver; - map bucket_stats; + map bucket_stats; int r = store->get_bucket_stats(bucket, &bucket_ver, &master_ver, bucket_stats, NULL); if (r < 0) { ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket.name << dendl; return r; } - stats = RGWBucketStats(); + stats = RGWStorageStats(); - map::iterator iter; + map::iterator iter; for (iter = bucket_stats.begin(); iter != bucket_stats.end(); ++iter) { - RGWBucketStats& s = iter->second; + RGWStorageStats& s = iter->second; stats.num_kb += s.num_kb; stats.num_kb_rounded += s.num_kb_rounded; stats.num_objects += s.num_objects; @@ -126,7 +126,7 @@ public: int AsyncRefreshHandler::init_fetch() { ldout(store->ctx(), 20) << "initiating async quota refresh for bucket=" << bucket << dendl; - map bucket_stats; + map bucket_stats; int r = store->get_bucket_stats_async(bucket, this); if (r < 0) { ldout(store->ctx(), 0) << "could not get bucket info for bucket=" << bucket.name << dendl; @@ -145,11 +145,11 @@ void AsyncRefreshHandler::handle_response(int r) return; /* nothing to do here */ } - RGWBucketStats bs; + RGWStorageStats bs; - map::iterator iter; + map::iterator iter; for (iter = stats->begin(); iter != stats->end(); ++iter) { - RGWBucketStats& s = iter->second; + RGWStorageStats& s = iter->second; bs.num_kb += s.num_kb; bs.num_kb_rounded += s.num_kb_rounded; bs.num_objects += s.num_objects; @@ -197,7 +197,7 @@ int RGWBucketStatsCache::async_refresh(rgw_bucket& bucket, RGWQuotaBucketStats& return 0; } -void RGWBucketStatsCache::async_refresh_response(rgw_bucket& bucket, RGWBucketStats& stats) +void RGWBucketStatsCache::async_refresh_response(rgw_bucket& bucket, RGWStorageStats& stats) { ldout(store->ctx(), 20) << "async stats refresh response for bucket=" << bucket << dendl; @@ -210,7 +210,7 @@ void RGWBucketStatsCache::async_refresh_response(rgw_bucket& bucket, RGWBucketSt async_refcount->put(); } -void RGWBucketStatsCache::set_stats(rgw_bucket& bucket, RGWQuotaBucketStats& qs, RGWBucketStats& stats) +void RGWBucketStatsCache::set_stats(rgw_bucket& bucket, RGWQuotaBucketStats& qs, RGWStorageStats& stats) { qs.stats = stats; qs.expiration = ceph_clock_now(store->ctx()); @@ -221,7 +221,7 @@ void RGWBucketStatsCache::set_stats(rgw_bucket& bucket, RGWQuotaBucketStats& qs, stats_map.add(bucket, qs); } -int RGWBucketStatsCache::get_bucket_stats(rgw_bucket& bucket, RGWBucketStats& stats, RGWQuotaInfo& quota) { +int RGWBucketStatsCache::get_bucket_stats(rgw_bucket& bucket, RGWStorageStats& stats, RGWQuotaInfo& quota) { RGWQuotaBucketStats qs; utime_t now = ceph_clock_now(store->ctx()); if (stats_map.find(bucket, qs)) { @@ -289,7 +289,7 @@ public: return 0; } - RGWBucketStats stats; + RGWStorageStats stats; int ret = stats_cache.get_bucket_stats(bucket, stats, bucket_quota); if (ret < 0) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index c56d994a57a1..6784ea9ed725 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -3121,12 +3121,12 @@ int RGWRados::open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, return 0; } -static void translate_raw_stats(rgw_bucket_dir_header& header, map& stats) +static void translate_raw_stats(rgw_bucket_dir_header& header, map& stats) { map::iterator iter = header.stats.begin(); for (; iter != header.stats.end(); ++iter) { RGWObjCategory category = (RGWObjCategory)iter->first; - RGWBucketStats& s = stats[category]; + RGWStorageStats& s = stats[category]; struct rgw_bucket_category_stats& header_stats = iter->second; s.category = (RGWObjCategory)iter->first; s.num_kb = ((header_stats.total_size + 1023) / 1024); @@ -3136,8 +3136,8 @@ static void translate_raw_stats(rgw_bucket_dir_header& header, map *existing_stats, - map *calculated_stats) + map *existing_stats, + map *calculated_stats) { librados::IoCtx index_ctx; string oid; @@ -4655,7 +4655,7 @@ int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, return 0; } -int RGWRados::get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map& stats, +int RGWRados::get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map& stats, string *max_marker) { rgw_bucket_dir_header header; @@ -4682,7 +4682,7 @@ class RGWGetBucketStatsContext : public RGWGetDirHeader_CB { public: RGWGetBucketStatsContext(RGWGetBucketStats_CB *_cb) : cb(_cb) {} void handle_response(int r, rgw_bucket_dir_header& header) { - map stats; + map stats; if (r >= 0) { translate_raw_stats(header, stats); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 1c66d49a555d..028102f08b8f 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -773,14 +773,14 @@ protected: rgw_bucket bucket; uint64_t bucket_ver; uint64_t master_ver; - map *stats; + map *stats; string max_marker; public: RGWGetBucketStats_CB(rgw_bucket& _bucket) : bucket(_bucket), stats(NULL) {} virtual ~RGWGetBucketStats_CB() {} virtual void handle_response(int r) = 0; virtual void set_response(uint64_t _bucket_ver, uint64_t _master_ver, - map *_stats, + map *_stats, const string &_max_marker) { bucket_ver = _bucket_ver; master_ver = _master_ver; @@ -1328,7 +1328,7 @@ public: } int decode_policy(bufferlist& bl, ACLOwner *owner); - int get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map& stats, + int get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map& stats, string *max_marker); int get_bucket_stats_async(rgw_bucket& bucket, RGWGetBucketStats_CB *cb); void get_bucket_instance_obj(rgw_bucket& bucket, rgw_obj& obj); @@ -1414,8 +1414,8 @@ public: int defer_gc(void *ctx, rgw_obj& obj); int bucket_check_index(rgw_bucket& bucket, - map *existing_stats, - map *calculated_stats); + map *existing_stats, + map *calculated_stats); int bucket_rebuild_index(rgw_bucket& bucket); int remove_objs_from_index(rgw_bucket& bucket, list& oid_list); diff --git a/src/rgw/rgw_rest_log.cc b/src/rgw/rgw_rest_log.cc index 2de424fb6e59..9f32fc9ebd3f 100644 --- a/src/rgw/rgw_rest_log.cc +++ b/src/rgw/rgw_rest_log.cc @@ -379,7 +379,7 @@ void RGWOp_BILog_Info::execute() { return; } } - map stats; + map stats; int ret = store->get_bucket_stats(bucket_info.bucket, &bucket_ver, &master_ver, stats, &max_marker); if (ret < 0 && ret != -ENOENT) { http_ret = ret;