Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rgw/admin: 'bucket stats' displays non-empty mtime #50429

Merged
merged 2 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/rgw/driver/rados/rgw_bucket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@ static int bucket_stats(rgw::sal::Driver* driver,
std::unique_ptr<rgw::sal::Bucket> bucket;
map<RGWObjCategory, RGWStorageStats> stats;

real_time mtime;
int ret = driver->get_bucket(dpp, nullptr, tenant_name, bucket_name, &bucket, null_yield);
if (ret < 0) {
return ret;
Expand All @@ -891,7 +890,7 @@ static int bucket_stats(rgw::sal::Driver* driver,
return ret;
}

utime_t ut(mtime);
utime_t ut(bucket->get_modification_time());
utime_t ctime_ut(bucket->get_creation_time());

formatter->open_object_section("stats");
Expand Down
1 change: 1 addition & 0 deletions src/rgw/services/svc_sys_obj.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int RGWSI_SysObj::Obj::ROp::read(const DoutPrefixProvider *dpp,
return svc->read(dpp, *state,
objv_tracker,
obj, bl, ofs, end,
lastmod, obj_size,
attrs,
raw_attrs,
cache_info,
Expand Down
35 changes: 32 additions & 3 deletions src/rgw/services/svc_sys_obj_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ int RGWSI_SysObj_Cache::read(const DoutPrefixProvider *dpp,
RGWObjVersionTracker *objv_tracker,
const rgw_raw_obj& obj,
bufferlist *obl, off_t ofs, off_t end,
ceph::real_time* pmtime, uint64_t* psize,
map<string, bufferlist> *attrs,
bool raw_attrs,
rgw_cache_entry_info *cache_info,
Expand All @@ -120,8 +121,8 @@ int RGWSI_SysObj_Cache::read(const DoutPrefixProvider *dpp,
rgw_pool pool;
string oid;
if (ofs != 0) {
return RGWSI_SysObj_Core::read(dpp, read_state, objv_tracker,
obj, obl, ofs, end, attrs, raw_attrs,
return RGWSI_SysObj_Core::read(dpp, read_state, objv_tracker, obj, obl,
ofs, end, pmtime, psize, attrs, raw_attrs,
cache_info, refresh_version, y);
}

Expand All @@ -133,6 +134,8 @@ int RGWSI_SysObj_Cache::read(const DoutPrefixProvider *dpp,
uint32_t flags = (end != 0 ? CACHE_FLAG_DATA : 0);
if (objv_tracker)
flags |= CACHE_FLAG_OBJV;
if (pmtime || psize)
flags |= CACHE_FLAG_META;
if (attrs)
flags |= CACHE_FLAG_XATTRS;

Expand All @@ -151,6 +154,12 @@ int RGWSI_SysObj_Cache::read(const DoutPrefixProvider *dpp,
i.copy_all(*obl);
if (objv_tracker)
objv_tracker->read_version = info.version;
if (pmtime) {
*pmtime = info.meta.mtime;
}
if (psize) {
*psize = info.meta.size;
}
if (attrs) {
if (raw_attrs) {
*attrs = info.xattrs;
Expand All @@ -163,9 +172,23 @@ int RGWSI_SysObj_Cache::read(const DoutPrefixProvider *dpp,
if(r == -ENODATA)
return -ENOENT;

// if we only ask for one of mtime or size, ask for the other too so we can
// satisfy CACHE_FLAG_META
uint64_t size = 0;
real_time mtime;
if (pmtime) {
if (!psize) {
psize = &size;
}
} else if (psize) {
if (!pmtime) {
pmtime = &mtime;
}
}

map<string, bufferlist> unfiltered_attrset;
r = RGWSI_SysObj_Core::read(dpp, read_state, objv_tracker,
obj, obl, ofs, end,
obj, obl, ofs, end, pmtime, psize,
(attrs ? &unfiltered_attrset : nullptr),
true, /* cache unfiltered attrs */
cache_info,
Expand Down Expand Up @@ -194,6 +217,12 @@ int RGWSI_SysObj_Cache::read(const DoutPrefixProvider *dpp,
if (objv_tracker) {
info.version = objv_tracker->read_version;
}
if (pmtime) {
info.meta.mtime = *pmtime;
}
if (psize) {
info.meta.size = *psize;
}
if (attrs) {
info.xattrs = std::move(unfiltered_attrset);
if (raw_attrs) {
Expand Down
1 change: 1 addition & 0 deletions src/rgw/services/svc_sys_obj_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class RGWSI_SysObj_Cache : public RGWSI_SysObj_Core
RGWObjVersionTracker *objv_tracker,
const rgw_raw_obj& obj,
bufferlist *bl, off_t ofs, off_t end,
ceph::real_time* pmtime, uint64_t* psize,
std::map<std::string, bufferlist> *attrs,
bool raw_attrs,
rgw_cache_entry_info *cache_info,
Expand Down
8 changes: 8 additions & 0 deletions src/rgw/services/svc_sys_obj_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ int RGWSI_SysObj_Core::read(const DoutPrefixProvider *dpp,
RGWObjVersionTracker *objv_tracker,
const rgw_raw_obj& obj,
bufferlist *bl, off_t ofs, off_t end,
ceph::real_time* pmtime, uint64_t* psize,
map<string, bufferlist> *attrs,
bool raw_attrs,
rgw_cache_entry_info *cache_info,
Expand All @@ -143,6 +144,7 @@ int RGWSI_SysObj_Core::read(const DoutPrefixProvider *dpp,
auto& read_state = static_cast<GetObjState&>(_read_state);

uint64_t len;
struct timespec mtime_ts;
librados::ObjectReadOperation op;

if (end < 0)
Expand All @@ -153,6 +155,9 @@ int RGWSI_SysObj_Core::read(const DoutPrefixProvider *dpp,
if (objv_tracker) {
objv_tracker->prepare_op_for_read(&op);
}
if (psize || pmtime) {
op.stat2(psize, &mtime_ts, nullptr);
}

ldpp_dout(dpp, 20) << "rados->read ofs=" << ofs << " len=" << len << dendl;
op.read(ofs, len, bl, nullptr);
Expand Down Expand Up @@ -188,6 +193,9 @@ int RGWSI_SysObj_Core::read(const DoutPrefixProvider *dpp,
return -ECANCELED;
}

if (pmtime) {
*pmtime = ceph::real_clock::from_timespec(mtime_ts);
}
if (attrs && !raw_attrs) {
rgw_filter_attrset(unfiltered_attrset, RGW_ATTR_PREFIX, attrs);
}
Expand Down
1 change: 1 addition & 0 deletions src/rgw/services/svc_sys_obj_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class RGWSI_SysObj_Core : public RGWServiceInstance
RGWObjVersionTracker *objv_tracker,
const rgw_raw_obj& obj,
bufferlist *bl, off_t ofs, off_t end,
ceph::real_time* pmtime, uint64_t* psize,
std::map<std::string, bufferlist> *attrs,
bool raw_attrs,
rgw_cache_entry_info *cache_info,
Expand Down