CephFS does not support disk space reservation. The only flags supported are
`FALLOC_FL_KEEP_SIZE` and `FALLOC_FL_PUNCH_HOLE`.
+* The HeadBucket API now reports the `X-RGW-Bytes-Used` and `X-RGW-Object-Count`
+ headers only when the `read-stats` querystring is explicitly included in the
+ API request.
+
>=19.2.1
* CephFS: Command `fs subvolume create` now allows tagging subvolumes through option
std::string uri;
std::map<std::string, buffer::list> attrs;
RGWLibFS::BucketStats& bs;
+ real_time ctime;
+ bool name_matched = false;
RGWStatBucketRequest(CephContext* _cct, std::unique_ptr<rgw::sal::User> _user,
const std::string& _path,
return (iter != attrs.end()) ? &(iter->second) : nullptr;
}
- real_time get_ctime() const {
- return bucket->get_creation_time();
- }
+ real_time get_ctime() { return ctime; }
bool only_bucket() override { return false; }
return 0;
}
- virtual int get_params() {
- return 0;
+ int get_params(optional_yield) override { return 0; }
+
+ void complete() override {
+ // get_state() will no longer be there after execute_req()
+ // so save what we need from get_state()->bucket
+ ctime = get_state()->bucket->get_creation_time();
+ name_matched = get_state()->bucket->get_name().length() > 0;
+
+ RGWOp::complete();
}
void send_response() override {
- bucket->get_creation_time() = get_state()->bucket->get_info().creation_time;
bs.size = stats.size;
bs.size_rounded = stats.size_rounded;
- bs.creation_time = bucket->get_creation_time();
+ bs.creation_time = get_state()->bucket->get_info().creation_time;
bs.num_entries = stats.num_objects;
std::swap(attrs, get_state()->bucket_attrs);
}
- bool matched() {
- return (bucket->get_name().length() > 0);
- }
+ bool matched() { return name_matched; }
}; /* RGWStatBucketRequest */
void RGWStatBucket::execute(optional_yield y)
{
- if (!s->bucket_exists) {
- op_ret = -ERR_NO_SUCH_BUCKET;
+ op_ret = get_params(y);
+ if (op_ret < 0) {
return;
}
- op_ret = driver->load_bucket(this, s->bucket->get_key(), &bucket, y);
- if (op_ret) {
+ if (!s->bucket_exists) {
+ op_ret = -ERR_NO_SUCH_BUCKET;
return;
}
- op_ret = load_bucket_stats(this, y, *s->bucket, stats);
+ if (report_stats) {
+ op_ret = load_bucket_stats(this, y, *s->bucket, stats);
+ }
}
int RGWListBucket::verify_permission(optional_yield y)
class RGWStatBucket : public RGWOp {
protected:
- std::unique_ptr<rgw::sal::Bucket> bucket;
RGWStorageStats stats;
+ bool report_stats{true};
public:
int verify_permission(optional_yield y) override;
void pre_exec() override;
void execute(optional_yield y) override;
+ virtual int get_params(optional_yield y) = 0;
void send_response() override = 0;
const char* name() const override { return "stat_bucket"; }
RGWOpType get_type() override { return RGW_OP_STAT_BUCKET; }
return op_ret;
}
-
void RGWRESTOp::send_response()
{
if (!flusher.did_start()) {
rgw_flush_formatter_and_reset(s, s->formatter);
}
-static void dump_bucket_metadata(req_state *s, rgw::sal::Bucket* bucket,
+static void dump_bucket_metadata(req_state *s,
RGWStorageStats& stats)
{
dump_header(s, "X-RGW-Object-Count", static_cast<long long>(stats.num_objects));
dump_header(s, "X-RGW-Bytes-Used", static_cast<long long>(stats.size));
+}
- // only bucket's owner is allowed to get the quota settings of the account
- if (s->auth.identity->is_owner_of(bucket->get_owner())) {
- const auto& user_info = s->user->get_info();
- const auto& bucket_quota = s->bucket->get_info().quota; // bucket quota
- dump_header(s, "X-RGW-Quota-Max-Buckets", static_cast<long long>(user_info.max_buckets));
-
- if (user_info.quota.user_quota.enabled){
- dump_header(s, "X-RGW-Quota-User-Size", static_cast<long long>(user_info.quota.user_quota.max_size));
- dump_header(s, "X-RGW-Quota-User-Objects", static_cast<long long>(user_info.quota.user_quota.max_objects));
- }
+int RGWStatBucket_ObjStore_S3::get_params(optional_yield y)
+{
+ report_stats = s->info.args.exists("read-stats");
- if (bucket_quota.enabled){
- dump_header(s, "X-RGW-Quota-Bucket-Size", static_cast<long long>(bucket_quota.max_size));
- dump_header(s, "X-RGW-Quota-Bucket-Objects", static_cast<long long>(bucket_quota.max_objects));
- }
- }
+ return 0;
}
void RGWStatBucket_ObjStore_S3::send_response()
{
if (op_ret >= 0) {
- dump_bucket_metadata(s, bucket.get(), stats);
+ if (report_stats) {
+ dump_bucket_metadata(s, stats);
+ }
+ // only bucket's owner is allowed to get the quota settings of the account
+ if (s->auth.identity->is_owner_of(s->bucket->get_owner())) {
+ const auto& user_info = s->user->get_info();
+ const auto& bucket_quota = s->bucket->get_info().quota; // bucket quota
+
+ dump_header(s, "X-RGW-Quota-Max-Buckets", static_cast<long long>(user_info.max_buckets));
+ if (user_info.quota.user_quota.enabled) {
+ dump_header(s, "X-RGW-Quota-User-Size", static_cast<long long>(user_info.quota.user_quota.max_size));
+ dump_header(s, "X-RGW-Quota-User-Objects", static_cast<long long>(user_info.quota.user_quota.max_objects));
+ }
+ if (bucket_quota.enabled) {
+ dump_header(s, "X-RGW-Quota-Bucket-Size", static_cast<long long>(bucket_quota.max_size));
+ dump_header(s, "X-RGW-Quota-Bucket-Objects", static_cast<long long>(bucket_quota.max_objects));
+ }
+ }
}
set_req_state_err(s, op_ret);
~RGWStatBucket_ObjStore_S3() override {}
void send_response() override;
+ int get_params(optional_yield y) override;
};
class RGWCreateBucket_ObjStore_S3 : public RGWCreateBucket_ObjStore {
}
static void dump_container_metadata(req_state *,
- const rgw::sal::Bucket*,
const std::optional<RGWStorageStats>& stats,
const RGWQuotaInfo&,
const RGWBucketWebsiteConf&);
map<string, bool>::iterator pref_iter = common_prefixes.begin();
dump_start(s);
- dump_container_metadata(s, s->bucket.get(), stats, quota.bucket_quota,
+ dump_container_metadata(s, stats, quota.bucket_quota,
s->bucket->get_info().website_conf);
s->formatter->open_array_section_with_attrs("container",
} // RGWListBucket_ObjStore_SWIFT::send_response
static void dump_container_metadata(req_state *s,
- const rgw::sal::Bucket* bucket,
const std::optional<RGWStorageStats>& stats,
const RGWQuotaInfo& quota,
const RGWBucketWebsiteConf& ws_conf)
{
if (op_ret >= 0) {
op_ret = STATUS_NO_CONTENT;
- dump_container_metadata(s, bucket.get(), stats, quota.bucket_quota,
+ dump_container_metadata(s, stats, quota.bucket_quota,
s->bucket->get_info().website_conf);
}
/* Generate the header now. */
set_req_state_err(s, op_ret);
dump_errno(s);
- dump_container_metadata(s, s->bucket.get(), stats, quota.bucket_quota,
+ dump_container_metadata(s, stats, quota.bucket_quota,
s->bucket->get_info().website_conf);
end_header(s, this, "text/html");
if (op_ret < 0) {
RGWStatBucket_ObjStore_SWIFT() {}
~RGWStatBucket_ObjStore_SWIFT() override {}
+ int get_params(optional_yield y) override { return 0; }
void send_response() override;
};