rgw: high resolution time

replace time_t, and some utime_t with ceph::real_clock. Use new
librados interfaces to stat() and set mtime.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
This commit is contained in:
Yehuda Sadeh 2016-03-02 22:23:41 -08:00
parent 0695698d34
commit 416234b38b
53 changed files with 797 additions and 676 deletions

View File

@ -9,7 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include "include/utime.h" #include "common/ceph_time.h"
#include "objclass/objclass.h" #include "objclass/objclass.h"
#include "cls/rgw/cls_rgw_ops.h" #include "cls/rgw/cls_rgw_ops.h"
#include "common/Clock.h" #include "common/Clock.h"
@ -114,10 +114,11 @@ static bool bi_entry_gt(const string& first, const string& second)
return first > second; return first > second;
} }
static void get_time_key(utime_t& ut, string *key) static void get_time_key(real_time& ut, string *key)
{ {
char buf[32]; char buf[32];
snprintf(buf, 32, "%011llu.%09u", (unsigned long long)ut.sec(), ut.nsec()); ceph_timespec ts = ceph::real_clock::to_ceph_timespec(ut);
snprintf(buf, 32, "%011llu.%09u", (unsigned long long)ts.tv_sec, (unsigned int)ts.tv_nsec);
*key = buf; *key = buf;
} }
@ -140,7 +141,7 @@ static void bi_log_index_key(cls_method_context_t hctx, string& key, string& id,
} }
static int log_index_operation(cls_method_context_t hctx, cls_rgw_obj_key& obj_key, RGWModifyOp op, static int log_index_operation(cls_method_context_t hctx, cls_rgw_obj_key& obj_key, RGWModifyOp op,
string& tag, utime_t& timestamp, string& tag, real_time& timestamp,
rgw_bucket_entry_ver& ver, RGWPendingState state, uint64_t index_ver, rgw_bucket_entry_ver& ver, RGWPendingState state, uint64_t index_ver,
string& max_marker, uint16_t bilog_flags, string *owner, string *owner_display_name) string& max_marker, uint16_t bilog_flags, string *owner, string *owner_display_name)
{ {
@ -678,7 +679,7 @@ int rgw_bucket_prepare_op(cls_method_context_t hctx, bufferlist *in, bufferlist
// fill in proper state // fill in proper state
struct rgw_bucket_pending_info info; struct rgw_bucket_pending_info info;
info.timestamp = ceph_clock_now(g_ceph_context); info.timestamp = real_clock::now();
info.state = CLS_RGW_STATE_PENDING_MODIFY; info.state = CLS_RGW_STATE_PENDING_MODIFY;
info.op = op.op; info.op = op.op;
entry.pending_map.insert(pair<string, rgw_bucket_pending_info>(op.tag, info)); entry.pending_map.insert(pair<string, rgw_bucket_pending_info>(op.tag, info));
@ -1183,7 +1184,7 @@ public:
return 0; return 0;
} }
time_t mtime() { real_time mtime() {
return instance_entry.meta.mtime; return instance_entry.meta.mtime;
} }
}; };
@ -1389,7 +1390,7 @@ static int rgw_bucket_link_olh(cls_method_context_t hctx, bufferlist *in, buffer
return ret; return ret;
} }
if (existed && op.unmod_since > 0) { if (existed && !real_clock::is_zero(op.unmod_since)) {
if (obj.mtime() >= op.unmod_since) { if (obj.mtime() >= op.unmod_since) {
return 0; /* no need to set error, we just return 0 and avoid writing to the bi log */ return 0; /* no need to set error, we just return 0 and avoid writing to the bi log */
} }
@ -1654,7 +1655,7 @@ static int rgw_bucket_unlink_instance(cls_method_context_t hctx, bufferlist *in,
rgw_bucket_entry_ver ver; rgw_bucket_entry_ver ver;
ver.epoch = (op.olh_epoch ? op.olh_epoch : olh.get_epoch()); ver.epoch = (op.olh_epoch ? op.olh_epoch : olh.get_epoch());
utime_t mtime = ceph_clock_now(g_ceph_context); /* mtime has no real meaning in instance removal context */ real_time mtime = real_clock::now(); /* mtime has no real meaning in instance removal context */
ret = log_index_operation(hctx, op.key, CLS_RGW_OP_UNLINK_INSTANCE, op.op_tag, ret = log_index_operation(hctx, op.key, CLS_RGW_OP_UNLINK_INSTANCE, op.op_tag,
mtime, ver, mtime, ver,
CLS_RGW_STATE_COMPLETE, header.ver, header.max_marker, CLS_RGW_STATE_COMPLETE, header.ver, header.max_marker,
@ -1842,7 +1843,6 @@ int rgw_dir_suggest_changes(cls_method_context_t hctx, bufferlist *in, bufferlis
bufferlist header_bl; bufferlist header_bl;
struct rgw_bucket_dir_header header; struct rgw_bucket_dir_header header;
bool header_changed = false; bool header_changed = false;
uint64_t tag_timeout;
int rc = read_bucket_header(hctx, &header); int rc = read_bucket_header(hctx, &header);
if (rc < 0) { if (rc < 0) {
@ -1850,7 +1850,7 @@ int rgw_dir_suggest_changes(cls_method_context_t hctx, bufferlist *in, bufferlis
return rc; return rc;
} }
tag_timeout = (header.tag_timeout ? header.tag_timeout : CEPH_RGW_TAG_TIMEOUT); timespan tag_timeout(header.tag_timeout ? header.tag_timeout : CEPH_RGW_TAG_TIMEOUT);
bufferlist::iterator in_iter = in->begin(); bufferlist::iterator in_iter = in->begin();
@ -1882,7 +1882,7 @@ int rgw_dir_suggest_changes(cls_method_context_t hctx, bufferlist *in, bufferlis
return -EINVAL; return -EINVAL;
} }
utime_t cur_time = ceph_clock_now(g_ceph_context); real_time cur_time = real_clock::now();
map<string, struct rgw_bucket_pending_info>::iterator iter = map<string, struct rgw_bucket_pending_info>::iterator iter =
cur_disk.pending_map.begin(); cur_disk.pending_map.begin();
while(iter != cur_disk.pending_map.end()) { while(iter != cur_disk.pending_map.end()) {
@ -2091,8 +2091,8 @@ static int rgw_obj_check_mtime(cls_method_context_t hctx, bufferlist *in, buffer
return -EINVAL; return -EINVAL;
} }
time_t mtime; real_time obj_ut;
int ret = cls_cxx_stat(hctx, NULL, &mtime); int ret = cls_cxx_stat2(hctx, NULL, &obj_ut);
if (ret < 0 && ret != -ENOENT) { if (ret < 0 && ret != -ENOENT) {
CLS_LOG(0, "ERROR: %s(): cls_cxx_stat() returned %d", __func__, ret); CLS_LOG(0, "ERROR: %s(): cls_cxx_stat() returned %d", __func__, ret);
return ret; return ret;
@ -2101,11 +2101,12 @@ static int rgw_obj_check_mtime(cls_method_context_t hctx, bufferlist *in, buffer
CLS_LOG(10, "object does not exist, skipping check"); CLS_LOG(10, "object does not exist, skipping check");
} }
utime_t obj_ut(mtime, 0); ceph_timespec obj_ts = ceph::real_clock::to_ceph_timespec(obj_ut);
ceph_timespec op_ts = ceph::real_clock::to_ceph_timespec(op.mtime);
CLS_LOG(10, "%s: obj_ut=%lld.%06lld op.mtime=%lld.%06lld", __func__, CLS_LOG(10, "%s: obj_ut=%lld.%06lld op.mtime=%lld.%06lld", __func__,
(long long)obj_ut.sec(), (long long)obj_ut.nsec(), (long long)obj_ts.tv_sec, (long long)obj_ts.tv_nsec,
(long long)op.mtime.sec(), (long long)op.mtime.nsec()); (long long)op_ts.tv_sec, (long long)op_ts.tv_nsec);
bool check; bool check;
@ -2931,8 +2932,8 @@ static int gc_update_entry(cls_method_context_t hctx, uint32_t expiration_secs,
return ret; return ret;
} }
} }
info.time = ceph_clock_now(g_ceph_context); info.time = ceph::real_clock::now();
info.time += expiration_secs; info.time += timespan(expiration_secs);
ret = gc_omap_set(hctx, GC_OBJ_NAME_INDEX, info.tag, &info); ret = gc_omap_set(hctx, GC_OBJ_NAME_INDEX, info.tag, &info);
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -3027,7 +3028,7 @@ static int gc_iterate_entries(cls_method_context_t hctx, const string& marker, b
} }
if (expired_only) { if (expired_only) {
utime_t now = ceph_clock_now(g_ceph_context); real_time now = ceph::real_clock::now();
string now_str; string now_str;
get_time_key(now, &now_str); get_time_key(now, &now_str);
prepend_index_prefix(now_str, GC_OBJ_TIME_INDEX, &end_key); prepend_index_prefix(now_str, GC_OBJ_TIME_INDEX, &end_key);

View File

@ -227,7 +227,7 @@ void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation& o, const string&
o.exec("rgw", "obj_check_attrs_prefix", in); o.exec("rgw", "obj_check_attrs_prefix", in);
} }
void cls_rgw_obj_check_mtime(librados::ObjectOperation& o, const utime_t& mtime, RGWCheckMTimeType type) void cls_rgw_obj_check_mtime(librados::ObjectOperation& o, const real_time& mtime, RGWCheckMTimeType type)
{ {
bufferlist in; bufferlist in;
struct rgw_cls_obj_check_mtime call; struct rgw_cls_obj_check_mtime call;
@ -306,7 +306,7 @@ int cls_rgw_bi_list(librados::IoCtx& io_ctx, const string oid,
int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, bufferlist& olh_tag, int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, bufferlist& olh_tag,
bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta, bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, time_t unmod_since, bool log_op) uint64_t olh_epoch, ceph::real_time unmod_since, bool log_op)
{ {
bufferlist in, out; bufferlist in, out;
struct rgw_cls_link_olh_op call; struct rgw_cls_link_olh_op call;

View File

@ -8,6 +8,7 @@
#include "cls_rgw_ops.h" #include "cls_rgw_ops.h"
#include "common/RefCountedObj.h" #include "common/RefCountedObj.h"
#include "include/compat.h" #include "include/compat.h"
#include "common/ceph_time.h"
// Forward declaration // Forward declaration
class BucketIndexAioManager; class BucketIndexAioManager;
@ -317,7 +318,7 @@ void cls_rgw_bucket_complete_op(librados::ObjectWriteOperation& o, RGWModifyOp o
void cls_rgw_remove_obj(librados::ObjectWriteOperation& o, list<string>& keep_attr_prefixes); void cls_rgw_remove_obj(librados::ObjectWriteOperation& o, list<string>& keep_attr_prefixes);
void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation& o, const string& attr); void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation& o, const string& attr);
void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation& o, const string& prefix, bool fail_if_exist); void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation& o, const string& prefix, bool fail_if_exist);
void cls_rgw_obj_check_mtime(librados::ObjectOperation& o, const utime_t& mtime, RGWCheckMTimeType type); void cls_rgw_obj_check_mtime(librados::ObjectOperation& o, const ceph::real_time& mtime, RGWCheckMTimeType type);
int cls_rgw_bi_get(librados::IoCtx& io_ctx, const string oid, int cls_rgw_bi_get(librados::IoCtx& io_ctx, const string oid,
BIIndexType index_type, cls_rgw_obj_key& key, BIIndexType index_type, cls_rgw_obj_key& key,
@ -330,7 +331,7 @@ int cls_rgw_bi_list(librados::IoCtx& io_ctx, const string oid,
int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, bufferlist& olh_tag, int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, bufferlist& olh_tag,
bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta, bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, time_t unmod_since, bool log_op); uint64_t olh_epoch, ceph::real_time unmod_since, bool log_op);
int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, const string& op_tag, int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, const string& op_tag,
uint64_t olh_epoch, bool log_op); uint64_t olh_epoch, bool log_op);
int cls_rgw_get_olh_log(librados::IoCtx& io_ctx, string& oid, librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker, int cls_rgw_get_olh_log(librados::IoCtx& io_ctx, string& oid, librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker,

View File

@ -3,6 +3,7 @@
#include "common/Formatter.h" #include "common/Formatter.h"
#include "common/ceph_json.h" #include "common/ceph_json.h"
#include "include/utime.h"
void rgw_cls_tag_timeout_op::dump(Formatter *f) const void rgw_cls_tag_timeout_op::dump(Formatter *f) const
{ {
@ -175,7 +176,8 @@ void rgw_cls_link_olh_op::dump(Formatter *f) const
::encode_json("olh_epoch", olh_epoch, f); ::encode_json("olh_epoch", olh_epoch, f);
::encode_json("log_op", log_op, f); ::encode_json("log_op", log_op, f);
::encode_json("bilog_flags", (uint32_t)bilog_flags, f); ::encode_json("bilog_flags", (uint32_t)bilog_flags, f);
::encode_json("unmod_since", unmod_since, f); utime_t ut(unmod_since);
::encode_json("unmod_since", ut, f);
} }
void rgw_cls_unlink_instance_op::generate_test_instances(list<rgw_cls_unlink_instance_op*>& o) void rgw_cls_unlink_instance_op::generate_test_instances(list<rgw_cls_unlink_instance_op*>& o)

View File

@ -4,6 +4,7 @@
#include <map> #include <map>
#include "include/types.h" #include "include/types.h"
#include "common/ceph_time.h"
#include "cls/rgw/cls_rgw_types.h" #include "cls/rgw/cls_rgw_types.h"
struct rgw_cls_tag_timeout_op struct rgw_cls_tag_timeout_op
@ -164,12 +165,12 @@ struct rgw_cls_link_olh_op {
uint64_t olh_epoch; uint64_t olh_epoch;
bool log_op; bool log_op;
uint16_t bilog_flags; uint16_t bilog_flags;
uint64_t unmod_since; /* only create delete marker if newer then this */ real_time unmod_since; /* only create delete marker if newer then this */
rgw_cls_link_olh_op() : delete_marker(false), olh_epoch(0), log_op(false), bilog_flags(0) {} rgw_cls_link_olh_op() : delete_marker(false), olh_epoch(0), log_op(false), bilog_flags(0) {}
void encode(bufferlist& bl) const { void encode(bufferlist& bl) const {
ENCODE_START(2, 1, bl); ENCODE_START(3, 1, bl);
::encode(key, bl); ::encode(key, bl);
::encode(olh_tag, bl); ::encode(olh_tag, bl);
::encode(delete_marker, bl); ::encode(delete_marker, bl);
@ -178,12 +179,14 @@ struct rgw_cls_link_olh_op {
::encode(olh_epoch, bl); ::encode(olh_epoch, bl);
::encode(log_op, bl); ::encode(log_op, bl);
::encode(bilog_flags, bl); ::encode(bilog_flags, bl);
time_t t = ceph::real_clock::to_time_t(unmod_since);
::encode(t, bl);
::encode(unmod_since, bl); ::encode(unmod_since, bl);
ENCODE_FINISH(bl); ENCODE_FINISH(bl);
} }
void decode(bufferlist::iterator& bl) { void decode(bufferlist::iterator& bl) {
DECODE_START(2, bl); DECODE_START(3, bl);
::decode(key, bl); ::decode(key, bl);
::decode(olh_tag, bl); ::decode(olh_tag, bl);
::decode(delete_marker, bl); ::decode(delete_marker, bl);
@ -192,7 +195,12 @@ struct rgw_cls_link_olh_op {
::decode(olh_epoch, bl); ::decode(olh_epoch, bl);
::decode(log_op, bl); ::decode(log_op, bl);
::decode(bilog_flags, bl); ::decode(bilog_flags, bl);
if (struct_v >= 2) { if (struct_v == 2) {
time_t t;
::decode(t, bl);
unmod_since = ceph::real_clock::from_time_t(t);
}
if (struct_v >= 3) {
::decode(unmod_since, bl); ::decode(unmod_since, bl);
} }
DECODE_FINISH(bl); DECODE_FINISH(bl);
@ -482,7 +490,7 @@ struct rgw_cls_obj_check_attrs_prefix {
WRITE_CLASS_ENCODER(rgw_cls_obj_check_attrs_prefix) WRITE_CLASS_ENCODER(rgw_cls_obj_check_attrs_prefix)
struct rgw_cls_obj_check_mtime { struct rgw_cls_obj_check_mtime {
utime_t mtime; ceph::real_time mtime;
RGWCheckMTimeType type; RGWCheckMTimeType type;
rgw_cls_obj_check_mtime() : type(CLS_RGW_CHECK_TIME_MTIME_EQ) {} rgw_cls_obj_check_mtime() : type(CLS_RGW_CHECK_TIME_MTIME_EQ) {}

View File

@ -2,6 +2,7 @@
#include "cls/rgw/cls_rgw_types.h" #include "cls/rgw/cls_rgw_types.h"
#include "common/Formatter.h" #include "common/Formatter.h"
#include "common/ceph_json.h" #include "common/ceph_json.h"
#include "include/utime.h"
void rgw_bucket_pending_info::generate_test_instances(list<rgw_bucket_pending_info*>& o) void rgw_bucket_pending_info::generate_test_instances(list<rgw_bucket_pending_info*>& o)
@ -16,7 +17,8 @@ void rgw_bucket_pending_info::generate_test_instances(list<rgw_bucket_pending_in
void rgw_bucket_pending_info::dump(Formatter *f) const void rgw_bucket_pending_info::dump(Formatter *f) const
{ {
encode_json("state", (int)state, f); encode_json("state", (int)state, f);
encode_json("timestamp", timestamp, f); utime_t ut(timestamp);
encode_json("timestamp", ut, f);
encode_json("op", (int)op, f); encode_json("op", (int)op, f);
} }
@ -24,7 +26,8 @@ void rgw_bucket_pending_info::decode_json(JSONObj *obj) {
int val; int val;
JSONDecoder::decode_json("state", val, obj); JSONDecoder::decode_json("state", val, obj);
state = (RGWPendingState)val; state = (RGWPendingState)val;
JSONDecoder::decode_json("timestamp", timestamp, obj); utime_t ut(timestamp);
JSONDecoder::decode_json("timestamp", ut, obj);
JSONDecoder::decode_json("op", val, obj); JSONDecoder::decode_json("op", val, obj);
op = (uint8_t)val; op = (uint8_t)val;
} }
@ -51,7 +54,8 @@ void rgw_bucket_dir_entry_meta::dump(Formatter *f) const
{ {
encode_json("category", (int)category, f); encode_json("category", (int)category, f);
encode_json("size", size, f); encode_json("size", size, f);
encode_json("mtime", mtime, f); utime_t ut(mtime);
encode_json("mtime", ut, f);
encode_json("etag", etag, f); encode_json("etag", etag, f);
encode_json("owner", owner, f); encode_json("owner", owner, f);
encode_json("owner_display_name", owner_display_name, f); encode_json("owner_display_name", owner_display_name, f);
@ -64,7 +68,8 @@ void rgw_bucket_dir_entry_meta::decode_json(JSONObj *obj) {
JSONDecoder::decode_json("category", val, obj); JSONDecoder::decode_json("category", val, obj);
category = (uint8_t)val; category = (uint8_t)val;
JSONDecoder::decode_json("size", size, obj); JSONDecoder::decode_json("size", size, obj);
JSONDecoder::decode_json("mtime", mtime, obj); utime_t ut(mtime);
JSONDecoder::decode_json("mtime", ut, obj);
JSONDecoder::decode_json("etag", etag, obj); JSONDecoder::decode_json("etag", etag, obj);
JSONDecoder::decode_json("owner", owner, obj); JSONDecoder::decode_json("owner", owner, obj);
JSONDecoder::decode_json("owner_display_name", owner_display_name, obj); JSONDecoder::decode_json("owner_display_name", owner_display_name, obj);
@ -343,7 +348,9 @@ void rgw_bi_log_entry::decode_json(JSONObj *obj)
state = CLS_RGW_STATE_UNKNOWN; state = CLS_RGW_STATE_UNKNOWN;
} }
JSONDecoder::decode_json("index_ver", index_ver, obj); JSONDecoder::decode_json("index_ver", index_ver, obj);
JSONDecoder::decode_json("timestamp", timestamp, obj); utime_t ut;
JSONDecoder::decode_json("timestamp", ut, obj);
timestamp = ut.to_real_time();
uint32_t f; uint32_t f;
JSONDecoder::decode_json("bilog_flags", f, obj); JSONDecoder::decode_json("bilog_flags", f, obj);
JSONDecoder::decode_json("ver", ver, obj); JSONDecoder::decode_json("ver", ver, obj);
@ -399,7 +406,8 @@ void rgw_bi_log_entry::dump(Formatter *f) const
} }
f->dump_int("index_ver", index_ver); f->dump_int("index_ver", index_ver);
timestamp.gmtime(f->dump_stream("timestamp")); utime_t ut(timestamp);
ut.gmtime(f->dump_stream("timestamp"));
f->open_object_section("ver"); f->open_object_section("ver");
ver.dump(f); ver.dump(f);
f->close_section(); f->close_section();
@ -415,7 +423,7 @@ void rgw_bi_log_entry::generate_test_instances(list<rgw_bi_log_entry*>& ls)
ls.push_back(new rgw_bi_log_entry); ls.push_back(new rgw_bi_log_entry);
ls.back()->id = "midf"; ls.back()->id = "midf";
ls.back()->object = "obj"; ls.back()->object = "obj";
ls.back()->timestamp = utime_t(2, 3); ls.back()->timestamp = ceph::real_clock::from_ceph_timespec({2, 3});
ls.back()->index_ver = 4323; ls.back()->index_ver = 4323;
ls.back()->tag = "tagasdfds"; ls.back()->tag = "tagasdfds";
ls.back()->op = CLS_RGW_OP_DEL; ls.back()->op = CLS_RGW_OP_DEL;

View File

@ -4,7 +4,7 @@
#include <map> #include <map>
#include "include/types.h" #include "include/types.h"
#include "include/utime.h" #include "common/ceph_time.h"
#include "common/Formatter.h" #include "common/Formatter.h"
#include "rgw/rgw_basic_types.h" #include "rgw/rgw_basic_types.h"
@ -49,7 +49,7 @@ enum RGWCheckMTimeType {
struct rgw_bucket_pending_info { struct rgw_bucket_pending_info {
RGWPendingState state; RGWPendingState state;
utime_t timestamp; ceph::real_time timestamp;
uint8_t op; uint8_t op;
rgw_bucket_pending_info() : state(CLS_RGW_STATE_PENDING_MODIFY), op(0) {} rgw_bucket_pending_info() : state(CLS_RGW_STATE_PENDING_MODIFY), op(0) {}
@ -80,7 +80,7 @@ WRITE_CLASS_ENCODER(rgw_bucket_pending_info)
struct rgw_bucket_dir_entry_meta { struct rgw_bucket_dir_entry_meta {
uint8_t category; uint8_t category;
uint64_t size; uint64_t size;
utime_t mtime; ceph::real_time mtime;
string etag; string etag;
string owner; string owner;
string owner_display_name; string owner_display_name;
@ -88,7 +88,7 @@ struct rgw_bucket_dir_entry_meta {
uint64_t accounted_size; uint64_t accounted_size;
rgw_bucket_dir_entry_meta() : rgw_bucket_dir_entry_meta() :
category(0), size(0), accounted_size(0) { mtime.set_from_double(0); } category(0), size(0), accounted_size(0) { }
void encode(bufferlist &bl) const { void encode(bufferlist &bl) const {
ENCODE_START(4, 3, bl); ENCODE_START(4, 3, bl);
@ -474,7 +474,7 @@ struct rgw_bi_log_entry {
string id; string id;
string object; string object;
string instance; string instance;
utime_t timestamp; ceph::real_time timestamp;
rgw_bucket_entry_ver ver; rgw_bucket_entry_ver ver;
RGWModifyOp op; RGWModifyOp op;
RGWPendingState state; RGWPendingState state;
@ -891,7 +891,7 @@ struct cls_rgw_gc_obj_info
{ {
string tag; string tag;
cls_rgw_obj_chain chain; cls_rgw_obj_chain chain;
utime_t time; ceph::real_time time;
cls_rgw_gc_obj_info() {} cls_rgw_gc_obj_info() {}
@ -922,7 +922,8 @@ struct cls_rgw_gc_obj_info
ls.push_back(new cls_rgw_gc_obj_info); ls.push_back(new cls_rgw_gc_obj_info);
ls.push_back(new cls_rgw_gc_obj_info); ls.push_back(new cls_rgw_gc_obj_info);
ls.back()->tag = "footag"; ls.back()->tag = "footag";
ls.back()->time = utime_t(21, 32); ceph_timespec ts{21, 32};
ls.back()->time = ceph::real_clock::from_ceph_timespec(ts);
} }
}; };
WRITE_CLASS_ENCODER(cls_rgw_gc_obj_info) WRITE_CLASS_ENCODER(cls_rgw_gc_obj_info)

View File

@ -18,7 +18,7 @@ void cls_user_set_buckets(librados::ObjectWriteOperation& op, list<cls_user_buck
cls_user_set_buckets_op call; cls_user_set_buckets_op call;
call.entries = entries; call.entries = entries;
call.add = add; call.add = add;
call.time = ceph_clock_now(NULL); call.time = real_clock::now();
::encode(call, in); ::encode(call, in);
op.exec("user", "set_buckets_info", in); op.exec("user", "set_buckets_info", in);
} }
@ -27,7 +27,7 @@ void cls_user_complete_stats_sync(librados::ObjectWriteOperation& op)
{ {
bufferlist in; bufferlist in;
cls_user_complete_stats_sync_op call; cls_user_complete_stats_sync_op call;
call.time = ceph_clock_now(NULL); call.time = real_clock::now();
::encode(call, in); ::encode(call, in);
op.exec("user", "complete_stats_sync", in); op.exec("user", "complete_stats_sync", in);
} }

View File

@ -10,7 +10,7 @@ void cls_user_set_buckets_op::dump(Formatter *f) const
{ {
encode_json("entries", entries, f); encode_json("entries", entries, f);
encode_json("add", add, f); encode_json("add", add, f);
encode_json("time", time, f); encode_json("time", utime_t(time), f);
} }
void cls_user_set_buckets_op::generate_test_instances(list<cls_user_set_buckets_op*>& ls) void cls_user_set_buckets_op::generate_test_instances(list<cls_user_set_buckets_op*>& ls)
@ -23,7 +23,7 @@ void cls_user_set_buckets_op::generate_test_instances(list<cls_user_set_buckets_
op->entries.push_back(e); op->entries.push_back(e);
} }
op->add = true; op->add = true;
op->time = utime_t(1, 0); op->time = utime_t(1, 0).to_real_time();
ls.push_back(op); ls.push_back(op);
} }
@ -101,14 +101,14 @@ void cls_user_get_header_ret::generate_test_instances(list<cls_user_get_header_r
void cls_user_complete_stats_sync_op::dump(Formatter *f) const void cls_user_complete_stats_sync_op::dump(Formatter *f) const
{ {
encode_json("time", time, f); encode_json("time", utime_t(time), f);
} }
void cls_user_complete_stats_sync_op::generate_test_instances(list<cls_user_complete_stats_sync_op*>& ls) void cls_user_complete_stats_sync_op::generate_test_instances(list<cls_user_complete_stats_sync_op*>& ls)
{ {
ls.push_back(new cls_user_complete_stats_sync_op); ls.push_back(new cls_user_complete_stats_sync_op);
cls_user_complete_stats_sync_op *op = new cls_user_complete_stats_sync_op; cls_user_complete_stats_sync_op *op = new cls_user_complete_stats_sync_op;
op->time = utime_t(12345, 0); op->time = utime_t(12345, 0).to_real_time();
ls.push_back(op); ls.push_back(op);
} }

View File

@ -6,11 +6,12 @@
#include "include/types.h" #include "include/types.h"
#include "cls_user_types.h" #include "cls_user_types.h"
#include "common/ceph_time.h"
struct cls_user_set_buckets_op { struct cls_user_set_buckets_op {
list<cls_user_bucket_entry> entries; list<cls_user_bucket_entry> entries;
bool add; bool add;
utime_t time; /* op time */ real_time time; /* op time */
cls_user_set_buckets_op() : add(false) {} cls_user_set_buckets_op() : add(false) {}
@ -159,7 +160,7 @@ struct cls_user_get_header_ret {
WRITE_CLASS_ENCODER(cls_user_get_header_ret) WRITE_CLASS_ENCODER(cls_user_get_header_ret)
struct cls_user_complete_stats_sync_op { struct cls_user_complete_stats_sync_op {
utime_t time; real_time time;
cls_user_complete_stats_sync_op() {} cls_user_complete_stats_sync_op() {}

View File

@ -40,7 +40,7 @@ void cls_user_bucket_entry::dump(Formatter *f) const
encode_json("bucket", bucket, f); encode_json("bucket", bucket, f);
encode_json("size", size, f); encode_json("size", size, f);
encode_json("size_rounded", size_rounded, f); encode_json("size_rounded", size_rounded, f);
encode_json("creation_time", creation_time, f); encode_json("creation_time", utime_t(creation_time), f);
encode_json("count", count, f); encode_json("count", count, f);
encode_json("user_stats_sync", user_stats_sync, f); encode_json("user_stats_sync", user_stats_sync, f);
} }
@ -50,7 +50,7 @@ void cls_user_gen_test_bucket_entry(cls_user_bucket_entry *entry, int i)
cls_user_gen_test_bucket(&entry->bucket, i); cls_user_gen_test_bucket(&entry->bucket, i);
entry->size = i + 1; entry->size = i + 1;
entry->size_rounded = i + 2; entry->size_rounded = i + 2;
entry->creation_time = i + 3; entry->creation_time = real_clock::from_time_t(i + 3);
entry->count = i + 4; entry->count = i + 4;
entry->user_stats_sync = true; entry->user_stats_sync = true;
} }
@ -88,15 +88,15 @@ void cls_user_stats::generate_test_instances(list<cls_user_stats*>& ls)
void cls_user_gen_test_header(cls_user_header *h) void cls_user_gen_test_header(cls_user_header *h)
{ {
cls_user_gen_test_stats(&h->stats); cls_user_gen_test_stats(&h->stats);
h->last_stats_sync = utime_t(1, 0); h->last_stats_sync = utime_t(1, 0).to_real_time();
h->last_stats_update = utime_t(2, 0); h->last_stats_update = utime_t(2, 0).to_real_time();
} }
void cls_user_header::dump(Formatter *f) const void cls_user_header::dump(Formatter *f) const
{ {
encode_json("stats", stats, f); encode_json("stats", stats, f);
encode_json("last_stats_sync", last_stats_sync, f); encode_json("last_stats_sync", utime_t(last_stats_sync), f);
encode_json("last_stats_update", last_stats_update, f); encode_json("last_stats_update", utime_t(last_stats_update), f);
} }
void cls_user_header::generate_test_instances(list<cls_user_header*>& ls) void cls_user_header::generate_test_instances(list<cls_user_header*>& ls)

View File

@ -7,6 +7,7 @@
#include "include/encoding.h" #include "include/encoding.h"
#include "include/types.h" #include "include/types.h"
#include "include/utime.h" #include "include/utime.h"
#include "common/ceph_time.h"
/* /*
* this needs to be compatible with with rgw_bucket, as it replaces it * this needs to be compatible with with rgw_bucket, as it replaces it
@ -72,16 +73,16 @@ struct cls_user_bucket_entry {
cls_user_bucket bucket; cls_user_bucket bucket;
size_t size; size_t size;
size_t size_rounded; size_t size_rounded;
time_t creation_time; real_time creation_time;
uint64_t count; uint64_t count;
bool user_stats_sync; bool user_stats_sync;
cls_user_bucket_entry() : size(0), size_rounded(0), creation_time(0), count(0), user_stats_sync(false) {} cls_user_bucket_entry() : size(0), size_rounded(0), count(0), user_stats_sync(false) {}
void encode(bufferlist& bl) const { void encode(bufferlist& bl) const {
ENCODE_START(6, 5, bl); ENCODE_START(7, 5, bl);
uint64_t s = size; uint64_t s = size;
__u32 mt = creation_time; __u32 mt = ceph::real_clock::to_time_t(creation_time);
string empty_str; // originally had the bucket name here, but we encode bucket later string empty_str; // originally had the bucket name here, but we encode bucket later
::encode(empty_str, bl); ::encode(empty_str, bl);
::encode(s, bl); ::encode(s, bl);
@ -91,6 +92,7 @@ struct cls_user_bucket_entry {
s = size_rounded; s = size_rounded;
::encode(s, bl); ::encode(s, bl);
::encode(user_stats_sync, bl); ::encode(user_stats_sync, bl);
::encode(creation_time, bl);
ENCODE_FINISH(bl); ENCODE_FINISH(bl);
} }
void decode(bufferlist::iterator& bl) { void decode(bufferlist::iterator& bl) {
@ -102,7 +104,9 @@ struct cls_user_bucket_entry {
::decode(s, bl); ::decode(s, bl);
::decode(mt, bl); ::decode(mt, bl);
size = s; size = s;
creation_time = mt; if (struct_v < 7) {
creation_time = ceph::real_clock::from_time_t(mt);
}
if (struct_v >= 2) if (struct_v >= 2)
::decode(count, bl); ::decode(count, bl);
if (struct_v >= 3) if (struct_v >= 3)
@ -112,6 +116,8 @@ struct cls_user_bucket_entry {
size_rounded = s; size_rounded = s;
if (struct_v >= 6) if (struct_v >= 6)
::decode(user_stats_sync, bl); ::decode(user_stats_sync, bl);
if (struct_v >= 7)
::decode(creation_time, bl);
DECODE_FINISH(bl); DECODE_FINISH(bl);
} }
void dump(Formatter *f) const; void dump(Formatter *f) const;
@ -154,8 +160,8 @@ WRITE_CLASS_ENCODER(cls_user_stats)
*/ */
struct cls_user_header { struct cls_user_header {
cls_user_stats stats; cls_user_stats stats;
utime_t last_stats_sync; /* last time a full stats sync completed */ ceph::real_time last_stats_sync; /* last time a full stats sync completed */
utime_t last_stats_update; /* last time a stats update was done */ ceph::real_time last_stats_update; /* last time a stats update was done */
void encode(bufferlist& bl) const { void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl); ENCODE_START(1, 1, bl);

View File

@ -807,7 +807,7 @@ static void dump_bucket_usage(map<RGWObjCategory, RGWStorageStats>& stats, Forma
int bucket_stats(rgw_bucket& bucket, int shard_id, Formatter *formatter) int bucket_stats(rgw_bucket& bucket, int shard_id, Formatter *formatter)
{ {
RGWBucketInfo bucket_info; RGWBucketInfo bucket_info;
time_t mtime; real_time mtime;
RGWObjectCtx obj_ctx(store); RGWObjectCtx obj_ctx(store);
int r = store->get_bucket_info(obj_ctx, bucket.tenant, bucket.name, bucket_info, &mtime); int r = store->get_bucket_info(obj_ctx, bucket.tenant, bucket.name, bucket_info, &mtime);
if (r < 0) if (r < 0)
@ -829,7 +829,7 @@ int bucket_stats(rgw_bucket& bucket, int shard_id, Formatter *formatter)
formatter->dump_string("id", bucket.bucket_id); formatter->dump_string("id", bucket.bucket_id);
formatter->dump_string("marker", bucket.marker); formatter->dump_string("marker", bucket.marker);
::encode_json("owner", bucket_info.owner, formatter); ::encode_json("owner", bucket_info.owner, formatter);
formatter->dump_int("mtime", mtime); formatter->dump_int("mtime", utime_t(mtime));
formatter->dump_string("ver", bucket_ver); formatter->dump_string("ver", bucket_ver);
formatter->dump_string("master_ver", master_ver); formatter->dump_string("master_ver", master_ver);
formatter->dump_string("max_marker", max_marker); formatter->dump_string("max_marker", max_marker);
@ -1043,7 +1043,7 @@ int set_bucket_quota(RGWRados *store, int opt_cmd,
set_quota_info(bucket_info.quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects); set_quota_info(bucket_info.quota, opt_cmd, max_size, max_objects, have_max_size, have_max_objects);
r = store->put_bucket_instance_info(bucket_info, false, 0, &attrs); r = store->put_bucket_instance_info(bucket_info, false, real_time(), &attrs);
if (r < 0) { if (r < 0) {
cerr << "ERROR: failed writing bucket instance info: " << cpp_strerror(-r) << std::endl; cerr << "ERROR: failed writing bucket instance info: " << cpp_strerror(-r) << std::endl;
return -r; return -r;
@ -1704,21 +1704,21 @@ static void get_md_sync_status(list<string>& status)
if (ret < 0) { if (ret < 0) {
derr << "ERROR: failed to fetch master next positions (" << cpp_strerror(-ret) << ")" << dendl; derr << "ERROR: failed to fetch master next positions (" << cpp_strerror(-ret) << ")" << dendl;
} else { } else {
utime_t oldest; ceph::real_time oldest;
for (auto iter : master_pos) { for (auto iter : master_pos) {
rgw_mdlog_shard_data& shard_data = iter.second; rgw_mdlog_shard_data& shard_data = iter.second;
if (!shard_data.entries.empty()) { if (!shard_data.entries.empty()) {
rgw_mdlog_entry& entry = shard_data.entries.front(); rgw_mdlog_entry& entry = shard_data.entries.front();
if (oldest.is_zero()) { if (ceph::real_clock::is_zero(oldest)) {
oldest = entry.timestamp; oldest = entry.timestamp;
} else if (!entry.timestamp.is_zero() && entry.timestamp < oldest) { } else if (!ceph::real_clock::is_zero(entry.timestamp) && entry.timestamp < oldest) {
oldest = entry.timestamp; oldest = entry.timestamp;
} }
} }
} }
if (!oldest.is_zero()) { if (!ceph::real_clock::is_zero(oldest)) {
push_ss(ss, status) << "oldest incremental change not applied: " << oldest; push_ss(ss, status) << "oldest incremental change not applied: " << oldest;
} }
} }
@ -1838,21 +1838,21 @@ static void get_data_sync_status(const string& source_zone, list<string>& status
if (ret < 0) { if (ret < 0) {
derr << "ERROR: failed to fetch next positions (" << cpp_strerror(-ret) << ")" << dendl; derr << "ERROR: failed to fetch next positions (" << cpp_strerror(-ret) << ")" << dendl;
} else { } else {
utime_t oldest; ceph::real_time oldest;
for (auto iter : master_pos) { for (auto iter : master_pos) {
rgw_datalog_shard_data& shard_data = iter.second; rgw_datalog_shard_data& shard_data = iter.second;
if (!shard_data.entries.empty()) { if (!shard_data.entries.empty()) {
rgw_datalog_entry& entry = shard_data.entries.front(); rgw_datalog_entry& entry = shard_data.entries.front();
if (oldest.is_zero()) { if (ceph::real_clock::is_zero(oldest)) {
oldest = entry.timestamp; oldest = entry.timestamp;
} else if (!entry.timestamp.is_zero() && entry.timestamp < oldest) { } else if (!ceph::real_clock::is_zero(entry.timestamp) && entry.timestamp < oldest) {
oldest = entry.timestamp; oldest = entry.timestamp;
} }
} }
} }
if (!oldest.is_zero()) { if (!ceph::real_clock::is_zero(oldest)) {
push_ss(ss, status, tab) << "oldest incremental change not applied: " << oldest; push_ss(ss, status, tab) << "oldest incremental change not applied: " << oldest;
} }
} }
@ -4399,7 +4399,7 @@ next:
formatter->dump_string("name", key.name); formatter->dump_string("name", key.name);
formatter->dump_string("instance", key.instance); formatter->dump_string("instance", key.instance);
formatter->dump_int("size", entry.size); formatter->dump_int("size", entry.size);
utime_t ut(entry.mtime, 0); utime_t ut(entry.mtime);
ut.gmtime(formatter->dump_stream("mtime")); ut.gmtime(formatter->dump_stream("mtime"));
if ((entry.size < min_rewrite_size) || if ((entry.size < min_rewrite_size) ||
@ -4753,8 +4753,7 @@ next:
list<cls_log_entry> entries; list<cls_log_entry> entries;
meta_log->init_list_entries(i, start_time, end_time, marker, &handle); meta_log->init_list_entries(i, start_time.to_real_time(), end_time.to_real_time(), marker, &handle);
bool truncated; bool truncated;
do { do {
int ret = meta_log->list_entries(handle, 1000, entries, NULL, &truncated); int ret = meta_log->list_entries(handle, 1000, entries, NULL, &truncated);
@ -4833,7 +4832,7 @@ next:
} }
RGWMetadataLog *meta_log = store->meta_mgr->get_log(period_id); RGWMetadataLog *meta_log = store->meta_mgr->get_log(period_id);
ret = meta_log->trim(shard_id, start_time, end_time, start_marker, end_marker); ret = meta_log->trim(shard_id, start_time.to_real_time(), end_time.to_real_time(), start_marker, end_marker);
if (ret < 0) { if (ret < 0) {
cerr << "ERROR: meta_log->trim(): " << cpp_strerror(-ret) << std::endl; cerr << "ERROR: meta_log->trim(): " << cpp_strerror(-ret) << std::endl;
return -ret; return -ret;
@ -5162,8 +5161,8 @@ next:
do { do {
list<cls_log_entry> entries; list<cls_log_entry> entries;
ret = store->time_log_list(oid, start_time, end_time, max_entries - count, entries, ret = store->time_log_list(oid, start_time.to_real_time(), end_time.to_real_time(),
marker, &marker, &truncated); max_entries - count, entries, marker, &marker, &truncated);
if (ret == -ENOENT) { if (ret == -ENOENT) {
break; break;
} }
@ -5247,7 +5246,7 @@ next:
do { do {
list<rgw_data_change_log_entry> entries; list<rgw_data_change_log_entry> entries;
ret = log->list_entries(start_time, end_time, max_entries - count, entries, marker, &truncated); ret = log->list_entries(start_time.to_real_time(), end_time.to_real_time(), max_entries - count, entries, marker, &truncated);
if (ret < 0) { if (ret < 0) {
cerr << "ERROR: list_bi_log_entries(): " << cpp_strerror(-ret) << std::endl; cerr << "ERROR: list_bi_log_entries(): " << cpp_strerror(-ret) << std::endl;
return -ret; return -ret;
@ -5303,7 +5302,7 @@ next:
return -ret; return -ret;
RGWDataChangesLog *log = store->data_log; RGWDataChangesLog *log = store->data_log;
ret = log->trim_entries(start_time, end_time, start_marker, end_marker); ret = log->trim_entries(start_time.to_real_time(), end_time.to_real_time(), start_marker, end_marker);
if (ret < 0) { if (ret < 0) {
cerr << "ERROR: trim_entries(): " << cpp_strerror(-ret) << std::endl; cerr << "ERROR: trim_entries(): " << cpp_strerror(-ret) << std::endl;
return -ret; return -ret;

View File

@ -178,7 +178,7 @@ int rgw_bucket_sync_user_stats(RGWRados *store, const string& tenant_name, const
return 0; return 0;
} }
int rgw_link_bucket(RGWRados *store, const rgw_user& user_id, rgw_bucket& bucket, time_t creation_time, bool update_entrypoint) int rgw_link_bucket(RGWRados *store, const rgw_user& user_id, rgw_bucket& bucket, real_time creation_time, bool update_entrypoint)
{ {
int ret; int ret;
string& tenant_name = bucket.tenant; string& tenant_name = bucket.tenant;
@ -191,8 +191,8 @@ int rgw_link_bucket(RGWRados *store, const rgw_user& user_id, rgw_bucket& bucket
bucket.convert(&new_bucket.bucket); bucket.convert(&new_bucket.bucket);
new_bucket.size = 0; new_bucket.size = 0;
if (!creation_time) if (real_clock::is_zero(creation_time))
time(&new_bucket.creation_time); new_bucket.creation_time = real_clock::now();
else else
new_bucket.creation_time = creation_time; new_bucket.creation_time = creation_time;
@ -222,7 +222,7 @@ int rgw_link_bucket(RGWRados *store, const rgw_user& user_id, rgw_bucket& bucket
ep.linked = true; ep.linked = true;
ep.owner = user_id; ep.owner = user_id;
ret = store->put_bucket_entrypoint_info(tenant_name, bucket_name, ep, false, ot, 0, &attrs); ret = store->put_bucket_entrypoint_info(tenant_name, bucket_name, ep, false, ot, real_time(), &attrs);
if (ret < 0) if (ret < 0)
goto done_err; goto done_err;
@ -275,7 +275,7 @@ int rgw_unlink_bucket(RGWRados *store, const rgw_user& user_id, const string& te
} }
ep.linked = false; ep.linked = false;
ret = store->put_bucket_entrypoint_info(tenant_name, bucket_name, ep, false, ot, 0, &attrs); ret = store->put_bucket_entrypoint_info(tenant_name, bucket_name, ep, false, ot, real_time(), &attrs);
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -284,13 +284,13 @@ int rgw_unlink_bucket(RGWRados *store, const rgw_user& user_id, const string& te
int rgw_bucket_store_info(RGWRados *store, const string& bucket_name, bufferlist& bl, bool exclusive, int rgw_bucket_store_info(RGWRados *store, const string& bucket_name, bufferlist& bl, bool exclusive,
map<string, bufferlist> *pattrs, RGWObjVersionTracker *objv_tracker, map<string, bufferlist> *pattrs, RGWObjVersionTracker *objv_tracker,
time_t mtime) { real_time mtime) {
return store->meta_mgr->put_entry(bucket_meta_handler, bucket_name, bl, exclusive, objv_tracker, mtime, pattrs); return store->meta_mgr->put_entry(bucket_meta_handler, bucket_name, bl, exclusive, objv_tracker, mtime, pattrs);
} }
int rgw_bucket_instance_store_info(RGWRados *store, string& entry, bufferlist& bl, bool exclusive, int rgw_bucket_instance_store_info(RGWRados *store, string& entry, bufferlist& bl, bool exclusive,
map<string, bufferlist> *pattrs, RGWObjVersionTracker *objv_tracker, map<string, bufferlist> *pattrs, RGWObjVersionTracker *objv_tracker,
time_t mtime) { real_time mtime) {
return store->meta_mgr->put_entry(bucket_instance_meta_handler, entry, bl, exclusive, objv_tracker, mtime, pattrs); return store->meta_mgr->put_entry(bucket_instance_meta_handler, entry, bl, exclusive, objv_tracker, mtime, pattrs);
} }
@ -350,7 +350,7 @@ int rgw_bucket_set_attrs(RGWRados *store, RGWBucketInfo& bucket_info,
::encode(bucket_info, bl); ::encode(bucket_info, bl);
return rgw_bucket_instance_store_info(store, key, bl, false, &attrs, objv_tracker, 0); return rgw_bucket_instance_store_info(store, key, bl, false, &attrs, objv_tracker, real_time());
} }
static void dump_mulipart_index_results(list<rgw_obj_key>& objs_to_unlink, static void dump_mulipart_index_results(list<rgw_obj_key>& objs_to_unlink,
@ -400,7 +400,7 @@ void check_bad_user_bucket_mapping(RGWRados *store, const rgw_user& user_id,
rgw_bucket& bucket = bucket_ent.bucket; rgw_bucket& bucket = bucket_ent.bucket;
RGWBucketInfo bucket_info; RGWBucketInfo bucket_info;
time_t mtime; real_time mtime;
RGWObjectCtx obj_ctx(store); RGWObjectCtx obj_ctx(store);
int r = store->get_bucket_info(obj_ctx, user_id.tenant, bucket.name, bucket_info, &mtime); int r = store->get_bucket_info(obj_ctx, user_id.tenant, bucket.name, bucket_info, &mtime);
if (r < 0) { if (r < 0) {
@ -664,7 +664,7 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg)
rgw_obj obj_bucket_instance(bucket_instance, no_oid); rgw_obj obj_bucket_instance(bucket_instance, no_oid);
r = store->system_obj_set_attr(NULL, obj_bucket_instance, RGW_ATTR_ACL, aclbl, &objv_tracker); r = store->system_obj_set_attr(NULL, obj_bucket_instance, RGW_ATTR_ACL, aclbl, &objv_tracker);
r = rgw_link_bucket(store, user_info.user_id, bucket, 0); r = rgw_link_bucket(store, user_info.user_id, bucket, real_time());
if (r < 0) if (r < 0)
return r; return r;
} }
@ -1129,7 +1129,7 @@ static int bucket_stats(RGWRados *store, const std::string& tenant_name, std::st
rgw_bucket bucket; rgw_bucket bucket;
map<RGWObjCategory, RGWStorageStats> stats; map<RGWObjCategory, RGWStorageStats> stats;
time_t mtime; real_time mtime;
RGWObjectCtx obj_ctx(store); RGWObjectCtx obj_ctx(store);
int r = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, &mtime); int r = store->get_bucket_info(obj_ctx, tenant_name, bucket_name, bucket_info, &mtime);
if (r < 0) if (r < 0)
@ -1145,7 +1145,7 @@ static int bucket_stats(RGWRados *store, const std::string& tenant_name, std::st
return ret; return ret;
} }
utime_t ut(mtime, 0); utime_t ut(mtime);
formatter->open_object_section("stats"); formatter->open_object_section("stats");
formatter->dump_string("bucket", bucket.name); formatter->dump_string("bucket", bucket.name);
@ -1259,7 +1259,8 @@ void rgw_data_change::dump(Formatter *f) const
} }
encode_json("entity_type", type, f); encode_json("entity_type", type, f);
encode_json("key", key, f); encode_json("key", key, f);
encode_json("timestamp", timestamp, f); utime_t ut(timestamp);
encode_json("timestamp", ut, f);
} }
void rgw_data_change::decode_json(JSONObj *obj) { void rgw_data_change::decode_json(JSONObj *obj) {
@ -1271,19 +1272,24 @@ void rgw_data_change::decode_json(JSONObj *obj) {
entity_type = ENTITY_TYPE_UNKNOWN; entity_type = ENTITY_TYPE_UNKNOWN;
} }
JSONDecoder::decode_json("key", key, obj); JSONDecoder::decode_json("key", key, obj);
JSONDecoder::decode_json("timestamp", timestamp, obj); utime_t ut;
JSONDecoder::decode_json("timestamp", ut, obj);
timestamp = ut.to_real_time();
} }
void rgw_data_change_log_entry::dump(Formatter *f) const void rgw_data_change_log_entry::dump(Formatter *f) const
{ {
encode_json("log_id", log_id, f); encode_json("log_id", log_id, f);
encode_json("log_timestamp", log_timestamp, f); utime_t ut(log_timestamp);
encode_json("log_timestamp", ut, f);
encode_json("entry", entry, f); encode_json("entry", entry, f);
} }
void rgw_data_change_log_entry::decode_json(JSONObj *obj) { void rgw_data_change_log_entry::decode_json(JSONObj *obj) {
JSONDecoder::decode_json("log_id", log_id, obj); JSONDecoder::decode_json("log_id", log_id, obj);
JSONDecoder::decode_json("log_timestamp", log_timestamp, obj); utime_t ut;
JSONDecoder::decode_json("log_timestamp", ut, obj);
log_timestamp = ut.to_real_time();
JSONDecoder::decode_json("entry", entry, obj); JSONDecoder::decode_json("entry", entry, obj);
} }
@ -1311,7 +1317,7 @@ int RGWDataChangesLog::renew_entries()
map<rgw_bucket_shard, bool>::iterator iter; map<rgw_bucket_shard, bool>::iterator iter;
string section; string section;
utime_t ut = ceph_clock_now(cct); real_time ut = real_clock::now();
for (iter = entries.begin(); iter != entries.end(); ++iter) { for (iter = entries.begin(); iter != entries.end(); ++iter) {
const rgw_bucket_shard& bs = iter->first; const rgw_bucket_shard& bs = iter->first;
const rgw_bucket& bucket = bs.bucket; const rgw_bucket& bucket = bs.bucket;
@ -1343,7 +1349,7 @@ int RGWDataChangesLog::renew_entries()
for (miter = m.begin(); miter != m.end(); ++miter) { for (miter = m.begin(); miter != m.end(); ++miter) {
list<cls_log_entry>& entries = miter->second.second; list<cls_log_entry>& entries = miter->second.second;
utime_t now = ceph_clock_now(cct); real_time now = real_clock::now();
int ret = store->time_log_add(oids[miter->first], entries, NULL); int ret = store->time_log_add(oids[miter->first], entries, NULL);
if (ret < 0) { if (ret < 0) {
@ -1353,8 +1359,8 @@ int RGWDataChangesLog::renew_entries()
return ret; return ret;
} }
utime_t expiration = now; real_time expiration = now;
expiration += utime_t(cct->_conf->rgw_data_log_window, 0); expiration += timespan(cct->_conf->rgw_data_log_window);
list<rgw_bucket_shard>& buckets = miter->second.first; list<rgw_bucket_shard>& buckets = miter->second.first;
list<rgw_bucket_shard>::iterator liter; list<rgw_bucket_shard>::iterator liter;
@ -1381,7 +1387,7 @@ void RGWDataChangesLog::register_renew(rgw_bucket_shard& bs)
cur_cycle[bs] = true; cur_cycle[bs] = true;
} }
void RGWDataChangesLog::update_renewed(rgw_bucket_shard& bs, utime_t& expiration) void RGWDataChangesLog::update_renewed(rgw_bucket_shard& bs, real_time& expiration)
{ {
Mutex::Locker l(lock); Mutex::Locker l(lock);
ChangeStatusPtr status; ChangeStatusPtr status;
@ -1413,7 +1419,7 @@ int RGWDataChangesLog::add_entry(rgw_bucket& bucket, int shard_id) {
lock.Unlock(); lock.Unlock();
utime_t now = ceph_clock_now(cct); real_time now = real_clock::now();
status->lock->Lock(); status->lock->Lock();
@ -1449,7 +1455,7 @@ int RGWDataChangesLog::add_entry(rgw_bucket& bucket, int shard_id) {
status->pending = true; status->pending = true;
string& oid = oids[index]; string& oid = oids[index];
utime_t expiration; real_time expiration;
int ret; int ret;
@ -1457,7 +1463,7 @@ int RGWDataChangesLog::add_entry(rgw_bucket& bucket, int shard_id) {
status->cur_sent = now; status->cur_sent = now;
expiration = now; expiration = now;
expiration += utime_t(cct->_conf->rgw_data_log_window, 0); expiration += timespan(cct->_conf->rgw_data_log_window);
status->lock->Unlock(); status->lock->Unlock();
@ -1478,17 +1484,17 @@ int RGWDataChangesLog::add_entry(rgw_bucket& bucket, int shard_id) {
ret = store->time_log_add(oid, now, section, change.key, bl); ret = store->time_log_add(oid, now, section, change.key, bl);
now = ceph_clock_now(cct); now = real_clock::now();
status->lock->Lock(); status->lock->Lock();
} while (!ret && ceph_clock_now(cct) > expiration); } while (!ret && real_clock::now() > expiration);
cond = status->cond; cond = status->cond;
status->pending = false; status->pending = false;
status->cur_expiration = status->cur_sent; /* time of when operation started, not completed */ status->cur_expiration = status->cur_sent; /* time of when operation started, not completed */
status->cur_expiration += utime_t(cct->_conf->rgw_data_log_window, 0); status->cur_expiration += timespan(cct->_conf->rgw_data_log_window);
status->cond = NULL; status->cond = NULL;
status->lock->Unlock(); status->lock->Unlock();
@ -1498,7 +1504,7 @@ int RGWDataChangesLog::add_entry(rgw_bucket& bucket, int shard_id) {
return ret; return ret;
} }
int RGWDataChangesLog::list_entries(int shard, utime_t& start_time, utime_t& end_time, int max_entries, int RGWDataChangesLog::list_entries(int shard, const real_time& start_time, const real_time& end_time, int max_entries,
list<rgw_data_change_log_entry>& entries, list<rgw_data_change_log_entry>& entries,
const string& marker, const string& marker,
string *out_marker, string *out_marker,
@ -1516,7 +1522,8 @@ int RGWDataChangesLog::list_entries(int shard, utime_t& start_time, utime_t& end
for (iter = log_entries.begin(); iter != log_entries.end(); ++iter) { for (iter = log_entries.begin(); iter != log_entries.end(); ++iter) {
rgw_data_change_log_entry log_entry; rgw_data_change_log_entry log_entry;
log_entry.log_id = iter->id; log_entry.log_id = iter->id;
log_entry.log_timestamp = iter->timestamp; real_time rt = iter->timestamp.to_real_time();
log_entry.log_timestamp = rt;
bufferlist::iterator liter = iter->data.begin(); bufferlist::iterator liter = iter->data.begin();
try { try {
::decode(log_entry.entry, liter); ::decode(log_entry.entry, liter);
@ -1530,7 +1537,7 @@ int RGWDataChangesLog::list_entries(int shard, utime_t& start_time, utime_t& end
return 0; return 0;
} }
int RGWDataChangesLog::list_entries(utime_t& start_time, utime_t& end_time, int max_entries, int RGWDataChangesLog::list_entries(const real_time& start_time, const real_time& end_time, int max_entries,
list<rgw_data_change_log_entry>& entries, LogMarker& marker, bool *ptruncated) { list<rgw_data_change_log_entry>& entries, LogMarker& marker, bool *ptruncated) {
bool truncated; bool truncated;
entries.clear(); entries.clear();
@ -1570,12 +1577,12 @@ int RGWDataChangesLog::get_info(int shard_id, RGWDataChangesLogInfo *info)
return ret; return ret;
info->marker = header.max_marker; info->marker = header.max_marker;
info->last_update = header.max_time; info->last_update = header.max_time.to_real_time();
return 0; return 0;
} }
int RGWDataChangesLog::trim_entries(int shard_id, const utime_t& start_time, const utime_t& end_time, int RGWDataChangesLog::trim_entries(int shard_id, const real_time& start_time, const real_time& end_time,
const string& start_marker, const string& end_marker) const string& start_marker, const string& end_marker)
{ {
int ret; int ret;
@ -1591,7 +1598,7 @@ int RGWDataChangesLog::trim_entries(int shard_id, const utime_t& start_time, con
return ret; return ret;
} }
int RGWDataChangesLog::trim_entries(const utime_t& start_time, const utime_t& end_time, int RGWDataChangesLog::trim_entries(const real_time& start_time, const real_time& end_time,
const string& start_marker, const string& end_marker) const string& start_marker, const string& end_marker)
{ {
for (int shard = 0; shard < num_shards; shard++) { for (int shard = 0; shard < num_shards; shard++) {
@ -1692,7 +1699,7 @@ public:
RGWObjVersionTracker ot; RGWObjVersionTracker ot;
RGWBucketEntryPoint be; RGWBucketEntryPoint be;
time_t mtime; real_time mtime;
map<string, bufferlist> attrs; map<string, bufferlist> attrs;
RGWObjectCtx obj_ctx(store); RGWObjectCtx obj_ctx(store);
@ -1710,7 +1717,7 @@ public:
} }
int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker, int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker,
time_t mtime, JSONObj *obj, sync_type_t sync_type) { real_time mtime, JSONObj *obj, sync_type_t sync_type) {
RGWBucketEntryPoint be, old_be; RGWBucketEntryPoint be, old_be;
try { try {
decode_json_obj(be, obj); decode_json_obj(be, obj);
@ -1718,7 +1725,7 @@ public:
return -EINVAL; return -EINVAL;
} }
time_t orig_mtime; real_time orig_mtime;
map<string, bufferlist> attrs; map<string, bufferlist> attrs;
RGWObjVersionTracker old_ot; RGWObjVersionTracker old_ot;
@ -1850,7 +1857,7 @@ public:
int get(RGWRados *store, string& oid, RGWMetadataObject **obj) { int get(RGWRados *store, string& oid, RGWMetadataObject **obj) {
RGWBucketCompleteInfo bci; RGWBucketCompleteInfo bci;
time_t mtime; real_time mtime;
RGWObjectCtx obj_ctx(store); RGWObjectCtx obj_ctx(store);
int ret = store->get_bucket_instance_info(obj_ctx, oid, bci.info, &mtime, &bci.attrs); int ret = store->get_bucket_instance_info(obj_ctx, oid, bci.info, &mtime, &bci.attrs);
@ -1865,7 +1872,7 @@ public:
} }
int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker, int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker,
time_t mtime, JSONObj *obj, sync_type_t sync_type) { real_time mtime, JSONObj *obj, sync_type_t sync_type) {
RGWBucketCompleteInfo bci, old_bci; RGWBucketCompleteInfo bci, old_bci;
try { try {
decode_json_obj(bci, obj); decode_json_obj(bci, obj);
@ -1873,7 +1880,7 @@ public:
return -EINVAL; return -EINVAL;
} }
time_t orig_mtime; real_time orig_mtime;
RGWObjectCtx obj_ctx(store); RGWObjectCtx obj_ctx(store);
int ret = store->get_bucket_instance_info(obj_ctx, entry, old_bci.info, int ret = store->get_bucket_instance_info(obj_ctx, entry, old_bci.info,

View File

@ -17,6 +17,7 @@
#include "common/Formatter.h" #include "common/Formatter.h"
#include "common/lru_map.h" #include "common/lru_map.h"
#include "common/ceph_time.h"
#include "rgw_formats.h" #include "rgw_formats.h"
@ -27,10 +28,10 @@ extern void rgw_get_buckets_obj(const rgw_user& user_id, string& buckets_obj_id)
extern int rgw_bucket_store_info(RGWRados *store, const string& bucket_name, bufferlist& bl, bool exclusive, extern int rgw_bucket_store_info(RGWRados *store, const string& bucket_name, bufferlist& bl, bool exclusive,
map<string, bufferlist> *pattrs, RGWObjVersionTracker *objv_tracker, map<string, bufferlist> *pattrs, RGWObjVersionTracker *objv_tracker,
time_t mtime); real_time mtime);
extern int rgw_bucket_instance_store_info(RGWRados *store, string& oid, bufferlist& bl, bool exclusive, extern int rgw_bucket_instance_store_info(RGWRados *store, string& oid, bufferlist& bl, bool exclusive,
map<string, bufferlist> *pattrs, RGWObjVersionTracker *objv_tracker, map<string, bufferlist> *pattrs, RGWObjVersionTracker *objv_tracker,
time_t mtime); real_time mtime);
extern int rgw_bucket_parse_bucket_instance(const string& bucket_instance, string *target_bucket_instance, int *shard_id); extern int rgw_bucket_parse_bucket_instance(const string& bucket_instance, string *target_bucket_instance, int *shard_id);
@ -64,7 +65,7 @@ struct RGWBucketCompleteInfo {
class RGWBucketEntryMetadataObject : public RGWMetadataObject { class RGWBucketEntryMetadataObject : public RGWMetadataObject {
RGWBucketEntryPoint ep; RGWBucketEntryPoint ep;
public: public:
RGWBucketEntryMetadataObject(RGWBucketEntryPoint& _ep, obj_version& v, time_t m) : ep(_ep) { RGWBucketEntryMetadataObject(RGWBucketEntryPoint& _ep, obj_version& v, real_time m) : ep(_ep) {
objv = v; objv = v;
mtime = m; mtime = m;
} }
@ -78,7 +79,7 @@ class RGWBucketInstanceMetadataObject : public RGWMetadataObject {
RGWBucketCompleteInfo info; RGWBucketCompleteInfo info;
public: public:
RGWBucketInstanceMetadataObject() {} RGWBucketInstanceMetadataObject() {}
RGWBucketInstanceMetadataObject(RGWBucketCompleteInfo& i, obj_version& v, time_t m) : info(i) { RGWBucketInstanceMetadataObject(RGWBucketCompleteInfo& i, obj_version& v, real_time m) : info(i) {
objv = v; objv = v;
mtime = m; mtime = m;
} }
@ -167,7 +168,7 @@ extern int rgw_read_user_buckets(RGWRados *store,
bool* is_truncated, bool* is_truncated,
uint64_t default_amount = 1000); uint64_t default_amount = 1000);
extern int rgw_link_bucket(RGWRados *store, const rgw_user& user_id, rgw_bucket& bucket, time_t creation_time, bool update_entrypoint = true); extern int rgw_link_bucket(RGWRados *store, const rgw_user& user_id, rgw_bucket& bucket, real_time creation_time, bool update_entrypoint = true);
extern int rgw_unlink_bucket(RGWRados *store, const rgw_user& user_id, extern int rgw_unlink_bucket(RGWRados *store, const rgw_user& user_id,
const string& tenant_name, const string& bucket_name, bool update_entrypoint = true); const string& tenant_name, const string& bucket_name, bool update_entrypoint = true);
@ -315,7 +316,7 @@ enum DataLogEntityType {
struct rgw_data_change { struct rgw_data_change {
DataLogEntityType entity_type; DataLogEntityType entity_type;
string key; string key;
utime_t timestamp; real_time timestamp;
void encode(bufferlist& bl) const { void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl); ENCODE_START(1, 1, bl);
@ -343,7 +344,7 @@ WRITE_CLASS_ENCODER(rgw_data_change)
struct rgw_data_change_log_entry { struct rgw_data_change_log_entry {
string log_id; string log_id;
utime_t log_timestamp; real_time log_timestamp;
rgw_data_change entry; rgw_data_change entry;
void encode(bufferlist& bl) const { void encode(bufferlist& bl) const {
@ -369,7 +370,7 @@ WRITE_CLASS_ENCODER(rgw_data_change_log_entry)
struct RGWDataChangesLogInfo { struct RGWDataChangesLogInfo {
string marker; string marker;
utime_t last_update; real_time last_update;
void dump(Formatter *f) const; void dump(Formatter *f) const;
void decode_json(JSONObj *obj); void decode_json(JSONObj *obj);
@ -389,8 +390,8 @@ class RGWDataChangesLog {
atomic_t down_flag; atomic_t down_flag;
struct ChangeStatus { struct ChangeStatus {
utime_t cur_expiration; real_time cur_expiration;
utime_t cur_sent; real_time cur_sent;
bool pending; bool pending;
RefCountedCond *cond; RefCountedCond *cond;
Mutex *lock; Mutex *lock;
@ -412,7 +413,7 @@ class RGWDataChangesLog {
void _get_change(const rgw_bucket_shard& bs, ChangeStatusPtr& status); void _get_change(const rgw_bucket_shard& bs, ChangeStatusPtr& status);
void register_renew(rgw_bucket_shard& bs); void register_renew(rgw_bucket_shard& bs);
void update_renewed(rgw_bucket_shard& bs, utime_t& expiration); void update_renewed(rgw_bucket_shard& bs, real_time& expiration);
class ChangesRenewThread : public Thread { class ChangesRenewThread : public Thread {
CephContext *cct; CephContext *cct;
@ -459,17 +460,17 @@ public:
int add_entry(rgw_bucket& bucket, int shard_id); int add_entry(rgw_bucket& bucket, int shard_id);
int get_log_shard_id(rgw_bucket& bucket, int shard_id); int get_log_shard_id(rgw_bucket& bucket, int shard_id);
int renew_entries(); int renew_entries();
int list_entries(int shard, utime_t& start_time, utime_t& end_time, int max_entries, int list_entries(int shard, const real_time& start_time, const real_time& end_time, int max_entries,
list<rgw_data_change_log_entry>& entries, list<rgw_data_change_log_entry>& entries,
const string& marker, const string& marker,
string *out_marker, string *out_marker,
bool *truncated); bool *truncated);
int trim_entries(int shard_id, const utime_t& start_time, const utime_t& end_time, int trim_entries(int shard_id, const real_time& start_time, const real_time& end_time,
const string& start_marker, const string& end_marker); const string& start_marker, const string& end_marker);
int trim_entries(const utime_t& start_time, const utime_t& end_time, int trim_entries(const real_time& start_time, const real_time& end_time,
const string& start_marker, const string& end_marker); const string& start_marker, const string& end_marker);
int get_info(int shard_id, RGWDataChangesLogInfo *info); int get_info(int shard_id, RGWDataChangesLogInfo *info);
int lock_exclusive(int shard_id, utime_t& duration, string& zone_id, string& owner_id) { int lock_exclusive(int shard_id, timespan duration, string& zone_id, string& owner_id) {
return store->lock_exclusive(store->get_zone_params().log_pool, oids[shard_id], duration, zone_id, owner_id); return store->lock_exclusive(store->get_zone_params().log_pool, oids[shard_id], duration, zone_id, owner_id);
} }
int unlock(int shard_id, string& zone_id, string& owner_id) { int unlock(int shard_id, string& zone_id, string& owner_id) {
@ -481,7 +482,7 @@ public:
LogMarker() : shard(0) {} LogMarker() : shard(0) {}
}; };
int list_entries(utime_t& start_time, utime_t& end_time, int max_entries, int list_entries(const real_time& start_time, const real_time& end_time, int max_entries,
list<rgw_data_change_log_entry>& entries, LogMarker& marker, bool *ptruncated); list<rgw_data_change_log_entry>& entries, LogMarker& marker, bool *ptruncated);
void mark_modified(int shard_id, rgw_bucket_shard& bs); void mark_modified(int shard_id, rgw_bucket_shard& bs);

View File

@ -27,23 +27,20 @@ enum {
struct ObjectMetaInfo { struct ObjectMetaInfo {
uint64_t size; uint64_t size;
time_t mtime; real_time mtime;
ObjectMetaInfo() : size(0), mtime(0) {} ObjectMetaInfo() : size(0) {}
void encode(bufferlist& bl) const { void encode(bufferlist& bl) const {
ENCODE_START(2, 2, bl); ENCODE_START(2, 2, bl);
::encode(size, bl); ::encode(size, bl);
utime_t t(mtime, 0); ::encode(mtime, bl);
::encode(t, bl);
ENCODE_FINISH(bl); ENCODE_FINISH(bl);
} }
void decode(bufferlist::iterator& bl) { void decode(bufferlist::iterator& bl) {
DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
::decode(size, bl); ::decode(size, bl);
utime_t t; ::decode(mtime, bl);
::decode(t, bl);
mtime = t.sec();
DECODE_FINISH(bl); DECODE_FINISH(bl);
} }
void dump(Formatter *f) const; void dump(Formatter *f) const;
@ -231,11 +228,11 @@ public:
map<string, bufferlist>& attrs, map<string, bufferlist>& attrs,
map<string, bufferlist>* rmattrs, map<string, bufferlist>* rmattrs,
RGWObjVersionTracker *objv_tracker); RGWObjVersionTracker *objv_tracker);
int put_system_obj_impl(rgw_obj& obj, uint64_t size, time_t *mtime, int put_system_obj_impl(rgw_obj& obj, uint64_t size, real_time *mtime,
map<std::string, bufferlist>& attrs, int flags, map<std::string, bufferlist>& attrs, int flags,
bufferlist& data, bufferlist& data,
RGWObjVersionTracker *objv_tracker, RGWObjVersionTracker *objv_tracker,
time_t set_mtime); real_time set_mtime);
int put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl, off_t ofs, bool exclusive); int put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl, off_t ofs, bool exclusive);
int get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read::GetObjState& read_state, int get_system_obj(RGWObjectCtx& obj_ctx, RGWRados::SystemObject::Read::GetObjState& read_state,
@ -244,7 +241,7 @@ public:
map<string, bufferlist> *attrs, map<string, bufferlist> *attrs,
rgw_cache_entry_info *cache_info); rgw_cache_entry_info *cache_info);
int raw_obj_stat(rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64_t *epoch, map<string, bufferlist> *attrs, int raw_obj_stat(rgw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch, map<string, bufferlist> *attrs,
bufferlist *first_chunk, RGWObjVersionTracker *objv_tracker); bufferlist *first_chunk, RGWObjVersionTracker *objv_tracker);
int delete_system_obj(rgw_obj& obj, RGWObjVersionTracker *objv_tracker); int delete_system_obj(rgw_obj& obj, RGWObjVersionTracker *objv_tracker);
@ -387,11 +384,11 @@ int RGWCache<T>::system_obj_set_attrs(void *ctx, rgw_obj& obj,
} }
template <class T> template <class T>
int RGWCache<T>::put_system_obj_impl(rgw_obj& obj, uint64_t size, time_t *mtime, int RGWCache<T>::put_system_obj_impl(rgw_obj& obj, uint64_t size, real_time *mtime,
map<std::string, bufferlist>& attrs, int flags, map<std::string, bufferlist>& attrs, int flags,
bufferlist& data, bufferlist& data,
RGWObjVersionTracker *objv_tracker, RGWObjVersionTracker *objv_tracker,
time_t set_mtime) real_time set_mtime)
{ {
rgw_bucket bucket; rgw_bucket bucket;
string oid; string oid;
@ -406,9 +403,9 @@ int RGWCache<T>::put_system_obj_impl(rgw_obj& obj, uint64_t size, time_t *mtime,
info.version = objv_tracker->write_version; info.version = objv_tracker->write_version;
info.flags |= CACHE_FLAG_OBJV; info.flags |= CACHE_FLAG_OBJV;
} }
time_t result_mtime; ceph::real_time result_mtime;
int ret = T::put_system_obj_impl(obj, size, &result_mtime, attrs, flags, data, int ret = T::put_system_obj_impl(obj, size, &result_mtime, attrs, flags, data,
objv_tracker, set_mtime); objv_tracker, set_mtime);
if (mtime) { if (mtime) {
*mtime = result_mtime; *mtime = result_mtime;
} }
@ -459,7 +456,7 @@ int RGWCache<T>::put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& data,
} }
template <class T> template <class T>
int RGWCache<T>::raw_obj_stat(rgw_obj& obj, uint64_t *psize, time_t *pmtime, int RGWCache<T>::raw_obj_stat(rgw_obj& obj, uint64_t *psize, real_time *pmtime,
uint64_t *pepoch, map<string, bufferlist> *attrs, uint64_t *pepoch, map<string, bufferlist> *attrs,
bufferlist *first_chunk, RGWObjVersionTracker *objv_tracker) bufferlist *first_chunk, RGWObjVersionTracker *objv_tracker)
{ {
@ -470,7 +467,7 @@ int RGWCache<T>::raw_obj_stat(rgw_obj& obj, uint64_t *psize, time_t *pmtime,
string name = normal_name(bucket, oid); string name = normal_name(bucket, oid);
uint64_t size; uint64_t size;
time_t mtime; real_time mtime;
uint64_t epoch; uint64_t epoch;
ObjectCacheInfo info; ObjectCacheInfo info;

View File

@ -388,7 +388,7 @@ bool parse_rfc2616(const char *s, struct tm *t)
return parse_rfc850(s, t) || parse_asctime(s, t) || parse_rfc1123(s, t) || parse_rfc1123_alt(s,t); return parse_rfc850(s, t) || parse_asctime(s, t) || parse_rfc1123(s, t) || parse_rfc1123_alt(s,t);
} }
bool parse_iso8601(const char *s, struct tm *t, bool extended_format) bool parse_iso8601(const char *s, struct tm *t, uint32_t *pns, bool extended_format)
{ {
memset(t, 0, sizeof(*t)); memset(t, 0, sizeof(*t));
const char *p; const char *p;
@ -416,10 +416,33 @@ bool parse_iso8601(const char *s, struct tm *t, bool extended_format)
return false; return false;
uint32_t ms; uint32_t ms;
int r = stringtoul(str.substr(1, len - 2), &ms); string nsstr = str.substr(1, len - 2);
int r = stringtoul(nsstr, &ms);
if (r < 0) if (r < 0)
return false; return false;
if (!pns) {
return true;
}
if (nsstr.size() > 9) {
nsstr = nsstr.substr(0, 9);
}
uint64_t mul_table[] = { 0,
100000000LL,
10000000LL,
1000000LL,
100000LL,
10000LL,
1000LL,
100LL,
10LL,
1 };
*pns = ms * mul_table[nsstr.size()];
return true; return true;
} }
@ -445,14 +468,15 @@ int parse_key_value(string& in_str, string& key, string& val)
return parse_key_value(in_str, "=", key,val); return parse_key_value(in_str, "=", key,val);
} }
int parse_time(const char *time_str, time_t *time) int parse_time(const char *time_str, real_time *time)
{ {
struct tm tm; struct tm tm;
if (!parse_rfc2616(time_str, &tm)) if (!parse_rfc2616(time_str, &tm))
return -EINVAL; return -EINVAL;
*time = timegm(&tm); time_t sec = timegm(&tm);
*time = utime_t(sec, 0).to_real_time();
return 0; return 0;
} }

View File

@ -866,7 +866,7 @@ struct RGWBucketInfo
rgw_user owner; rgw_user owner;
uint32_t flags; uint32_t flags;
string zonegroup; string zonegroup;
time_t creation_time; ceph::real_time creation_time;
string placement_rule; string placement_rule;
bool has_instance_obj; bool has_instance_obj;
RGWObjVersionTracker objv_tracker; /* we don't need to serialize this, for runtime tracking */ RGWObjVersionTracker objv_tracker; /* we don't need to serialize this, for runtime tracking */
@ -897,12 +897,12 @@ struct RGWBucketInfo
void encode(bufferlist& bl) const { void encode(bufferlist& bl) const {
ENCODE_START(16, 4, bl); ENCODE_START(17, 4, bl);
::encode(bucket, bl); ::encode(bucket, bl);
::encode(owner.id, bl); ::encode(owner.id, bl);
::encode(flags, bl); ::encode(flags, bl);
::encode(zonegroup, bl); ::encode(zonegroup, bl);
uint64_t ct = (uint64_t)creation_time; uint64_t ct = real_clock::to_time_t(creation_time);
::encode(ct, bl); ::encode(ct, bl);
::encode(placement_rule, bl); ::encode(placement_rule, bl);
::encode(has_instance_obj, bl); ::encode(has_instance_obj, bl);
@ -920,10 +920,11 @@ struct RGWBucketInfo
if (swift_versioning) { if (swift_versioning) {
::encode(swift_ver_location, bl); ::encode(swift_ver_location, bl);
} }
::encode(creation_time, bl);
ENCODE_FINISH(bl); ENCODE_FINISH(bl);
} }
void decode(bufferlist::iterator& bl) { void decode(bufferlist::iterator& bl) {
DECODE_START_LEGACY_COMPAT_LEN_32(16, 4, 4, bl); DECODE_START_LEGACY_COMPAT_LEN_32(17, 4, 4, bl);
::decode(bucket, bl); ::decode(bucket, bl);
if (struct_v >= 2) { if (struct_v >= 2) {
string s; string s;
@ -934,10 +935,10 @@ struct RGWBucketInfo
::decode(flags, bl); ::decode(flags, bl);
if (struct_v >= 5) if (struct_v >= 5)
::decode(zonegroup, bl); ::decode(zonegroup, bl);
if (struct_v >= 6) { uint64_t ct;
uint64_t ct; ::decode(ct, bl);
::decode(ct, bl); if (struct_v >= 6 && struct_v < 17) {
creation_time = (time_t)ct; creation_time = ceph::real_clock::from_time_t((time_t)ct);
} }
if (struct_v >= 7) if (struct_v >= 7)
::decode(placement_rule, bl); ::decode(placement_rule, bl);
@ -976,6 +977,9 @@ struct RGWBucketInfo
::decode(swift_ver_location, bl); ::decode(swift_ver_location, bl);
} }
} }
if (struct_v >= 17) {
::decode(creation_time, bl);
}
DECODE_FINISH(bl); DECODE_FINISH(bl);
} }
void dump(Formatter *f) const; void dump(Formatter *f) const;
@ -989,7 +993,7 @@ struct RGWBucketInfo
bool has_swift_versioning() { return swift_versioning; } bool has_swift_versioning() { return swift_versioning; }
RGWBucketInfo() : flags(0), creation_time(0), has_instance_obj(false), num_shards(0), bucket_index_shard_hash_type(MOD), requester_pays(false), RGWBucketInfo() : flags(0), has_instance_obj(false), num_shards(0), bucket_index_shard_hash_type(MOD), requester_pays(false),
has_website(false), swift_versioning(false) {} has_website(false), swift_versioning(false) {}
}; };
WRITE_CLASS_ENCODER(RGWBucketInfo) WRITE_CLASS_ENCODER(RGWBucketInfo)
@ -998,27 +1002,28 @@ struct RGWBucketEntryPoint
{ {
rgw_bucket bucket; rgw_bucket bucket;
rgw_user owner; rgw_user owner;
time_t creation_time; ceph::real_time creation_time;
bool linked; bool linked;
bool has_bucket_info; bool has_bucket_info;
RGWBucketInfo old_bucket_info; RGWBucketInfo old_bucket_info;
RGWBucketEntryPoint() : creation_time(0), linked(false), has_bucket_info(false) {} RGWBucketEntryPoint() : linked(false), has_bucket_info(false) {}
void encode(bufferlist& bl) const { void encode(bufferlist& bl) const {
ENCODE_START(9, 8, bl); ENCODE_START(10, 8, bl);
::encode(bucket, bl); ::encode(bucket, bl);
::encode(owner.id, bl); ::encode(owner.id, bl);
::encode(linked, bl); ::encode(linked, bl);
uint64_t ctime = (uint64_t)creation_time; uint64_t ctime = (uint64_t)real_clock::to_time_t(creation_time);
::encode(ctime, bl); ::encode(ctime, bl);
::encode(owner, bl); ::encode(owner, bl);
::encode(creation_time, bl);
ENCODE_FINISH(bl); ENCODE_FINISH(bl);
} }
void decode(bufferlist::iterator& bl) { void decode(bufferlist::iterator& bl) {
bufferlist::iterator orig_iter = bl; bufferlist::iterator orig_iter = bl;
DECODE_START_LEGACY_COMPAT_LEN_32(9, 4, 4, bl); DECODE_START_LEGACY_COMPAT_LEN_32(10, 4, 4, bl);
if (struct_v < 8) { if (struct_v < 8) {
/* ouch, old entry, contains the bucket info itself */ /* ouch, old entry, contains the bucket info itself */
old_bucket_info.decode(orig_iter); old_bucket_info.decode(orig_iter);
@ -1031,10 +1036,15 @@ struct RGWBucketEntryPoint
::decode(linked, bl); ::decode(linked, bl);
uint64_t ctime; uint64_t ctime;
::decode(ctime, bl); ::decode(ctime, bl);
creation_time = (uint64_t)ctime; if (struct_v < 10) {
creation_time = real_clock::from_time_t((time_t)ctime);
}
if (struct_v >= 9) { if (struct_v >= 9) {
::decode(owner, bl); ::decode(owner, bl);
} }
if (struct_v >= 10) {
::decode(creation_time, bl);
}
DECODE_FINISH(bl); DECODE_FINISH(bl);
} }
@ -1284,7 +1294,7 @@ struct RGWObjEnt {
rgw_user owner; rgw_user owner;
std::string owner_display_name; std::string owner_display_name;
uint64_t size; uint64_t size;
utime_t mtime; ceph::real_time mtime;
string etag; string etag;
string content_type; string content_type;
string tag; string tag;
@ -1311,10 +1321,10 @@ struct RGWBucketEnt {
rgw_bucket bucket; rgw_bucket bucket;
size_t size; size_t size;
size_t size_rounded; size_t size_rounded;
time_t creation_time; real_time creation_time;
uint64_t count; uint64_t count;
RGWBucketEnt() : size(0), size_rounded(0), creation_time(0), count(0) {} RGWBucketEnt() : size(0), size_rounded(0), count(0) {}
explicit RGWBucketEnt(const cls_user_bucket_entry& e) : bucket(e.bucket), explicit RGWBucketEnt(const cls_user_bucket_entry& e) : bucket(e.bucket),
size(e.size), size(e.size),
@ -1331,9 +1341,9 @@ struct RGWBucketEnt {
} }
void encode(bufferlist& bl) const { void encode(bufferlist& bl) const {
ENCODE_START(5, 5, bl); ENCODE_START(6, 5, bl);
uint64_t s = size; uint64_t s = size;
__u32 mt = creation_time; __u32 mt = ceph::real_clock::to_time_t(creation_time);
string empty_str; // originally had the bucket name here, but we encode bucket later string empty_str; // originally had the bucket name here, but we encode bucket later
::encode(empty_str, bl); ::encode(empty_str, bl);
::encode(s, bl); ::encode(s, bl);
@ -1342,10 +1352,11 @@ struct RGWBucketEnt {
::encode(bucket, bl); ::encode(bucket, bl);
s = size_rounded; s = size_rounded;
::encode(s, bl); ::encode(s, bl);
::encode(creation_time, bl);
ENCODE_FINISH(bl); ENCODE_FINISH(bl);
} }
void decode(bufferlist::iterator& bl) { void decode(bufferlist::iterator& bl) {
DECODE_START_LEGACY_COMPAT_LEN(5, 5, 5, bl); DECODE_START_LEGACY_COMPAT_LEN(6, 5, 5, bl);
__u32 mt; __u32 mt;
uint64_t s; uint64_t s;
string empty_str; // backward compatibility string empty_str; // backward compatibility
@ -1353,7 +1364,9 @@ struct RGWBucketEnt {
::decode(s, bl); ::decode(s, bl);
::decode(mt, bl); ::decode(mt, bl);
size = s; size = s;
creation_time = mt; if (struct_v < 6) {
creation_time = ceph::real_clock::from_time_t(mt);
}
if (struct_v >= 2) if (struct_v >= 2)
::decode(count, bl); ::decode(count, bl);
if (struct_v >= 3) if (struct_v >= 3)
@ -1361,6 +1374,8 @@ struct RGWBucketEnt {
if (struct_v >= 4) if (struct_v >= 4)
::decode(s, bl); ::decode(s, bl);
size_rounded = s; size_rounded = s;
if (struct_v >= 6)
::decode(creation_time, bl);
DECODE_FINISH(bl); DECODE_FINISH(bl);
} }
void dump(Formatter *f) const; void dump(Formatter *f) const;
@ -1816,9 +1831,9 @@ extern void parse_csv_string(const string& ival, vector<string>& ovals);
extern int parse_key_value(string& in_str, string& key, string& val); extern int parse_key_value(string& in_str, string& key, string& val);
extern int parse_key_value(string& in_str, const char *delim, string& key, string& val); extern int parse_key_value(string& in_str, const char *delim, string& key, string& val);
/** time parsing */ /** time parsing */
extern int parse_time(const char *time_str, time_t *time); extern int parse_time(const char *time_str, real_time *time);
extern bool parse_rfc2616(const char *s, struct tm *t); extern bool parse_rfc2616(const char *s, struct tm *t);
extern bool parse_iso8601(const char *s, struct tm *t, bool extended_format = true); extern bool parse_iso8601(const char *s, struct tm *t, uint32_t *pns = NULL, bool extended_format = true);
extern string rgw_trim_whitespace(const string& src); extern string rgw_trim_whitespace(const string& src);
extern string rgw_trim_quotes(const string& val); extern string rgw_trim_quotes(const string& val);

View File

@ -477,7 +477,7 @@ int RGWAsyncFetchRemoteObj::_send_request()
attrs, attrs,
RGW_OBJ_CATEGORY_MAIN, RGW_OBJ_CATEGORY_MAIN,
versioned_epoch, versioned_epoch,
0, /* delete_at */ real_time(), /* delete_at */
&key.instance, /* string *version_id, */ &key.instance, /* string *version_id, */
NULL, /* string *ptag, */ NULL, /* string *ptag, */
NULL, /* string *petag, */ NULL, /* string *petag, */
@ -624,7 +624,7 @@ int RGWAsyncStatObj::_send_request()
RGWStatObjCR::RGWStatObjCR(RGWAsyncRadosProcessor *async_rados, RGWRados *store, RGWStatObjCR::RGWStatObjCR(RGWAsyncRadosProcessor *async_rados, RGWRados *store,
const rgw_obj& obj, uint64_t *psize, const rgw_obj& obj, uint64_t *psize,
time_t *pmtime, uint64_t *pepoch, ceph::real_time *pmtime, uint64_t *pepoch,
RGWObjVersionTracker *objv_tracker) RGWObjVersionTracker *objv_tracker)
: RGWSimpleCoroutine(store->ctx()), store(store), async_rados(async_rados), : RGWSimpleCoroutine(store->ctx()), store(store), async_rados(async_rados),
obj(obj), psize(psize), pmtime(pmtime), pepoch(pepoch), obj(obj), psize(psize), pmtime(pmtime), pepoch(pepoch),

View File

@ -718,7 +718,7 @@ class RGWAsyncRemoveObj : public RGWAsyncRadosRequest {
string marker_version_id; string marker_version_id;
bool del_if_older; bool del_if_older;
utime_t timestamp; ceph::real_time timestamp;
protected: protected:
int _send_request(); int _send_request();
@ -733,7 +733,7 @@ public:
uint64_t _versioned_epoch, uint64_t _versioned_epoch,
bool _delete_marker, bool _delete_marker,
bool _if_older, bool _if_older,
utime_t& _timestamp) : RGWAsyncRadosRequest(cn), store(_store), real_time& _timestamp) : RGWAsyncRadosRequest(cn), store(_store),
source_zone(_source_zone), source_zone(_source_zone),
bucket_info(_bucket_info), bucket_info(_bucket_info),
key(_key), key(_key),
@ -765,7 +765,7 @@ class RGWRemoveObjCR : public RGWSimpleCoroutine {
string owner_display_name; string owner_display_name;
bool del_if_older; bool del_if_older;
utime_t timestamp; real_time timestamp;
RGWAsyncRemoveObj *req; RGWAsyncRemoveObj *req;
@ -779,7 +779,7 @@ public:
string *_owner, string *_owner,
string *_owner_display_name, string *_owner_display_name,
bool _delete_marker, bool _delete_marker,
utime_t *_timestamp) : RGWSimpleCoroutine(_store->ctx()), cct(_store->ctx()), real_time *_timestamp) : RGWSimpleCoroutine(_store->ctx()), cct(_store->ctx()),
async_rados(_async_rados), store(_store), async_rados(_async_rados), store(_store),
source_zone(_source_zone), source_zone(_source_zone),
bucket_info(_bucket_info), bucket_info(_bucket_info),
@ -896,7 +896,7 @@ class RGWAsyncStatObj : public RGWAsyncRadosRequest {
RGWRados *store; RGWRados *store;
rgw_obj obj; rgw_obj obj;
uint64_t *psize; uint64_t *psize;
time_t *pmtime; ceph::real_time *pmtime;
uint64_t *pepoch; uint64_t *pepoch;
RGWObjVersionTracker *objv_tracker; RGWObjVersionTracker *objv_tracker;
protected: protected:
@ -904,7 +904,7 @@ protected:
public: public:
RGWAsyncStatObj(RGWAioCompletionNotifier *cn, RGWRados *store, RGWAsyncStatObj(RGWAioCompletionNotifier *cn, RGWRados *store,
const rgw_obj& obj, uint64_t *psize = nullptr, const rgw_obj& obj, uint64_t *psize = nullptr,
time_t *pmtime = nullptr, uint64_t *pepoch = nullptr, ceph::real_time *pmtime = nullptr, uint64_t *pepoch = nullptr,
RGWObjVersionTracker *objv_tracker = nullptr) RGWObjVersionTracker *objv_tracker = nullptr)
: RGWAsyncRadosRequest(cn), store(store), obj(obj), psize(psize), : RGWAsyncRadosRequest(cn), store(store), obj(obj), psize(psize),
pmtime(pmtime), pepoch(pepoch), objv_tracker(objv_tracker) {} pmtime(pmtime), pepoch(pepoch), objv_tracker(objv_tracker) {}
@ -915,14 +915,14 @@ class RGWStatObjCR : public RGWSimpleCoroutine {
RGWAsyncRadosProcessor *async_rados; RGWAsyncRadosProcessor *async_rados;
rgw_obj obj; rgw_obj obj;
uint64_t *psize; uint64_t *psize;
time_t *pmtime; ceph::real_time *pmtime;
uint64_t *pepoch; uint64_t *pepoch;
RGWObjVersionTracker *objv_tracker; RGWObjVersionTracker *objv_tracker;
RGWAsyncStatObj *req = nullptr; RGWAsyncStatObj *req = nullptr;
public: public:
RGWStatObjCR(RGWAsyncRadosProcessor *async_rados, RGWRados *store, RGWStatObjCR(RGWAsyncRadosProcessor *async_rados, RGWRados *store,
const rgw_obj& obj, uint64_t *psize = nullptr, const rgw_obj& obj, uint64_t *psize = nullptr,
time_t *pmtime = nullptr, uint64_t *pepoch = nullptr, ceph::real_time *pmtime = nullptr, uint64_t *pepoch = nullptr,
RGWObjVersionTracker *objv_tracker = nullptr); RGWObjVersionTracker *objv_tracker = nullptr);
~RGWStatObjCR(); ~RGWStatObjCR();

View File

@ -30,10 +30,11 @@ void rgw_datalog_info::decode_json(JSONObj *obj) {
JSONDecoder::decode_json("num_objects", num_shards, obj); JSONDecoder::decode_json("num_objects", num_shards, obj);
} }
void rgw_datalog_entry::decode_json(JSONObj *obj) { void rgw_datalog_entry::decode_json(JSONObj *obj) {
JSONDecoder::decode_json("key", key, obj); JSONDecoder::decode_json("key", key, obj);
JSONDecoder::decode_json("timestamp", timestamp, obj); utime_t ut;
JSONDecoder::decode_json("timestamp", ut, obj);
timestamp = ut.to_real_time();
} }
void rgw_datalog_shard_data::decode_json(JSONObj *obj) { void rgw_datalog_shard_data::decode_json(JSONObj *obj) {
@ -705,7 +706,7 @@ public:
marker_oid(_marker_oid), marker_oid(_marker_oid),
sync_marker(_marker) {} sync_marker(_marker) {}
RGWCoroutine *store_marker(const string& new_marker, uint64_t index_pos, const utime_t& timestamp) { RGWCoroutine *store_marker(const string& new_marker, uint64_t index_pos, const real_time& timestamp) {
sync_marker.marker = new_marker; sync_marker.marker = new_marker;
sync_marker.pos = index_pos; sync_marker.pos = index_pos;
@ -984,7 +985,7 @@ public:
for (; iter != entries.end(); ++iter) { for (; iter != entries.end(); ++iter) {
ldout(sync_env->cct, 20) << __func__ << ": full sync: " << iter->first << dendl; ldout(sync_env->cct, 20) << __func__ << ": full sync: " << iter->first << dendl;
total_entries++; total_entries++;
if (!marker_tracker->start(iter->first, total_entries, utime_t())) { if (!marker_tracker->start(iter->first, total_entries, real_time())) {
ldout(sync_env->cct, 0) << "ERROR: cannot start syncing " << iter->first << ". Duplicate entry?" << dendl; ldout(sync_env->cct, 0) << "ERROR: cannot start syncing " << iter->first << ". Duplicate entry?" << dendl;
} else { } else {
// fetch remote and write locally // fetch remote and write locally
@ -1656,7 +1657,7 @@ struct bucket_list_entry {
bool delete_marker; bool delete_marker;
rgw_obj_key key; rgw_obj_key key;
bool is_latest; bool is_latest;
utime_t mtime; real_time mtime;
string etag; string etag;
uint64_t size; uint64_t size;
string storage_class; string storage_class;
@ -1675,11 +1676,12 @@ struct bucket_list_entry {
JSONDecoder::decode_json("LastModified", mtime_str, obj); JSONDecoder::decode_json("LastModified", mtime_str, obj);
struct tm t; struct tm t;
if (parse_iso8601(mtime_str.c_str(), &t)) { uint32_t nsec;
time_t sec = timegm(&t); if (parse_iso8601(mtime_str.c_str(), &t, &nsec)) {
ceph_timespec ts;
/* FIXME: eventually we'll want to have a high def clock for rgw objects */ ts.tv_sec = (uint64_t)timegm(&t);
mtime = utime_t(sec, 0); ts.tv_nsec = nsec;
mtime = real_clock::from_ceph_timespec(ts);
} }
JSONDecoder::decode_json("ETag", etag, obj); JSONDecoder::decode_json("ETag", etag, obj);
JSONDecoder::decode_json("Size", size, obj); JSONDecoder::decode_json("Size", size, obj);
@ -1827,7 +1829,7 @@ public:
marker_oid(_marker_oid), marker_oid(_marker_oid),
sync_marker(_marker) {} sync_marker(_marker) {}
RGWCoroutine *store_marker(const rgw_obj_key& new_marker, uint64_t index_pos, const utime_t& timestamp) { RGWCoroutine *store_marker(const rgw_obj_key& new_marker, uint64_t index_pos, const real_time& timestamp) {
sync_marker.position = new_marker; sync_marker.position = new_marker;
sync_marker.count = index_pos; sync_marker.count = index_pos;
@ -1869,7 +1871,7 @@ public:
marker_oid(_marker_oid), marker_oid(_marker_oid),
sync_marker(_marker) {} sync_marker(_marker) {}
RGWCoroutine *store_marker(const string& new_marker, uint64_t index_pos, const utime_t& timestamp) { RGWCoroutine *store_marker(const string& new_marker, uint64_t index_pos, const real_time& timestamp) {
sync_marker.position = new_marker; sync_marker.position = new_marker;
map<string, bufferlist> attrs; map<string, bufferlist> attrs;
@ -1922,7 +1924,7 @@ class RGWBucketSyncSingleEntryCR : public RGWCoroutine {
bool versioned; bool versioned;
uint64_t versioned_epoch; uint64_t versioned_epoch;
bucket_entry_owner owner; bucket_entry_owner owner;
utime_t timestamp; real_time timestamp;
RGWModifyOp op; RGWModifyOp op;
RGWPendingState op_state; RGWPendingState op_state;
@ -1938,7 +1940,7 @@ public:
RGWBucketSyncSingleEntryCR(RGWDataSyncEnv *_sync_env, RGWBucketSyncSingleEntryCR(RGWDataSyncEnv *_sync_env,
RGWBucketInfo *_bucket_info, int _shard_id, RGWBucketInfo *_bucket_info, int _shard_id,
const rgw_obj_key& _key, bool _versioned, uint64_t _versioned_epoch, const rgw_obj_key& _key, bool _versioned, uint64_t _versioned_epoch,
utime_t& _timestamp, real_time& _timestamp,
const bucket_entry_owner& _owner, const bucket_entry_owner& _owner,
RGWModifyOp _op, RGWPendingState _op_state, RGWModifyOp _op, RGWPendingState _op_state,
const T& _entry_marker, RGWSyncShardMarkerTrack<T, K> *_marker_tracker) : RGWCoroutine(_sync_env->cct), const T& _entry_marker, RGWSyncShardMarkerTrack<T, K> *_marker_tracker) : RGWCoroutine(_sync_env->cct),
@ -2115,7 +2117,7 @@ int RGWBucketShardFullSyncCR::operate()
entry = &(*entries_iter); entry = &(*entries_iter);
total_entries++; total_entries++;
list_marker = entries_iter->key; list_marker = entries_iter->key;
if (!marker_tracker->start(entry->key, total_entries, utime_t())) { if (!marker_tracker->start(entry->key, total_entries, real_time())) {
ldout(sync_env->cct, 0) << "ERROR: cannot start syncing " << entry->key << ". Duplicate entry?" << dendl; ldout(sync_env->cct, 0) << "ERROR: cannot start syncing " << entry->key << ". Duplicate entry?" << dendl;
} else { } else {
op = (entry->key.instance.empty() || entry->key.instance == "null" ? CLS_RGW_OP_ADD : CLS_RGW_OP_LINK_OLH); op = (entry->key.instance.empty() || entry->key.instance == "null" ? CLS_RGW_OP_ADD : CLS_RGW_OP_LINK_OLH);
@ -2309,6 +2311,7 @@ int RGWBucketShardIncrementalSyncCR::operate()
if (entry->ver.pool < 0) { if (entry->ver.pool < 0) {
versioned_epoch = entry->ver.epoch; versioned_epoch = entry->ver.epoch;
} }
ldout(sync_env->cct, 0) << __FILE__ << ":" << __LINE__ << " entry->timestamp=" << entry->timestamp << dendl;
spawn(new RGWBucketSyncSingleEntryCR<string, rgw_obj_key>(sync_env, bucket_info, shard_id, spawn(new RGWBucketSyncSingleEntryCR<string, rgw_obj_key>(sync_env, bucket_info, shard_id,
key, entry->is_versioned(), versioned_epoch, entry->timestamp, owner, entry->op, key, entry->is_versioned(), versioned_epoch, entry->timestamp, owner, entry->op,
entry->state, entry->id, marker_tracker), false); entry->state, entry->id, marker_tracker), false);

View File

@ -74,7 +74,7 @@ struct rgw_data_sync_marker {
string next_step_marker; string next_step_marker;
uint64_t total_entries; uint64_t total_entries;
uint64_t pos; uint64_t pos;
utime_t timestamp; real_time timestamp;
rgw_data_sync_marker() : state(FullSync), total_entries(0), pos(0) {} rgw_data_sync_marker() : state(FullSync), total_entries(0), pos(0) {}
@ -106,7 +106,7 @@ struct rgw_data_sync_marker {
encode_json("next_step_marker", next_step_marker, f); encode_json("next_step_marker", next_step_marker, f);
encode_json("total_entries", total_entries, f); encode_json("total_entries", total_entries, f);
encode_json("pos", pos, f); encode_json("pos", pos, f);
encode_json("timestamp", timestamp, f); encode_json("timestamp", utime_t(timestamp), f);
} }
}; };
WRITE_CLASS_ENCODER(rgw_data_sync_marker) WRITE_CLASS_ENCODER(rgw_data_sync_marker)
@ -140,7 +140,7 @@ WRITE_CLASS_ENCODER(rgw_data_sync_status)
struct rgw_datalog_entry { struct rgw_datalog_entry {
string key; string key;
utime_t timestamp; ceph::real_time timestamp;
void decode_json(JSONObj *obj); void decode_json(JSONObj *obj);
}; };

View File

@ -105,7 +105,7 @@ namespace rgw {
if (get<0>(fhr)) { if (get<0>(fhr)) {
RGWFileHandle* rgw_fh = get<0>(fhr); RGWFileHandle* rgw_fh = get<0>(fhr);
rgw_fh->set_size(req.get_size()); rgw_fh->set_size(req.get_size());
rgw_fh->set_mtime({req.get_mtime(), 0}); rgw_fh->set_mtime(real_clock::to_timespec(req.get_mtime()));
} }
goto done; goto done;
} }
@ -614,11 +614,11 @@ namespace rgw {
attrs[RGW_ATTR_SLO_UINDICATOR] = slo_userindicator_bl; attrs[RGW_ATTR_SLO_UINDICATOR] = slo_userindicator_bl;
} }
op_ret = processor->complete(etag, &mtime, 0, attrs, delete_at, if_match, op_ret = processor->complete(etag, &mtime, real_time(), attrs, delete_at, if_match,
if_nomatch); if_nomatch);
if (! op_ret) { if (! op_ret) {
/* update stats */ /* update stats */
rgw_fh->set_mtime({mtime, 0}); rgw_fh->set_mtime(real_clock::to_timespec(mtime));
rgw_fh->set_size(bytes_written); rgw_fh->set_size(bytes_written);
} }
@ -758,8 +758,7 @@ int rgw_create(struct rgw_fs *rgw_fs,
if (rgw_fh) { if (rgw_fh) {
if (get<1>(fhr) & RGWFileHandle::FLAG_CREATE) { if (get<1>(fhr) & RGWFileHandle::FLAG_CREATE) {
/* fill in stat data */ /* fill in stat data */
time_t now = time(0); rgw_fh->set_times(real_clock::now());
rgw_fh->set_times(now);
rgw_fh->open_for_create(); // XXX needed? rgw_fh->open_for_create(); // XXX needed?
} }
(void) rgw_fh->stat(st); (void) rgw_fh->stat(st);
@ -832,8 +831,7 @@ int rgw_mkdir(struct rgw_fs *rgw_fs,
rgw_fh = get<0>(fhr); rgw_fh = get<0>(fhr);
if (rgw_fh) { if (rgw_fh) {
/* XXX unify timestamps */ /* XXX unify timestamps */
time_t now = time(0); rgw_fh->set_times(real_clock::now());
rgw_fh->set_times(now);
rgw_fh->stat(st); rgw_fh->stat(st);
struct rgw_file_handle *rfh = rgw_fh->get_fh(); struct rgw_file_handle *rfh = rgw_fh->get_fh();
*fh = rfh; *fh = rfh;

View File

@ -461,10 +461,10 @@ namespace rgw {
state.size = size; state.size = size;
} }
void set_times(time_t t) { void set_times(real_time t) {
state.ctime = {t, 0}; state.ctime = real_clock::to_timespec(t);
state.mtime = {t, 0}; state.mtime = state.ctime;
state.atime = {t, 0}; state.atime = state.ctime;
} }
void set_ctime(const struct timespec &ts) { void set_ctime(const struct timespec &ts) {
@ -679,7 +679,7 @@ namespace rgw {
if (ldh->auth(token.id, token.key) == 0) { if (ldh->auth(token.id, token.key) == 0) {
/* try to store user if it doesn't already exist */ /* try to store user if it doesn't already exist */
if (rgw_get_user_info_by_uid(store, token.id, user) < 0) { if (rgw_get_user_info_by_uid(store, token.id, user) < 0) {
int ret = rgw_store_user_info(store, user, NULL, NULL, 0, int ret = rgw_store_user_info(store, user, NULL, NULL, real_time(),
true); true);
if (ret < 0) { if (ret < 0) {
lsubdout(get_context(), rgw, 10) lsubdout(get_context(), rgw, 10)
@ -1503,14 +1503,14 @@ public:
virtual const string name() { return "stat_obj"; } virtual const string name() { return "stat_obj"; }
virtual RGWOpType get_type() { return RGW_OP_STAT_OBJ; } virtual RGWOpType get_type() { return RGW_OP_STAT_OBJ; }
time_t get_mtime() const { real_time get_mtime() const {
return lastmod; return lastmod;
} }
/* attributes */ /* attributes */
uint64_t get_size() { return _size; } uint64_t get_size() { return _size; }
time_t ctime() { return mod_time; } // XXX real_time ctime() { return mod_time; } // XXX
time_t mtime() { return mod_time; } real_time mtime() { return mod_time; }
map<string, bufferlist>& get_attrs() { return attrs; } map<string, bufferlist>& get_attrs() { return attrs; }
virtual bool only_bucket() { return false; } virtual bool only_bucket() { return false; }
@ -1612,7 +1612,7 @@ public:
return 0; return 0;
} }
time_t get_ctime() const { real_time get_ctime() const {
return bucket.creation_time; return bucket.creation_time;
} }

View File

@ -45,7 +45,8 @@ void RGWOLHInfo::dump(Formatter *f) const
void RGWOLHPendingInfo::dump(Formatter *f) const void RGWOLHPendingInfo::dump(Formatter *f) const
{ {
encode_json("time", time, f); utime_t ut(time);
encode_json("time", ut, f);
} }
void RGWObjManifestPart::dump(Formatter *f) const void RGWObjManifestPart::dump(Formatter *f) const
@ -188,7 +189,7 @@ void RGWAccessControlPolicy::dump(Formatter *f) const
void ObjectMetaInfo::dump(Formatter *f) const void ObjectMetaInfo::dump(Formatter *f) const
{ {
encode_json("size", size, f); encode_json("size", size, f);
encode_json("mtime", mtime, f); encode_json("mtime", utime_t(mtime), f);
} }
void ObjectCacheInfo::dump(Formatter *f) const void ObjectCacheInfo::dump(Formatter *f) const
@ -520,7 +521,8 @@ void RGWBucketEntryPoint::dump(Formatter *f) const
{ {
encode_json("bucket", bucket, f); encode_json("bucket", bucket, f);
encode_json("owner", owner, f); encode_json("owner", owner, f);
encode_json("creation_time", creation_time, f); utime_t ut(creation_time);
encode_json("creation_time", ut, f);
encode_json("linked", linked, f); encode_json("linked", linked, f);
encode_json("has_bucket_info", has_bucket_info, f); encode_json("has_bucket_info", has_bucket_info, f);
if (has_bucket_info) { if (has_bucket_info) {
@ -531,7 +533,8 @@ void RGWBucketEntryPoint::dump(Formatter *f) const
void RGWBucketEntryPoint::decode_json(JSONObj *obj) { void RGWBucketEntryPoint::decode_json(JSONObj *obj) {
JSONDecoder::decode_json("bucket", bucket, obj); JSONDecoder::decode_json("bucket", bucket, obj);
JSONDecoder::decode_json("owner", owner, obj); JSONDecoder::decode_json("owner", owner, obj);
JSONDecoder::decode_json("creation_time", creation_time, obj); utime_t ut(creation_time);
JSONDecoder::decode_json("creation_time", ut, obj);
JSONDecoder::decode_json("linked", linked, obj); JSONDecoder::decode_json("linked", linked, obj);
JSONDecoder::decode_json("has_bucket_info", has_bucket_info, obj); JSONDecoder::decode_json("has_bucket_info", has_bucket_info, obj);
if (has_bucket_info) { if (has_bucket_info) {
@ -623,7 +626,8 @@ void RGWBucketWebsiteConf::decode_json(JSONObj *obj) {
void RGWBucketInfo::dump(Formatter *f) const void RGWBucketInfo::dump(Formatter *f) const
{ {
encode_json("bucket", bucket, f); encode_json("bucket", bucket, f);
encode_json("creation_time", creation_time, f); utime_t ut(creation_time);
encode_json("creation_time", ut, f);
encode_json("owner", owner.to_str(), f); encode_json("owner", owner.to_str(), f);
encode_json("flags", flags, f); encode_json("flags", flags, f);
encode_json("zonegroup", zonegroup, f); encode_json("zonegroup", zonegroup, f);
@ -643,7 +647,8 @@ void RGWBucketInfo::dump(Formatter *f) const
void RGWBucketInfo::decode_json(JSONObj *obj) { void RGWBucketInfo::decode_json(JSONObj *obj) {
JSONDecoder::decode_json("bucket", bucket, obj); JSONDecoder::decode_json("bucket", bucket, obj);
JSONDecoder::decode_json("creation_time", creation_time, obj); utime_t ut(creation_time);
JSONDecoder::decode_json("creation_time", ut, obj);
JSONDecoder::decode_json("owner", owner, obj); JSONDecoder::decode_json("owner", owner, obj);
JSONDecoder::decode_json("flags", flags, obj); JSONDecoder::decode_json("flags", flags, obj);
JSONDecoder::decode_json("zonegroup", zonegroup, obj); JSONDecoder::decode_json("zonegroup", zonegroup, obj);
@ -681,7 +686,8 @@ void RGWObjEnt::dump(Formatter *f) const
encode_json("owner", owner.to_str(), f); encode_json("owner", owner.to_str(), f);
encode_json("owner_display_name", owner_display_name, f); encode_json("owner_display_name", owner_display_name, f);
encode_json("size", size, f); encode_json("size", size, f);
encode_json("mtime", mtime, f); utime_t ut(mtime);
encode_json("mtime", ut, f);
encode_json("etag", etag, f); encode_json("etag", etag, f);
encode_json("content_type", content_type, f); encode_json("content_type", content_type, f);
encode_json("tag", tag, f); encode_json("tag", tag, f);
@ -693,7 +699,8 @@ void RGWBucketEnt::dump(Formatter *f) const
encode_json("bucket", bucket, f); encode_json("bucket", bucket, f);
encode_json("size", size, f); encode_json("size", size, f);
encode_json("size_rounded", size_rounded, f); encode_json("size_rounded", size_rounded, f);
encode_json("mtime", creation_time, f); /* mtime / creation time discrepency needed for backward compatibility */ utime_t ut(creation_time);
encode_json("mtime", ut, f); /* mtime / creation time discrepency needed for backward compatibility */
encode_json("count", count, f); encode_json("count", count, f);
} }
@ -702,7 +709,8 @@ void RGWUploadPartInfo::dump(Formatter *f) const
encode_json("num", num, f); encode_json("num", num, f);
encode_json("size", size, f); encode_json("size", size, f);
encode_json("etag", etag, f); encode_json("etag", etag, f);
encode_json("modified", modified, f); utime_t ut(modified);
encode_json("modified", ut, f);
} }
void rgw_obj::dump(Formatter *f) const void rgw_obj::dump(Formatter *f) const
@ -1019,25 +1027,29 @@ void RGWZoneGroupMap::decode_json(JSONObj *obj)
void RGWMetadataLogInfo::dump(Formatter *f) const void RGWMetadataLogInfo::dump(Formatter *f) const
{ {
encode_json("marker", marker, f); encode_json("marker", marker, f);
encode_json("last_update", last_update, f); utime_t ut(last_update);
encode_json("last_update", ut, f);
} }
void RGWMetadataLogInfo::decode_json(JSONObj *obj) void RGWMetadataLogInfo::decode_json(JSONObj *obj)
{ {
JSONDecoder::decode_json("marker", marker, obj); JSONDecoder::decode_json("marker", marker, obj);
JSONDecoder::decode_json("last_update", last_update, obj); utime_t ut(last_update);
JSONDecoder::decode_json("last_update", ut, obj);
} }
void RGWDataChangesLogInfo::dump(Formatter *f) const void RGWDataChangesLogInfo::dump(Formatter *f) const
{ {
encode_json("marker", marker, f); encode_json("marker", marker, f);
encode_json("last_update", last_update, f); utime_t ut(last_update);
encode_json("last_update", ut, f);
} }
void RGWDataChangesLogInfo::decode_json(JSONObj *obj) void RGWDataChangesLogInfo::decode_json(JSONObj *obj)
{ {
JSONDecoder::decode_json("marker", marker, obj); JSONDecoder::decode_json("marker", marker, obj);
JSONDecoder::decode_json("last_update", last_update, obj); utime_t ut(last_update);
JSONDecoder::decode_json("last_update", ut, obj);
} }
@ -1208,7 +1220,9 @@ void rgw_meta_sync_marker::decode_json(JSONObj *obj)
JSONDecoder::decode_json("next_step_marker", next_step_marker, obj); JSONDecoder::decode_json("next_step_marker", next_step_marker, obj);
JSONDecoder::decode_json("total_entries", total_entries, obj); JSONDecoder::decode_json("total_entries", total_entries, obj);
JSONDecoder::decode_json("pos", pos, obj); JSONDecoder::decode_json("pos", pos, obj);
JSONDecoder::decode_json("timestamp", timestamp, obj); utime_t ut;
JSONDecoder::decode_json("timestamp", ut, obj);
timestamp = ut.to_real_time();
} }
void rgw_meta_sync_marker::dump(Formatter *f) const void rgw_meta_sync_marker::dump(Formatter *f) const
@ -1218,7 +1232,7 @@ void rgw_meta_sync_marker::dump(Formatter *f) const
encode_json("next_step_marker", next_step_marker, f); encode_json("next_step_marker", next_step_marker, f);
encode_json("total_entries", total_entries, f); encode_json("total_entries", total_entries, f);
encode_json("pos", pos, f); encode_json("pos", pos, f);
encode_json("timestamp", timestamp, f); encode_json("timestamp", utime_t(timestamp), f);
} }
void rgw_meta_sync_status::decode_json(JSONObj *obj) void rgw_meta_sync_status::decode_json(JSONObj *obj)

View File

@ -135,7 +135,8 @@ public:
bool account; bool account;
string u = user.to_str(); string u = user.to_str();
rgw_user_bucket ub(u, entry.bucket); rgw_user_bucket ub(u, entry.bucket);
usage_map[ub].insert(round_timestamp, entry, &account); real_time rt = round_timestamp.to_real_time();
usage_map[ub].insert(rt, entry, &account);
if (account) if (account)
num_entries++; num_entries++;
bool need_flush = (num_entries > cct->_conf->rgw_usage_log_flush_threshold); bool need_flush = (num_entries > cct->_conf->rgw_usage_log_flush_threshold);

View File

@ -3,6 +3,8 @@
#include <string> #include <string>
#include "common/ceph_time.h"
struct rgw_meta_sync_info { struct rgw_meta_sync_info {
enum SyncState { enum SyncState {
StateInit = 0, StateInit = 0,
@ -52,7 +54,7 @@ struct rgw_meta_sync_marker {
string next_step_marker; string next_step_marker;
uint64_t total_entries; uint64_t total_entries;
uint64_t pos; uint64_t pos;
utime_t timestamp; real_time timestamp;
rgw_meta_sync_marker() : state(FullSync), total_entries(0), pos(0) {} rgw_meta_sync_marker() : state(FullSync), total_entries(0), pos(0) {}

View File

@ -102,7 +102,7 @@ int RGWMetadataLog::add_entry(RGWMetadataHandler *handler, const string& section
int shard_id; int shard_id;
store->shard_name(prefix, cct->_conf->rgw_md_log_max_shards, hash_key, oid, &shard_id); store->shard_name(prefix, cct->_conf->rgw_md_log_max_shards, hash_key, oid, &shard_id);
mark_modified(shard_id); mark_modified(shard_id);
utime_t now = ceph_clock_now(cct); real_time now = real_clock::now();
return store->time_log_add(oid, now, section, key, bl); return store->time_log_add(oid, now, section, key, bl);
} }
@ -115,7 +115,7 @@ int RGWMetadataLog::store_entries_in_shard(list<cls_log_entry>& entries, int sha
return store->time_log_add(oid, entries, completion, false); return store->time_log_add(oid, entries, completion, false);
} }
void RGWMetadataLog::init_list_entries(int shard_id, utime_t& from_time, utime_t& end_time, void RGWMetadataLog::init_list_entries(int shard_id, const real_time& from_time, const real_time& end_time,
string& marker, void **handle) string& marker, void **handle)
{ {
LogListCtx *ctx = new LogListCtx(); LogListCtx *ctx = new LogListCtx();
@ -171,7 +171,7 @@ int RGWMetadataLog::get_info(int shard_id, RGWMetadataLogInfo *info)
return ret; return ret;
info->marker = header.max_marker; info->marker = header.max_marker;
info->last_update = header.max_time; info->last_update = header.max_time.to_real_time();
return 0; return 0;
} }
@ -201,7 +201,7 @@ public:
*pret = completion->get_return_value(); *pret = completion->get_return_value();
if (*pret >= 0) { if (*pret >= 0) {
pinfo->marker = header.max_marker; pinfo->marker = header.max_marker;
pinfo->last_update = header.max_time; pinfo->last_update = header.max_time.to_real_time();
} }
completion_manager->complete(NULL, user_info); completion_manager->complete(NULL, user_info);
put(); put();
@ -243,7 +243,7 @@ int RGWMetadataLog::get_info_async(int shard_id, RGWMetadataLogInfo *info, RGWCo
return 0; return 0;
} }
int RGWMetadataLog::trim(int shard_id, const utime_t& from_time, const utime_t& end_time, int RGWMetadataLog::trim(int shard_id, const real_time& from_time, const real_time& end_time,
const string& start_marker, const string& end_marker) const string& start_marker, const string& end_marker)
{ {
string oid; string oid;
@ -259,7 +259,7 @@ int RGWMetadataLog::trim(int shard_id, const utime_t& from_time, const utime_t&
return ret; return ret;
} }
int RGWMetadataLog::lock_exclusive(int shard_id, utime_t& duration, string& zone_id, string& owner_id) { int RGWMetadataLog::lock_exclusive(int shard_id, timespan duration, string& zone_id, string& owner_id) {
string oid; string oid;
get_shard_oid(shard_id, oid); get_shard_oid(shard_id, oid);
@ -311,7 +311,7 @@ public:
virtual int get(RGWRados *store, string& entry, RGWMetadataObject **obj) { return -ENOTSUP; } virtual int get(RGWRados *store, string& entry, RGWMetadataObject **obj) { return -ENOTSUP; }
virtual int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker, virtual int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker,
time_t mtime, JSONObj *obj, sync_type_t sync_type) { return -ENOTSUP; } real_time mtime, JSONObj *obj, sync_type_t sync_type) { return -ENOTSUP; }
virtual void get_pool_and_oid(RGWRados *store, const string& key, rgw_bucket& bucket, string& oid) {} virtual void get_pool_and_oid(RGWRados *store, const string& key, rgw_bucket& bucket, string& oid) {}
@ -567,9 +567,10 @@ int RGWMetadataManager::get(string& metadata_key, Formatter *f)
f->open_object_section("metadata_info"); f->open_object_section("metadata_info");
encode_json("key", metadata_key, f); encode_json("key", metadata_key, f);
encode_json("ver", obj->get_version(), f); encode_json("ver", obj->get_version(), f);
time_t mtime = obj->get_mtime(); real_time mtime = obj->get_mtime();
if (mtime > 0) { if (!real_clock::is_zero(mtime)) {
encode_json("mtime", mtime, f); utime_t ut(mtime);
encode_json("mtime", ut, f);
} }
encode_json("data", *obj, f); encode_json("data", *obj, f);
f->close_section(); f->close_section();
@ -599,7 +600,7 @@ int RGWMetadataManager::put(string& metadata_key, bufferlist& bl,
obj_version *objv = &objv_tracker.write_version; obj_version *objv = &objv_tracker.write_version;
time_t mtime = 0; utime_t mtime;
try { try {
JSONDecoder::decode_json("key", metadata_key, &parser); JSONDecoder::decode_json("key", metadata_key, &parser);
@ -614,7 +615,7 @@ int RGWMetadataManager::put(string& metadata_key, bufferlist& bl,
return -EINVAL; return -EINVAL;
} }
ret = handler->put(store, entry, objv_tracker, mtime, jo, sync_type); ret = handler->put(store, entry, objv_tracker, mtime.to_real_time(), jo, sync_type);
if (existing_version) { if (existing_version) {
*existing_version = objv_tracker.read_version; *existing_version = objv_tracker.read_version;
} }
@ -646,7 +647,7 @@ int RGWMetadataManager::remove(string& metadata_key)
return handler->remove(store, entry, objv_tracker); return handler->remove(store, entry, objv_tracker);
} }
int RGWMetadataManager::lock_exclusive(string& metadata_key, utime_t duration, string& owner_id) { int RGWMetadataManager::lock_exclusive(string& metadata_key, timespan duration, string& owner_id) {
RGWMetadataHandler *handler; RGWMetadataHandler *handler;
string entry; string entry;
string zone_id; string zone_id;
@ -820,7 +821,7 @@ string RGWMetadataManager::heap_oid(RGWMetadataHandler *handler, const string& k
} }
int RGWMetadataManager::store_in_heap(RGWMetadataHandler *handler, const string& key, bufferlist& bl, int RGWMetadataManager::store_in_heap(RGWMetadataHandler *handler, const string& key, bufferlist& bl,
RGWObjVersionTracker *objv_tracker, time_t mtime, RGWObjVersionTracker *objv_tracker, real_time mtime,
map<string, bufferlist> *pattrs) map<string, bufferlist> *pattrs)
{ {
if (!objv_tracker) { if (!objv_tracker) {
@ -863,7 +864,7 @@ int RGWMetadataManager::remove_from_heap(RGWMetadataHandler *handler, const stri
} }
int RGWMetadataManager::put_entry(RGWMetadataHandler *handler, const string& key, bufferlist& bl, bool exclusive, int RGWMetadataManager::put_entry(RGWMetadataHandler *handler, const string& key, bufferlist& bl, bool exclusive,
RGWObjVersionTracker *objv_tracker, time_t mtime, map<string, bufferlist> *pattrs) RGWObjVersionTracker *objv_tracker, real_time mtime, map<string, bufferlist> *pattrs)
{ {
string section; string section;
RGWMetadataLogData log_data; RGWMetadataLogData log_data;

View File

@ -12,6 +12,7 @@
#include "cls/version/cls_version_types.h" #include "cls/version/cls_version_types.h"
#include "cls/log/cls_log_types.h" #include "cls/log/cls_log_types.h"
#include "common/RWLock.h" #include "common/RWLock.h"
#include "common/ceph_time.h"
class RGWRados; class RGWRados;
@ -33,13 +34,13 @@ enum RGWMDLogStatus {
class RGWMetadataObject { class RGWMetadataObject {
protected: protected:
obj_version objv; obj_version objv;
time_t mtime; ceph::real_time mtime;
public: public:
RGWMetadataObject() : mtime(0) {} RGWMetadataObject() {}
virtual ~RGWMetadataObject() {} virtual ~RGWMetadataObject() {}
obj_version& get_version(); obj_version& get_version();
time_t get_mtime() { return mtime; } real_time get_mtime() { return mtime; }
virtual void dump(Formatter *f) const = 0; virtual void dump(Formatter *f) const = 0;
}; };
@ -72,7 +73,7 @@ public:
virtual int get(RGWRados *store, string& entry, RGWMetadataObject **obj) = 0; virtual int get(RGWRados *store, string& entry, RGWMetadataObject **obj) = 0;
virtual int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker, virtual int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker,
time_t mtime, JSONObj *obj, sync_type_t type) = 0; real_time mtime, JSONObj *obj, sync_type_t type) = 0;
virtual int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) = 0; virtual int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) = 0;
virtual int list_keys_init(RGWRados *store, void **phandle) = 0; virtual int list_keys_init(RGWRados *store, void **phandle) = 0;
@ -92,8 +93,8 @@ protected:
* *
* @return true if the update should proceed, false otherwise. * @return true if the update should proceed, false otherwise.
*/ */
bool check_versions(const obj_version& ondisk, const time_t& ondisk_time, bool check_versions(const obj_version& ondisk, const real_time& ondisk_time,
const obj_version& incoming, const time_t& incoming_time, const obj_version& incoming, const real_time& incoming_time,
sync_type_t sync_mode) { sync_type_t sync_mode) {
switch (sync_mode) { switch (sync_mode) {
case APPLY_UPDATES: case APPLY_UPDATES:
@ -131,7 +132,7 @@ protected:
struct RGWMetadataLogInfo { struct RGWMetadataLogInfo {
string marker; string marker;
utime_t last_update; real_time last_update;
void dump(Formatter *f) const; void dump(Formatter *f) const;
void decode_json(JSONObj *obj); void decode_json(JSONObj *obj);
@ -172,8 +173,8 @@ public:
struct LogListCtx { struct LogListCtx {
int cur_shard; int cur_shard;
string marker; string marker;
utime_t from_time; real_time from_time;
utime_t end_time; real_time end_time;
string cur_oid; string cur_oid;
@ -182,7 +183,7 @@ public:
LogListCtx() : cur_shard(0), done(false) {} LogListCtx() : cur_shard(0), done(false) {}
}; };
void init_list_entries(int shard_id, utime_t& from_time, utime_t& end_time, string& marker, void **handle); void init_list_entries(int shard_id, const real_time& from_time, const real_time& end_time, string& marker, void **handle);
void complete_list_entries(void *handle); void complete_list_entries(void *handle);
int list_entries(void *handle, int list_entries(void *handle,
int max_entries, int max_entries,
@ -190,10 +191,10 @@ public:
string *out_marker, string *out_marker,
bool *truncated); bool *truncated);
int trim(int shard_id, const utime_t& from_time, const utime_t& end_time, const string& start_marker, const string& end_marker); int trim(int shard_id, const real_time& from_time, const real_time& end_time, const string& start_marker, const string& end_marker);
int get_info(int shard_id, RGWMetadataLogInfo *info); int get_info(int shard_id, RGWMetadataLogInfo *info);
int get_info_async(int shard_id, RGWMetadataLogInfo *info, RGWCompletionManager *completion_manager, void *user_info, int *pret); int get_info_async(int shard_id, RGWMetadataLogInfo *info, RGWCompletionManager *completion_manager, void *user_info, int *pret);
int lock_exclusive(int shard_id, utime_t& duration, string&zone_id, string& owner_id); int lock_exclusive(int shard_id, timespan duration, string&zone_id, string& owner_id);
int unlock(int shard_id, string& zone_id, string& owner_id); int unlock(int shard_id, string& zone_id, string& owner_id);
int update_shards(list<int>& shards); int update_shards(list<int>& shards);
@ -245,7 +246,7 @@ class RGWMetadataManager {
string heap_oid(RGWMetadataHandler *handler, const string& key, const obj_version& objv); string heap_oid(RGWMetadataHandler *handler, const string& key, const obj_version& objv);
int store_in_heap(RGWMetadataHandler *handler, const string& key, bufferlist& bl, int store_in_heap(RGWMetadataHandler *handler, const string& key, bufferlist& bl,
RGWObjVersionTracker *objv_tracker, time_t mtime, RGWObjVersionTracker *objv_tracker, real_time mtime,
map<string, bufferlist> *pattrs); map<string, bufferlist> *pattrs);
int remove_from_heap(RGWMetadataHandler *handler, const string& key, RGWObjVersionTracker *objv_tracker); int remove_from_heap(RGWMetadataHandler *handler, const string& key, RGWObjVersionTracker *objv_tracker);
public: public:
@ -266,7 +267,7 @@ public:
RGWMetadataHandler *get_handler(const string& type); RGWMetadataHandler *get_handler(const string& type);
int put_entry(RGWMetadataHandler *handler, const string& key, bufferlist& bl, bool exclusive, int put_entry(RGWMetadataHandler *handler, const string& key, bufferlist& bl, bool exclusive,
RGWObjVersionTracker *objv_tracker, time_t mtime, map<string, bufferlist> *pattrs = NULL); RGWObjVersionTracker *objv_tracker, real_time mtime, map<string, bufferlist> *pattrs = NULL);
int remove_entry(RGWMetadataHandler *handler, string& key, RGWObjVersionTracker *objv_tracker); int remove_entry(RGWMetadataHandler *handler, string& key, RGWObjVersionTracker *objv_tracker);
int get(string& metadata_key, Formatter *f); int get(string& metadata_key, Formatter *f);
int put(string& metadata_key, bufferlist& bl, int put(string& metadata_key, bufferlist& bl,
@ -281,7 +282,7 @@ public:
void dump_log_entry(cls_log_entry& entry, Formatter *f); void dump_log_entry(cls_log_entry& entry, Formatter *f);
void get_sections(list<string>& sections); void get_sections(list<string>& sections);
int lock_exclusive(string& metadata_key, utime_t duration, string& owner_id); int lock_exclusive(string& metadata_key, timespan duration, string& owner_id);
int unlock(string& metadata_key, string& owner_id); int unlock(string& metadata_key, string& owner_id);
int get_log_shard_id(const string& section, const string& key, int *shard_id); int get_log_shard_id(const string& section, const string& key, int *shard_id);

View File

@ -129,7 +129,10 @@ void RGWObjectExpirer::trim_chunk(const string& shard,
{ {
ldout(store->ctx(), 20) << "trying to trim removal hints to " << to << dendl; ldout(store->ctx(), 20) << "trying to trim removal hints to " << to << dendl;
int ret = store->objexp_hint_trim(shard, from, to); real_time rt_from = from.to_real_time();
real_time rt_to = to.to_real_time();
int ret = store->objexp_hint_trim(shard, rt_from, rt_to);
if (ret < 0) { if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR during trim: " << ret << dendl; ldout(store->ctx(), 0) << "ERROR during trim: " << ret << dendl;
} }
@ -163,8 +166,11 @@ void RGWObjectExpirer::process_single_shard(const string& shard,
return; return;
} }
do { do {
real_time rt_last = last_run.to_real_time();
real_time rt_start = round_start.to_real_time();
list<cls_timeindex_entry> entries; list<cls_timeindex_entry> entries;
ret = store->objexp_hint_list(shard, last_run, round_start, ret = store->objexp_hint_list(shard, rt_last, rt_start,
num_entries, marker, entries, num_entries, marker, entries,
&out_marker, &truncated); &out_marker, &truncated);
if (ret < 0) { if (ret < 0) {

View File

@ -1546,7 +1546,7 @@ void RGWSetBucketVersioning::execute()
s->bucket_info.flags |= (BUCKET_VERSIONED | BUCKET_VERSIONS_SUSPENDED); s->bucket_info.flags |= (BUCKET_VERSIONED | BUCKET_VERSIONS_SUSPENDED);
} }
op_ret = store->put_bucket_instance_info(s->bucket_info, false, 0, op_ret = store->put_bucket_instance_info(s->bucket_info, false, real_time(),
&s->bucket_attrs); &s->bucket_attrs);
if (op_ret < 0) { if (op_ret < 0) {
ldout(s->cct, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket.name ldout(s->cct, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket.name
@ -1598,7 +1598,7 @@ void RGWSetBucketWebsite::execute()
s->bucket_info.has_website = true; s->bucket_info.has_website = true;
s->bucket_info.website_conf = website_conf; s->bucket_info.website_conf = website_conf;
op_ret = store->put_bucket_instance_info(s->bucket_info, false, 0, &s->bucket_attrs); op_ret = store->put_bucket_instance_info(s->bucket_info, false, real_time(), &s->bucket_attrs);
if (op_ret < 0) { if (op_ret < 0) {
ldout(s->cct, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket.name << " returned err=" << op_ret << dendl; ldout(s->cct, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket.name << " returned err=" << op_ret << dendl;
return; return;
@ -1623,7 +1623,7 @@ void RGWDeleteBucketWebsite::execute()
s->bucket_info.has_website = false; s->bucket_info.has_website = false;
s->bucket_info.website_conf = RGWBucketWebsiteConf(); s->bucket_info.website_conf = RGWBucketWebsiteConf();
op_ret = store->put_bucket_instance_info(s->bucket_info, false, 0, &s->bucket_attrs); op_ret = store->put_bucket_instance_info(s->bucket_info, false, real_time(), &s->bucket_attrs);
if (op_ret < 0) { if (op_ret < 0) {
ldout(s->cct, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket.name << " returned err=" << op_ret << dendl; ldout(s->cct, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket.name << " returned err=" << op_ret << dendl;
return; return;
@ -1866,7 +1866,7 @@ void RGWCreateBucket::execute()
RGWBucketInfo master_info; RGWBucketInfo master_info;
rgw_bucket *pmaster_bucket; rgw_bucket *pmaster_bucket;
time_t creation_time; real_time creation_time;
if (!store->is_meta_master()) { if (!store->is_meta_master()) {
JSONParser jp; JSONParser jp;
@ -1884,7 +1884,6 @@ void RGWCreateBucket::execute()
pobjv = &objv; pobjv = &objv;
} else { } else {
pmaster_bucket = NULL; pmaster_bucket = NULL;
creation_time = 0;
} }
string zonegroup_id; string zonegroup_id;
@ -2060,8 +2059,8 @@ class RGWPutObjProcessor_Multipart : public RGWPutObjProcessor_Atomic
protected: protected:
int prepare(RGWRados *store, string *oid_rand); int prepare(RGWRados *store, string *oid_rand);
int do_complete(string& etag, time_t *mtime, time_t set_mtime, int do_complete(string& etag, real_time *mtime, real_time set_mtime,
map<string, bufferlist>& attrs, time_t delete_at, map<string, bufferlist>& attrs, real_time delete_at,
const char *if_match = NULL, const char *if_nomatch = NULL); const char *if_match = NULL, const char *if_nomatch = NULL);
public: public:
@ -2134,8 +2133,8 @@ static bool is_v2_upload_id(const string& upload_id)
(strncmp(uid, MULTIPART_UPLOAD_ID_PREFIX_LEGACY, sizeof(MULTIPART_UPLOAD_ID_PREFIX_LEGACY) - 1) == 0); (strncmp(uid, MULTIPART_UPLOAD_ID_PREFIX_LEGACY, sizeof(MULTIPART_UPLOAD_ID_PREFIX_LEGACY) - 1) == 0);
} }
int RGWPutObjProcessor_Multipart::do_complete(string& etag, time_t *mtime, time_t set_mtime, int RGWPutObjProcessor_Multipart::do_complete(string& etag, real_time *mtime, real_time set_mtime,
map<string, bufferlist>& attrs, time_t delete_at, map<string, bufferlist>& attrs, real_time delete_at,
const char *if_match, const char *if_nomatch) const char *if_match, const char *if_nomatch)
{ {
complete_writing_data(); complete_writing_data();
@ -2173,7 +2172,7 @@ int RGWPutObjProcessor_Multipart::do_complete(string& etag, time_t *mtime, time_
info.num = atoi(part_num.c_str()); info.num = atoi(part_num.c_str());
info.etag = etag; info.etag = etag;
info.size = s->obj_size; info.size = s->obj_size;
info.modified = ceph_clock_now(store->ctx()); info.modified = real_clock::now();
info.manifest = manifest; info.manifest = manifest;
::encode(info, bl); ::encode(info, bl);
@ -2467,7 +2466,7 @@ void RGWPutObj::execute()
attrs[RGW_ATTR_SLO_UINDICATOR] = slo_userindicator_bl; attrs[RGW_ATTR_SLO_UINDICATOR] = slo_userindicator_bl;
} }
op_ret = processor->complete(etag, &mtime, 0, attrs, delete_at, if_match, op_ret = processor->complete(etag, &mtime, real_time(), attrs, delete_at, if_match,
if_nomatch); if_nomatch);
done: done:
@ -2589,7 +2588,7 @@ void RGWPostObj::execute()
attrs[RGW_ATTR_CONTENT_TYPE] = ct_bl; attrs[RGW_ATTR_CONTENT_TYPE] = ct_bl;
} }
op_ret = processor->complete(etag, NULL, 0, attrs, delete_at); op_ret = processor->complete(etag, NULL, real_time(), attrs, delete_at);
done: done:
dispose_processor(processor); dispose_processor(processor);
@ -2750,7 +2749,7 @@ void RGWPutMetadataAccount::execute()
/* XXX tenant needed? */ /* XXX tenant needed? */
op_ret = rgw_store_user_info(store, *(s->user), &orig_uinfo, op_ret = rgw_store_user_info(store, *(s->user), &orig_uinfo,
&acct_op_tracker, 0, false, &attrs); &acct_op_tracker, real_time(), false, &attrs);
if (op_ret < 0) { if (op_ret < 0) {
return; return;
} }
@ -3592,7 +3591,7 @@ void RGWSetRequestPayment::execute()
return; return;
s->bucket_info.requester_pays = requester_pays; s->bucket_info.requester_pays = requester_pays;
op_ret = store->put_bucket_instance_info(s->bucket_info, false, 0, op_ret = store->put_bucket_instance_info(s->bucket_info, false, real_time(),
&s->bucket_attrs); &s->bucket_attrs);
if (op_ret < 0) { if (op_ret < 0) {
ldout(s->cct, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket.name ldout(s->cct, 0) << "NOTICE: put_bucket_info on bucket=" << s->bucket.name

View File

@ -23,6 +23,7 @@
#include "common/utf8.h" #include "common/utf8.h"
#include "common/ceph_json.h" #include "common/ceph_json.h"
#include "common/utf8.h" #include "common/utf8.h"
#include "common/ceph_time.h"
#include "rgw_common.h" #include "rgw_common.h"
#include "rgw_rados.h" #include "rgw_rados.h"
@ -111,11 +112,11 @@ protected:
uint64_t total_len; uint64_t total_len;
off_t start; off_t start;
off_t end; off_t end;
time_t mod_time; ceph::real_time mod_time;
time_t lastmod; ceph::real_time lastmod;
time_t unmod_time; ceph::real_time unmod_time;
time_t *mod_ptr; ceph::real_time *mod_ptr;
time_t *unmod_ptr; ceph::real_time *unmod_ptr;
map<string, bufferlist> attrs; map<string, bufferlist> attrs;
bool get_data; bool get_data;
bool partial_content; bool partial_content;
@ -140,9 +141,6 @@ public:
ofs = 0; ofs = 0;
total_len = 0; total_len = 0;
end = -1; end = -1;
mod_time = 0;
lastmod = 0;
unmod_time = 0;
mod_ptr = NULL; mod_ptr = NULL;
unmod_ptr = NULL; unmod_ptr = NULL;
get_data = false; get_data = false;
@ -647,11 +645,11 @@ protected:
const char *dlo_manifest; const char *dlo_manifest;
RGWSLOInfo *slo_info; RGWSLOInfo *slo_info;
time_t mtime; ceph::real_time mtime;
uint64_t olh_epoch; uint64_t olh_epoch;
string version_id; string version_id;
time_t delete_at; ceph::real_time delete_at;
public: public:
RGWPutObj() : ofs(0), RGWPutObj() : ofs(0),
@ -662,9 +660,7 @@ public:
chunked_upload(0), chunked_upload(0),
dlo_manifest(NULL), dlo_manifest(NULL),
slo_info(NULL), slo_info(NULL),
mtime(0), olh_epoch(0) {}
olh_epoch(0),
delete_at(0) {}
~RGWPutObj() { ~RGWPutObj() {
delete slo_info; delete slo_info;
@ -707,12 +703,12 @@ protected:
string content_type; string content_type;
RGWAccessControlPolicy policy; RGWAccessControlPolicy policy;
map<string, bufferlist> attrs; map<string, bufferlist> attrs;
time_t delete_at; ceph::real_time delete_at;
public: public:
RGWPostObj() : min_len(0), max_len(LLONG_MAX), len(0), ofs(0), RGWPostObj() : min_len(0), max_len(LLONG_MAX), len(0), ofs(0),
supplied_md5_b64(NULL), supplied_etag(NULL), supplied_md5_b64(NULL), supplied_etag(NULL),
data_pending(false), delete_at(0) {} data_pending(false) {}
virtual void init(RGWRados *store, struct req_state *s, RGWHandler *h) { virtual void init(RGWRados *store, struct req_state *s, RGWHandler *h) {
RGWOp::init(store, s, h); RGWOp::init(store, s, h);
@ -794,13 +790,12 @@ class RGWPutMetadataObject : public RGWOp {
protected: protected:
RGWAccessControlPolicy policy; RGWAccessControlPolicy policy;
string placement_rule; string placement_rule;
time_t delete_at; ceph::real_time delete_at;
const char *dlo_manifest; const char *dlo_manifest;
public: public:
RGWPutMetadataObject() RGWPutMetadataObject()
: delete_at(0), : dlo_manifest(NULL)
dlo_manifest(NULL)
{} {}
virtual void init(RGWRados *store, struct req_state *s, RGWHandler *h) { virtual void init(RGWRados *store, struct req_state *s, RGWHandler *h) {
@ -824,7 +819,7 @@ protected:
bool delete_marker; bool delete_marker;
bool multipart_delete; bool multipart_delete;
string version_id; string version_id;
time_t unmod_since; /* if unmodified since */ ceph::real_time unmod_since; /* if unmodified since */
bool no_precondition_error; bool no_precondition_error;
std::unique_ptr<RGWBulkDelete::Deleter> deleter; std::unique_ptr<RGWBulkDelete::Deleter> deleter;
@ -832,7 +827,6 @@ public:
RGWDeleteObj() RGWDeleteObj()
: delete_marker(false), : delete_marker(false),
multipart_delete(false), multipart_delete(false),
unmod_since(0),
no_precondition_error(false), no_precondition_error(false),
deleter(nullptr) { deleter(nullptr) {
} }
@ -860,10 +854,10 @@ protected:
off_t ofs; off_t ofs;
off_t len; off_t len;
off_t end; off_t end;
time_t mod_time; ceph::real_time mod_time;
time_t unmod_time; ceph::real_time unmod_time;
time_t *mod_ptr; ceph::real_time *mod_ptr;
time_t *unmod_ptr; ceph::real_time *unmod_ptr;
map<string, bufferlist> attrs; map<string, bufferlist> attrs;
string src_tenant_name, src_bucket_name; string src_tenant_name, src_bucket_name;
rgw_bucket src_bucket; rgw_bucket src_bucket;
@ -871,8 +865,8 @@ protected:
string dest_tenant_name, dest_bucket_name; string dest_tenant_name, dest_bucket_name;
rgw_bucket dest_bucket; rgw_bucket dest_bucket;
string dest_object; string dest_object;
time_t src_mtime; ceph::real_time src_mtime;
time_t mtime; ceph::real_time mtime;
RGWRados::AttrsMod attrs_mod; RGWRados::AttrsMod attrs_mod;
RGWBucketInfo src_bucket_info; RGWBucketInfo src_bucket_info;
RGWBucketInfo dest_bucket_info; RGWBucketInfo dest_bucket_info;
@ -886,7 +880,7 @@ protected:
string version_id; string version_id;
uint64_t olh_epoch; uint64_t olh_epoch;
time_t delete_at; ceph::real_time delete_at;
bool copy_if_newer; bool copy_if_newer;
int init_common(); int init_common();
@ -900,16 +894,11 @@ public:
ofs = 0; ofs = 0;
len = 0; len = 0;
end = -1; end = -1;
mod_time = 0;
unmod_time = 0;
mod_ptr = NULL; mod_ptr = NULL;
unmod_ptr = NULL; unmod_ptr = NULL;
src_mtime = 0;
mtime = 0;
attrs_mod = RGWRados::ATTRSMOD_NONE; attrs_mod = RGWRados::ATTRSMOD_NONE;
last_ofs = 0; last_ofs = 0;
olh_epoch = 0; olh_epoch = 0;
delete_at = 0;
copy_if_newer = false; copy_if_newer = false;
} }
@ -1451,15 +1440,15 @@ static inline void rgw_get_request_metadata(CephContext *cct,
} }
} /* rgw_get_request_metadata */ } /* rgw_get_request_metadata */
static inline void encode_delete_at_attr(time_t delete_at, static inline void encode_delete_at_attr(ceph::real_time delete_at,
map<string, bufferlist>& attrs) map<string, bufferlist>& attrs)
{ {
if (delete_at == 0) { if (real_clock::is_zero(delete_at)) {
return; return;
} }
bufferlist delatbl; bufferlist delatbl;
::encode(utime_t(delete_at, 0), delatbl); ::encode(delete_at, delatbl);
attrs[RGW_ATTR_DELETE_AT] = delatbl; attrs[RGW_ATTR_DELETE_AT] = delatbl;
} /* encode_delete_at_attr */ } /* encode_delete_at_attr */

View File

@ -590,10 +590,11 @@ int RGWUserStatsCache::sync_user(const rgw_user& user)
return 0; return 0;
} }
utime_t when_need_full_sync = header.last_stats_sync; real_time when_need_full_sync = header.last_stats_sync;
when_need_full_sync += store->ctx()->_conf->rgw_user_quota_sync_wait_time; when_need_full_sync += timespan(store->ctx()->_conf->rgw_user_quota_sync_wait_time);
// check if enough time passed since last full sync // check if enough time passed since last full sync
/* FIXME: missing check? */
ret = rgw_user_sync_all_stats(store, user); ret = rgw_user_sync_all_stats(store, user);
if (ret < 0) { if (ret < 0) {

View File

@ -108,7 +108,7 @@ static string RGW_DEFAULT_PERIOD_ROOT_POOL = "rgw.root";
struct bucket_info_entry { struct bucket_info_entry {
RGWBucketInfo info; RGWBucketInfo info;
time_t mtime; real_time mtime;
map<string, bufferlist> attrs; map<string, bufferlist> attrs;
}; };
@ -454,7 +454,7 @@ int RGWSystemMetaObj::set_as_default()
::encode(default_info, bl); ::encode(default_info, bl);
int ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), false, NULL, 0, NULL); int ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), false, NULL, real_time(), NULL);
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -544,7 +544,7 @@ int RGWSystemMetaObj::store_name(bool exclusive)
bufferlist bl; bufferlist bl;
::encode(nameToId, bl); ::encode(nameToId, bl);
return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, NULL, 0, NULL); return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, NULL, real_time(), NULL);
} }
int RGWSystemMetaObj::rename(const string& new_name) int RGWSystemMetaObj::rename(const string& new_name)
@ -663,7 +663,7 @@ int RGWSystemMetaObj::store_info(bool exclusive)
bufferlist bl; bufferlist bl;
::encode(*this, bl); ::encode(*this, bl);
return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, NULL, 0, NULL); return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, NULL, real_time(), NULL);
} }
int RGWSystemMetaObj::write(bool exclusive) int RGWSystemMetaObj::write(bool exclusive)
@ -759,7 +759,7 @@ int RGWRealm::create_control()
auto pool = rgw_bucket{pool_name.c_str()}; auto pool = rgw_bucket{pool_name.c_str()};
auto oid = get_control_oid(); auto oid = get_control_oid();
return rgw_put_system_obj(store, pool, oid, nullptr, 0, true, return rgw_put_system_obj(store, pool, oid, nullptr, 0, true,
nullptr, 0, nullptr); nullptr, real_time(), nullptr);
} }
int RGWRealm::delete_control() int RGWRealm::delete_control()
@ -1021,7 +1021,7 @@ int RGWPeriod::set_latest_epoch(epoch_t epoch, bool exclusive)
::encode(info, bl); ::encode(info, bl);
return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), return rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(),
exclusive, NULL, 0, NULL); exclusive, NULL, real_time(), NULL);
} }
int RGWPeriod::delete_obj() int RGWPeriod::delete_obj()
@ -1106,7 +1106,7 @@ int RGWPeriod::store_info(bool exclusive)
string oid = get_period_oid(); string oid = get_period_oid();
bufferlist bl; bufferlist bl;
::encode(*this, bl); ::encode(*this, bl);
ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, NULL, 0, NULL); ret = rgw_put_system_obj(store, pool, oid, bl.c_str(), bl.length(), exclusive, NULL, real_time(), NULL);
if (ret < 0) { if (ret < 0) {
ldout(cct, 0) << "ERROR: rgw_put_system_obj(" << pool << ":" << oid << "): " << cpp_strerror(-ret) << dendl; ldout(cct, 0) << "ERROR: rgw_put_system_obj(" << pool << ":" << oid << "): " << cpp_strerror(-ret) << dendl;
return ret; return ret;
@ -2123,8 +2123,8 @@ void RGWObjVersionTracker::generate_new_write_ver(CephContext *cct)
append_rand_alpha(cct, write_version.tag, write_version.tag, TAG_LEN); append_rand_alpha(cct, write_version.tag, write_version.tag, TAG_LEN);
} }
int RGWPutObjProcessor::complete(string& etag, time_t *mtime, time_t set_mtime, int RGWPutObjProcessor::complete(string& etag, real_time *mtime, real_time set_mtime,
map<string, bufferlist>& attrs, time_t delete_at, map<string, bufferlist>& attrs, real_time delete_at,
const char *if_match, const char * if_nomatch) const char *if_match, const char * if_nomatch)
{ {
int r = do_complete(etag, mtime, set_mtime, attrs, delete_at, if_match, if_nomatch); int r = do_complete(etag, mtime, set_mtime, attrs, delete_at, if_match, if_nomatch);
@ -2446,8 +2446,8 @@ int RGWPutObjProcessor_Atomic::complete_writing_data()
return 0; return 0;
} }
int RGWPutObjProcessor_Atomic::do_complete(string& etag, time_t *mtime, time_t set_mtime, int RGWPutObjProcessor_Atomic::do_complete(string& etag, real_time *mtime, real_time set_mtime,
map<string, bufferlist>& attrs, time_t delete_at, map<string, bufferlist>& attrs, real_time delete_at,
const char *if_match, const char *if_match,
const char *if_nomatch) { const char *if_nomatch) {
int r = complete_writing_data(); int r = complete_writing_data();
@ -4257,8 +4257,7 @@ int RGWRados::log_usage(map<rgw_user_bucket, RGWUsageBatch>& usage_info)
last_user = ub.user; last_user = ub.user;
vector<rgw_usage_log_entry>& v = log_objs[hash].entries; vector<rgw_usage_log_entry>& v = log_objs[hash].entries;
map<utime_t, rgw_usage_log_entry>::iterator miter; for (auto miter = info.m.begin(); miter != info.m.end(); ++miter) {
for (miter = info.m.begin(); miter != info.m.end(); ++miter) {
v.push_back(miter->second); v.push_back(miter->second);
} }
} }
@ -4376,9 +4375,9 @@ void RGWRados::shard_name(const string& prefix, unsigned shard_id, string& name)
} }
void RGWRados::time_log_prepare_entry(cls_log_entry& entry, const utime_t& ut, const string& section, const string& key, bufferlist& bl) void RGWRados::time_log_prepare_entry(cls_log_entry& entry, const real_time& ut, const string& section, const string& key, bufferlist& bl)
{ {
cls_log_add_prepare_entry(entry, ut, section, key, bl); cls_log_add_prepare_entry(entry, utime_t(ut), section, key, bl);
} }
int RGWRados::time_log_add_init(librados::IoCtx& io_ctx) int RGWRados::time_log_add_init(librados::IoCtx& io_ctx)
@ -4402,7 +4401,7 @@ int RGWRados::time_log_add_init(librados::IoCtx& io_ctx)
} }
int RGWRados::time_log_add(const string& oid, const utime_t& ut, const string& section, const string& key, bufferlist& bl) int RGWRados::time_log_add(const string& oid, const real_time& ut, const string& section, const string& key, bufferlist& bl)
{ {
librados::IoCtx io_ctx; librados::IoCtx io_ctx;
@ -4412,7 +4411,8 @@ int RGWRados::time_log_add(const string& oid, const utime_t& ut, const string& s
} }
ObjectWriteOperation op; ObjectWriteOperation op;
cls_log_add(op, ut, section, key, bl); utime_t t(ut);
cls_log_add(op, t, section, key, bl);
r = io_ctx.operate(oid, &op); r = io_ctx.operate(oid, &op);
return r; return r;
@ -4439,7 +4439,7 @@ int RGWRados::time_log_add(const string& oid, list<cls_log_entry>& entries,
return r; return r;
} }
int RGWRados::time_log_list(const string& oid, utime_t& start_time, utime_t& end_time, int RGWRados::time_log_list(const string& oid, const real_time& start_time, const real_time& end_time,
int max_entries, list<cls_log_entry>& entries, int max_entries, list<cls_log_entry>& entries,
const string& marker, const string& marker,
string *out_marker, string *out_marker,
@ -4454,7 +4454,10 @@ int RGWRados::time_log_list(const string& oid, utime_t& start_time, utime_t& end
return r; return r;
librados::ObjectReadOperation op; librados::ObjectReadOperation op;
cls_log_list(op, start_time, end_time, marker, max_entries, entries, utime_t st(start_time);
utime_t et(end_time);
cls_log_list(op, st, et, marker, max_entries, entries,
out_marker, truncated); out_marker, truncated);
bufferlist obl; bufferlist obl;
@ -4507,7 +4510,7 @@ int RGWRados::time_log_info_async(librados::IoCtx& io_ctx, const string& oid, cl
return 0; return 0;
} }
int RGWRados::time_log_trim(const string& oid, const utime_t& start_time, const utime_t& end_time, int RGWRados::time_log_trim(const string& oid, const real_time& start_time, const real_time& end_time,
const string& from_marker, const string& to_marker) const string& from_marker, const string& to_marker)
{ {
librados::IoCtx io_ctx; librados::IoCtx io_ctx;
@ -4518,7 +4521,10 @@ int RGWRados::time_log_trim(const string& oid, const utime_t& start_time, const
if (r < 0) if (r < 0)
return r; return r;
return cls_log_trim(io_ctx, oid, start_time, end_time, from_marker, to_marker); utime_t st(start_time);
utime_t et(end_time);
return cls_log_trim(io_ctx, oid, st, et, from_marker, to_marker);
} }
string RGWRados::objexp_hint_get_shardname(int shard_num) string RGWRados::objexp_hint_get_shardname(int shard_num)
@ -4551,7 +4557,7 @@ static string objexp_hint_get_keyext(const string& tenant_name,
":" + obj_key.name + ":" + obj_key.instance; ":" + obj_key.name + ":" + obj_key.instance;
} }
int RGWRados::objexp_hint_add(const utime_t& delete_at, int RGWRados::objexp_hint_add(const ceph::real_time& delete_at,
const string& tenant_name, const string& tenant_name,
const string& bucket_name, const string& bucket_name,
const string& bucket_id, const string& bucket_id,
@ -4568,7 +4574,7 @@ int RGWRados::objexp_hint_add(const utime_t& delete_at,
bufferlist hebl; bufferlist hebl;
::encode(he, hebl); ::encode(he, hebl);
ObjectWriteOperation op; ObjectWriteOperation op;
cls_timeindex_add(op, delete_at, keyext, hebl); cls_timeindex_add(op, utime_t(delete_at), keyext, hebl);
string shard_name = objexp_hint_get_shardname(objexp_key_shard(obj_key)); string shard_name = objexp_hint_get_shardname(objexp_key_shard(obj_key));
return objexp_pool_ctx.operate(shard_name, &op); return objexp_pool_ctx.operate(shard_name, &op);
@ -4581,8 +4587,8 @@ void RGWRados::objexp_get_shard(int shard_num,
} }
int RGWRados::objexp_hint_list(const string& oid, int RGWRados::objexp_hint_list(const string& oid,
const utime_t& start_time, const ceph::real_time& start_time,
const utime_t& end_time, const ceph::real_time& end_time,
const int max_entries, const int max_entries,
const string& marker, const string& marker,
list<cls_timeindex_entry>& entries, /* out */ list<cls_timeindex_entry>& entries, /* out */
@ -4590,7 +4596,7 @@ int RGWRados::objexp_hint_list(const string& oid,
bool *truncated) /* out */ bool *truncated) /* out */
{ {
librados::ObjectReadOperation op; librados::ObjectReadOperation op;
cls_timeindex_list(op, start_time, end_time, marker, max_entries, entries, cls_timeindex_list(op, utime_t(start_time), utime_t(end_time), marker, max_entries, entries,
out_marker, truncated); out_marker, truncated);
bufferlist obl; bufferlist obl;
@ -4621,12 +4627,12 @@ int RGWRados::objexp_hint_parse(cls_timeindex_entry &ti_entry, /* in */
} }
int RGWRados::objexp_hint_trim(const string& oid, int RGWRados::objexp_hint_trim(const string& oid,
const utime_t& start_time, const ceph::real_time& start_time,
const utime_t& end_time, const ceph::real_time& end_time,
const string& from_marker, const string& from_marker,
const string& to_marker) const string& to_marker)
{ {
int ret = cls_timeindex_trim(objexp_pool_ctx, oid, start_time, end_time, int ret = cls_timeindex_trim(objexp_pool_ctx, oid, utime_t(start_time), utime_t(end_time),
from_marker, to_marker); from_marker, to_marker);
if ((ret < 0 ) && (ret != -ENOENT)) { if ((ret < 0 ) && (ret != -ENOENT)) {
return ret; return ret;
@ -4635,7 +4641,7 @@ int RGWRados::objexp_hint_trim(const string& oid,
return 0; return 0;
} }
int RGWRados::lock_exclusive(rgw_bucket& pool, const string& oid, utime_t& duration, int RGWRados::lock_exclusive(rgw_bucket& pool, const string& oid, timespan& duration,
string& zone_id, string& owner_id) { string& zone_id, string& owner_id) {
librados::IoCtx io_ctx; librados::IoCtx io_ctx;
@ -4645,9 +4651,11 @@ int RGWRados::lock_exclusive(rgw_bucket& pool, const string& oid, utime_t& durat
int r = rad->ioctx_create(pool_name, io_ctx); int r = rad->ioctx_create(pool_name, io_ctx);
if (r < 0) if (r < 0)
return r; return r;
uint64_t msec = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
utime_t ut(msec / 1000, msec % 1000);
rados::cls::lock::Lock l(log_lock_name); rados::cls::lock::Lock l(log_lock_name);
l.set_duration(duration); l.set_duration(ut);
l.set_cookie(owner_id); l.set_cookie(owner_id);
l.set_tag(zone_id); l.set_tag(zone_id);
l.set_renew(true); l.set_renew(true);
@ -4949,7 +4957,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
RGWBucketInfo& info, RGWBucketInfo& info,
obj_version *pobjv, obj_version *pobjv,
obj_version *pep_objv, obj_version *pep_objv,
time_t creation_time, real_time creation_time,
rgw_bucket *pmaster_bucket, rgw_bucket *pmaster_bucket,
bool exclusive) bool exclusive)
{ {
@ -5010,11 +5018,11 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
info.num_shards = bucket_index_max_shards; info.num_shards = bucket_index_max_shards;
info.bucket_index_shard_hash_type = RGWBucketInfo::MOD; info.bucket_index_shard_hash_type = RGWBucketInfo::MOD;
info.requester_pays = false; info.requester_pays = false;
if (!creation_time) if (real_clock::is_zero(creation_time))
time(&info.creation_time); creation_time = ceph::real_clock::now(cct);
else else
info.creation_time = creation_time; info.creation_time = creation_time;
ret = put_linked_bucket_info(info, exclusive, 0, pep_objv, &attrs, true); ret = put_linked_bucket_info(info, exclusive, ceph::real_time(), pep_objv, &attrs, true);
if (ret == -EEXIST) { if (ret == -EEXIST) {
/* we need to reread the info and return it, caller will have a use for it */ /* we need to reread the info and return it, caller will have a use for it */
RGWObjVersionTracker instance_ver = info.objv_tracker; RGWObjVersionTracker instance_ver = info.objv_tracker;
@ -5440,13 +5448,13 @@ int RGWRados::fix_head_obj_locator(rgw_bucket& bucket, bool copy_obj, bool remov
ioctx.locator_set_key(string()); /* override locator for this object, use empty locator */ ioctx.locator_set_key(string()); /* override locator for this object, use empty locator */
uint64_t size; uint64_t size;
time_t mtime;
bufferlist data; bufferlist data;
struct timespec mtime_ts;
map<string, bufferlist> attrs; map<string, bufferlist> attrs;
librados::ObjectReadOperation op; librados::ObjectReadOperation op;
op.getxattrs(&attrs, NULL); op.getxattrs(&attrs, NULL);
op.stat(&size, &mtime, NULL); op.stat2(&size, &mtime_ts, NULL);
#define HEAD_SIZE 512 * 1024 #define HEAD_SIZE 512 * 1024
op.read(0, HEAD_SIZE, &data, NULL); op.read(0, HEAD_SIZE, &data, NULL);
@ -5469,7 +5477,7 @@ int RGWRados::fix_head_obj_locator(rgw_bucket& bucket, bool copy_obj, bool remov
if (copy_obj) { if (copy_obj) {
librados::ObjectWriteOperation wop; librados::ObjectWriteOperation wop;
wop.mtime(&mtime); wop.mtime2(&mtime_ts);
map<string, bufferlist>::iterator iter; map<string, bufferlist>::iterator iter;
for (iter = attrs.begin(); iter != attrs.end(); ++iter) { for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
@ -5506,7 +5514,7 @@ int RGWRados::move_rados_obj(librados::IoCtx& src_ioctx,
uint64_t chunk_size = COPY_BUF_SIZE; uint64_t chunk_size = COPY_BUF_SIZE;
uint64_t ofs = 0; uint64_t ofs = 0;
int ret = 0; int ret = 0;
time_t mtime = 0; struct timespec mtime_ts;
uint64_t size; uint64_t size;
if (src_oid == dst_oid && src_locator == dst_locator) { if (src_oid == dst_oid && src_locator == dst_locator) {
@ -5522,7 +5530,7 @@ int RGWRados::move_rados_obj(librados::IoCtx& src_ioctx,
ObjectWriteOperation wop; ObjectWriteOperation wop;
if (ofs == 0) { if (ofs == 0) {
rop.stat(&size, &mtime, NULL); rop.stat2(&size, &mtime_ts, NULL);
} }
rop.read(ofs, chunk_size, &data, NULL); rop.read(ofs, chunk_size, &data, NULL);
ret = src_ioctx.operate(src_oid, &rop, NULL); ret = src_ioctx.operate(src_oid, &rop, NULL);
@ -5536,7 +5544,7 @@ int RGWRados::move_rados_obj(librados::IoCtx& src_ioctx,
if (ofs == 0) { if (ofs == 0) {
wop.create(true); /* make it exclusive */ wop.create(true); /* make it exclusive */
wop.mtime(&mtime); wop.mtime2(&mtime_ts);
} }
wop.write(ofs, data); wop.write(ofs, data);
ret = dst_ioctx.operate(dst_oid, &wop); ret = dst_ioctx.operate(dst_oid, &wop);
@ -5668,8 +5676,9 @@ int RGWRados::swift_versioning_copy(RGWBucketInfo& bucket_info, RGWRados::Object
rgw_obj& obj = source->get_obj(); rgw_obj& obj = source->get_obj();
const string& src_name = obj.get_object(); const string& src_name = obj.get_object();
char buf[src_name.size() + 32]; char buf[src_name.size() + 32];
snprintf(buf, sizeof(buf), "%03d%s/%lld.%06d", (int)src_name.size(), struct timespec ts = ceph::real_clock::to_timespec(state->mtime);
src_name.c_str(), (long long)state->mtime, 0); snprintf(buf, sizeof(buf), "%03d%s/%lld.%06ld", (int)src_name.size(),
src_name.c_str(), (long long)ts.tv_sec, ts.tv_nsec / 1000);
RGWBucketInfo dest_bucket_info; RGWBucketInfo dest_bucket_info;
@ -5708,7 +5717,7 @@ int RGWRados::swift_versioning_copy(RGWBucketInfo& bucket_info, RGWRados::Object
state->attrset, state->attrset,
RGW_OBJ_CATEGORY_MAIN, RGW_OBJ_CATEGORY_MAIN,
0, /* uint64_t olh_epoch */ 0, /* uint64_t olh_epoch */
0, /* time_t delete_at */ real_time(), /* time_t delete_at */
NULL, /* string *version_id */ NULL, /* string *version_id */
NULL, /* string *ptag */ NULL, /* string *ptag */
NULL, /* string *petag */ NULL, /* string *petag */
@ -5765,18 +5774,15 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
if (r < 0) if (r < 0)
return r; return r;
utime_t ut; if (real_clock::is_zero(meta.set_mtime)) {
if (meta.set_mtime) { meta.set_mtime = real_clock::now();
ut = utime_t(meta.set_mtime, 0);
} else {
ut = ceph_clock_now(0);
meta.set_mtime = ut.sec();
} }
if (state->is_olh) { if (state->is_olh) {
op.setxattr(RGW_ATTR_OLH_ID_TAG, state->olh_tag); op.setxattr(RGW_ATTR_OLH_ID_TAG, state->olh_tag);
} }
op.mtime(&meta.set_mtime); struct timespec mtime_ts = ceph::real_clock::to_timespec(meta.set_mtime);
op.mtime2(&mtime_ts);
if (meta.data) { if (meta.data) {
/* if we want to overwrite the data, we also want to overwrite the /* if we want to overwrite the data, we also want to overwrite the
@ -5884,7 +5890,7 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
} }
r = index_op.complete(poolid, epoch, size, r = index_op.complete(poolid, epoch, size,
ut, etag, content_type, &acl_bl, meta.set_mtime, etag, content_type, &acl_bl,
meta.category, meta.remove_objs); meta.category, meta.remove_objs);
if (r < 0) if (r < 0)
goto done_cancel; goto done_cancel;
@ -5898,17 +5904,17 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
state = NULL; state = NULL;
if (versioned_op) { if (versioned_op) {
r = store->set_olh(target->get_ctx(), target->get_bucket_info(), obj, false, NULL, meta.olh_epoch, 0); r = store->set_olh(target->get_ctx(), target->get_bucket_info(), obj, false, NULL, meta.olh_epoch, real_time());
if (r < 0) { if (r < 0) {
return r; return r;
} }
} }
if (meta.delete_at > 0) { if (!real_clock::is_zero(meta.delete_at)) {
rgw_obj_key obj_key; rgw_obj_key obj_key;
obj.get_index_key(&obj_key); obj.get_index_key(&obj_key);
r = store->objexp_hint_add(utime_t(meta.delete_at, 0), r = store->objexp_hint_add(meta.delete_at,
bucket.tenant, bucket.name, bucket.bucket_id, obj_key); bucket.tenant, bucket.name, bucket.bucket_id, obj_key);
if (r < 0) { if (r < 0) {
ldout(store->ctx(), 0) << "ERROR: objexp_hint_add() returned r=" << r << ", object will not get removed" << dendl; ldout(store->ctx(), 0) << "ERROR: objexp_hint_add() returned r=" << r << ", object will not get removed" << dendl;
@ -5968,11 +5974,11 @@ done_cancel:
} }
/** Write/overwrite a system object. */ /** Write/overwrite a system object. */
int RGWRados::put_system_obj_impl(rgw_obj& obj, uint64_t size, time_t *mtime, int RGWRados::put_system_obj_impl(rgw_obj& obj, uint64_t size, real_time *mtime,
map<std::string, bufferlist>& attrs, int flags, map<std::string, bufferlist>& attrs, int flags,
bufferlist& data, bufferlist& data,
RGWObjVersionTracker *objv_tracker, RGWObjVersionTracker *objv_tracker,
time_t set_mtime /* 0 for don't set */) real_time set_mtime /* 0 for don't set */)
{ {
rgw_bucket bucket; rgw_bucket bucket;
rgw_rados_ref ref; rgw_rados_ref ref;
@ -5996,15 +6002,13 @@ int RGWRados::put_system_obj_impl(rgw_obj& obj, uint64_t size, time_t *mtime,
objv_tracker->prepare_op_for_write(&op); objv_tracker->prepare_op_for_write(&op);
} }
utime_t ut; if (real_clock::is_zero(set_mtime)) {
if (set_mtime) { set_mtime = real_clock::now();
ut = utime_t(set_mtime, 0);
} else {
ut = ceph_clock_now(0);
set_mtime = ut.sec();
} }
op.mtime(&set_mtime); struct timespec mtime_ts = ceph::real_clock::to_timespec(set_mtime);
op.mtime2(&mtime_ts);
op.write_full(data); op.write_full(data);
bufferlist acl_bl; bufferlist acl_bl;
@ -6189,7 +6193,7 @@ public:
processor->set_extra_data_len(len); processor->set_extra_data_len(len);
} }
int complete(string& etag, time_t *mtime, time_t set_mtime, map<string, bufferlist>& attrs, time_t delete_at) { int complete(string& etag, real_time *mtime, real_time set_mtime, map<string, bufferlist>& attrs, real_time delete_at) {
return processor->complete(etag, mtime, set_mtime, attrs, delete_at); return processor->complete(etag, mtime, set_mtime, attrs, delete_at);
} }
@ -6230,7 +6234,7 @@ int RGWRados::rewrite_obj(RGWBucketInfo& dest_bucket_info, rgw_obj& obj)
int64_t ofs = 0; int64_t ofs = 0;
int64_t end = -1; int64_t end = -1;
time_t mtime; real_time mtime;
uint64_t total_len; uint64_t total_len;
uint64_t obj_size; uint64_t obj_size;
RGWObjectCtx rctx(this); RGWObjectCtx rctx(this);
@ -6257,15 +6261,16 @@ int RGWRados::rewrite_obj(RGWBucketInfo& dest_bucket_info, rgw_obj& obj)
return ret; return ret;
} }
return copy_obj_data(rctx, dest_bucket_info, read_op, end, obj, obj, max_chunk_size, NULL, mtime, attrset, RGW_OBJ_CATEGORY_MAIN, 0, 0, NULL, NULL, NULL, NULL); return copy_obj_data(rctx, dest_bucket_info, read_op, end, obj, obj, max_chunk_size, NULL, mtime, attrset,
RGW_OBJ_CATEGORY_MAIN, 0, real_time(), NULL, NULL, NULL, NULL);
} }
struct obj_time_weight { struct obj_time_weight {
time_t mtime; real_time mtime;
uint32_t zone_short_id; uint32_t zone_short_id;
uint64_t pg_ver; uint64_t pg_ver;
obj_time_weight() : mtime(0), zone_short_id(0), pg_ver(0) {} obj_time_weight() : zone_short_id(0), pg_ver(0) {}
bool operator<(const obj_time_weight& rhs) { bool operator<(const obj_time_weight& rhs) {
if (mtime > rhs.mtime) { if (mtime > rhs.mtime) {
@ -6280,7 +6285,7 @@ struct obj_time_weight {
return (pg_ver < rhs.pg_ver); return (pg_ver < rhs.pg_ver);
} }
void init(const time_t& _mtime, uint32_t _short_id, uint64_t _pg_ver) { void init(const real_time& _mtime, uint32_t _short_id, uint64_t _pg_ver) {
mtime = _mtime; mtime = _mtime;
zone_short_id = _short_id; zone_short_id = _short_id;
pg_ver = _pg_ver; pg_ver = _pg_ver;
@ -6313,10 +6318,10 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
rgw_obj& src_obj, rgw_obj& src_obj,
RGWBucketInfo& dest_bucket_info, RGWBucketInfo& dest_bucket_info,
RGWBucketInfo& src_bucket_info, RGWBucketInfo& src_bucket_info,
time_t *src_mtime, real_time *src_mtime,
time_t *mtime, real_time *mtime,
const time_t *mod_ptr, const real_time *mod_ptr,
const time_t *unmod_ptr, const real_time *unmod_ptr,
const char *if_match, const char *if_match,
const char *if_nomatch, const char *if_nomatch,
AttrsMod attrs_mod, AttrsMod attrs_mod,
@ -6324,7 +6329,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
map<string, bufferlist>& attrs, map<string, bufferlist>& attrs,
RGWObjCategory category, RGWObjCategory category,
uint64_t olh_epoch, uint64_t olh_epoch,
time_t delete_at, real_time delete_at,
string *version_id, string *version_id,
string *ptag, string *ptag,
string *petag, string *petag,
@ -6388,11 +6393,11 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
RGWRadosPutObj cb(&processor, &opstate, progress_cb, progress_data); RGWRadosPutObj cb(&processor, &opstate, progress_cb, progress_data);
string etag; string etag;
map<string, string> req_headers; map<string, string> req_headers;
time_t set_mtime; real_time set_mtime;
RGWObjState *dest_state = NULL; RGWObjState *dest_state = NULL;
const time_t *pmod = mod_ptr; const real_time *pmod = mod_ptr;
obj_time_weight dest_mtime_weight; obj_time_weight dest_mtime_weight;
@ -6439,9 +6444,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
map<string, bufferlist>::iterator iter = src_attrs.find(RGW_ATTR_DELETE_AT); map<string, bufferlist>::iterator iter = src_attrs.find(RGW_ATTR_DELETE_AT);
if (iter != src_attrs.end()) { if (iter != src_attrs.end()) {
try { try {
utime_t da; ::decode(delete_at, iter->second);
::decode(da, iter->second);
delete_at = (time_t)da.sec();
} catch (buffer::error& err) { } catch (buffer::error& err) {
ldout(cct, 0) << "ERROR: failed to decode delete_at field in intra zone copy" << dendl; ldout(cct, 0) << "ERROR: failed to decode delete_at field in intra zone copy" << dendl;
} }
@ -6540,7 +6543,7 @@ int RGWRados::copy_obj_to_remote_dest(RGWObjState *astate,
RGWRados::Object::Read& read_op, RGWRados::Object::Read& read_op,
const rgw_user& user_id, const rgw_user& user_id,
rgw_obj& dest_obj, rgw_obj& dest_obj,
time_t *mtime) real_time *mtime)
{ {
string etag; string etag;
@ -6588,10 +6591,10 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
rgw_obj& src_obj, rgw_obj& src_obj,
RGWBucketInfo& dest_bucket_info, RGWBucketInfo& dest_bucket_info,
RGWBucketInfo& src_bucket_info, RGWBucketInfo& src_bucket_info,
time_t *src_mtime, real_time *src_mtime,
time_t *mtime, real_time *mtime,
const time_t *mod_ptr, const real_time *mod_ptr,
const time_t *unmod_ptr, const real_time *unmod_ptr,
const char *if_match, const char *if_match,
const char *if_nomatch, const char *if_nomatch,
AttrsMod attrs_mod, AttrsMod attrs_mod,
@ -6599,7 +6602,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
map<string, bufferlist>& attrs, map<string, bufferlist>& attrs,
RGWObjCategory category, RGWObjCategory category,
uint64_t olh_epoch, uint64_t olh_epoch,
time_t delete_at, real_time delete_at,
string *version_id, string *version_id,
string *ptag, string *ptag,
string *petag, string *petag,
@ -6713,7 +6716,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */ if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */
return copy_obj_data(obj_ctx, dest_bucket_info, read_op, end, dest_obj, src_obj, return copy_obj_data(obj_ctx, dest_bucket_info, read_op, end, dest_obj, src_obj,
max_chunk_size, mtime, 0, attrs, category, olh_epoch, delete_at, max_chunk_size, mtime, real_time(), attrs, category, olh_epoch, delete_at,
version_id, ptag, petag, err); version_id, ptag, petag, err);
} }
@ -6844,12 +6847,12 @@ int RGWRados::copy_obj_data(RGWObjectCtx& obj_ctx,
rgw_obj& dest_obj, rgw_obj& dest_obj,
rgw_obj& src_obj, rgw_obj& src_obj,
uint64_t max_chunk_size, uint64_t max_chunk_size,
time_t *mtime, real_time *mtime,
time_t set_mtime, real_time set_mtime,
map<string, bufferlist>& attrs, map<string, bufferlist>& attrs,
RGWObjCategory category, RGWObjCategory category,
uint64_t olh_epoch, uint64_t olh_epoch,
time_t delete_at, real_time delete_at,
string *version_id, string *version_id,
string *ptag, string *ptag,
string *petag, string *petag,
@ -7013,7 +7016,7 @@ int RGWRados::set_bucket_owner(rgw_bucket& bucket, ACLOwner& owner)
info.owner = owner.get_id(); info.owner = owner.get_id();
r = put_bucket_instance_info(info, false, 0, &attrs); r = put_bucket_instance_info(info, false, real_time(), &attrs);
if (r < 0) { if (r < 0) {
ldout(cct, 0) << "NOTICE: put_bucket_info on bucket=" << bucket.name << " returned err=" << r << dendl; ldout(cct, 0) << "NOTICE: put_bucket_info on bucket=" << bucket.name << " returned err=" << r << dendl;
return r; return r;
@ -7051,7 +7054,7 @@ int RGWRados::set_buckets_enabled(vector<rgw_bucket>& buckets, bool enabled)
info.flags |= BUCKET_SUSPENDED; info.flags |= BUCKET_SUSPENDED;
} }
r = put_bucket_instance_info(info, false, 0, &attrs); r = put_bucket_instance_info(info, false, real_time(), &attrs);
if (r < 0) { if (r < 0) {
ldout(cct, 0) << "NOTICE: put_bucket_info on bucket=" << bucket.name << " returned err=" << r << ", skipping bucket" << dendl; ldout(cct, 0) << "NOTICE: put_bucket_info on bucket=" << bucket.name << " returned err=" << r << ", skipping bucket" << dendl;
ret = r; ret = r;
@ -7302,7 +7305,7 @@ void RGWRados::cls_obj_check_prefix_exist(ObjectOperation& op, const string& pre
cls_rgw_obj_check_attrs_prefix(op, prefix, fail_if_exist); cls_rgw_obj_check_attrs_prefix(op, prefix, fail_if_exist);
} }
void RGWRados::cls_obj_check_mtime(ObjectOperation& op, const utime_t& mtime, RGWCheckMTimeType type) void RGWRados::cls_obj_check_mtime(ObjectOperation& op, const real_time& mtime, RGWCheckMTimeType type)
{ {
cls_rgw_obj_check_mtime(op, mtime, type); cls_rgw_obj_check_mtime(op, mtime, type);
} }
@ -7347,10 +7350,10 @@ int RGWRados::Object::Delete::delete_obj()
meta.owner = params.obj_owner.get_id().to_str(); meta.owner = params.obj_owner.get_id().to_str();
meta.owner_display_name = params.obj_owner.get_display_name(); meta.owner_display_name = params.obj_owner.get_display_name();
if (params.mtime == 0) { if (real_clock::is_zero(params.mtime)) {
meta.mtime = ceph_clock_now(store->ctx()); meta.mtime = real_clock::now();
} else { } else {
meta.mtime = utime_t(params.mtime, 0); meta.mtime = params.mtime;
} }
int r = store->set_olh(target->get_ctx(), target->get_bucket_info(), marker, true, &meta, params.olh_epoch, params.unmod_since); int r = store->set_olh(target->get_ctx(), target->get_bucket_info(), marker, true, &meta, params.olh_epoch, params.unmod_since);
@ -7402,8 +7405,8 @@ int RGWRados::Object::Delete::delete_obj()
ObjectWriteOperation op; ObjectWriteOperation op;
if (params.unmod_since > 0) { if (!real_clock::is_zero(params.unmod_since)) {
time_t ctime = state->mtime; real_time ctime = state->mtime;
ldout(store->ctx(), 10) << "If-UnModified-Since: " << params.unmod_since << " Last-Modified: " << ctime << dendl; ldout(store->ctx(), 10) << "If-UnModified-Since: " << params.unmod_since << " Last-Modified: " << ctime << dendl;
if (ctime > params.unmod_since) { if (ctime > params.unmod_since) {
@ -7411,13 +7414,13 @@ int RGWRados::Object::Delete::delete_obj()
} }
/* only delete object if mtime is less than or equal to params.unmod_since */ /* only delete object if mtime is less than or equal to params.unmod_since */
store->cls_obj_check_mtime(op, utime_t(params.unmod_since, 0), CLS_RGW_CHECK_TIME_MTIME_LE); store->cls_obj_check_mtime(op, params.unmod_since, CLS_RGW_CHECK_TIME_MTIME_LE);
} }
uint64_t obj_size = state->size; uint64_t obj_size = state->size;
if (!params.expiration_time.is_zero()) { if (!real_clock::is_zero(params.expiration_time)) {
bufferlist bl; bufferlist bl;
utime_t delete_at; real_time delete_at;
if (state->get_attr(RGW_ATTR_DELETE_AT, bl)) { if (state->get_attr(RGW_ATTR_DELETE_AT, bl)) {
try { try {
@ -7504,7 +7507,7 @@ int RGWRados::delete_obj(RGWObjectCtx& obj_ctx,
rgw_obj& obj, rgw_obj& obj,
int versioning_status, int versioning_status,
uint16_t bilog_flags, uint16_t bilog_flags,
const utime_t& expiration_time) const real_time& expiration_time)
{ {
RGWRados::Object del_target(this, bucket_info, obj_ctx, obj); RGWRados::Object del_target(this, bucket_info, obj_ctx, obj);
RGWRados::Object::Delete del_op(&del_target); RGWRados::Object::Delete del_op(&del_target);
@ -7640,7 +7643,7 @@ int RGWRados::get_system_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObj
if (r == -ENOENT) { if (r == -ENOENT) {
s->exists = false; s->exists = false;
s->has_attrs = true; s->has_attrs = true;
s->mtime = 0; s->mtime = real_time();
return 0; return 0;
} }
if (r < 0) if (r < 0)
@ -7690,7 +7693,7 @@ int RGWRados::get_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState *
if (r == -ENOENT) { if (r == -ENOENT) {
s->exists = false; s->exists = false;
s->has_attrs = true; s->has_attrs = true;
s->mtime = 0; s->mtime = real_time();
return 0; return 0;
} }
if (r < 0) if (r < 0)
@ -7823,7 +7826,7 @@ int RGWRados::Object::Stat::stat_async()
if (s->has_attrs) { if (s->has_attrs) {
state.ret = 0; state.ret = 0;
result.size = s->size; result.size = s->size;
result.mtime = s->mtime; result.mtime = ceph::real_clock::to_timespec(s->mtime);
result.attrs = s->attrset; result.attrs = s->attrset;
result.has_manifest = s->has_manifest; result.has_manifest = s->has_manifest;
result.manifest = s->manifest; result.manifest = s->manifest;
@ -7841,7 +7844,7 @@ int RGWRados::Object::Stat::stat_async()
} }
librados::ObjectReadOperation op; librados::ObjectReadOperation op;
op.stat(&result.size, &result.mtime, NULL); op.stat2(&result.size, &result.mtime, NULL);
op.getxattrs(&result.attrs, NULL); op.getxattrs(&result.attrs, NULL);
state.completion = librados::Rados::aio_create_completion(NULL, NULL, NULL); state.completion = librados::Rados::aio_create_completion(NULL, NULL, NULL);
state.io_ctx.locator_set_key(loc); state.io_ctx.locator_set_key(loc);
@ -8151,7 +8154,7 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj,
op.setxattr(name.c_str(), bl); op.setxattr(name.c_str(), bl);
if (name.compare(RGW_ATTR_DELETE_AT) == 0) { if (name.compare(RGW_ATTR_DELETE_AT) == 0) {
utime_t ts; real_time ts;
try { try {
::decode(ts, bl); ::decode(ts, bl);
@ -8205,7 +8208,7 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj,
string content_type(content_type_bl.c_str(), content_type_bl.length()); string content_type(content_type_bl.c_str(), content_type_bl.length());
uint64_t epoch = ref.ioctx.get_last_version(); uint64_t epoch = ref.ioctx.get_last_version();
int64_t poolid = ref.ioctx.get_id(); int64_t poolid = ref.ioctx.get_id();
utime_t mtime = ceph_clock_now(cct); real_time mtime = real_clock::now();
r = index_op.complete(poolid, epoch, state->size, r = index_op.complete(poolid, epoch, state->size,
mtime, etag, content_type, &acl_bl, mtime, etag, content_type, &acl_bl,
RGW_OBJ_CATEGORY_MAIN, NULL); RGW_OBJ_CATEGORY_MAIN, NULL);
@ -8386,7 +8389,7 @@ int RGWRados::stat_system_obj(RGWObjectCtx& obj_ctx,
RGWRados::SystemObject::Read::GetObjState& state, RGWRados::SystemObject::Read::GetObjState& state,
rgw_obj& obj, rgw_obj& obj,
map<string, bufferlist> *attrs, map<string, bufferlist> *attrs,
time_t *lastmod, real_time *lastmod,
uint64_t *obj_size, uint64_t *obj_size,
RGWObjVersionTracker *objv_tracker) RGWObjVersionTracker *objv_tracker)
{ {
@ -8459,7 +8462,7 @@ int RGWRados::Bucket::UpdateIndex::prepare(RGWModifyOp op)
} }
int RGWRados::Bucket::UpdateIndex::complete(int64_t poolid, uint64_t epoch, uint64_t size, int RGWRados::Bucket::UpdateIndex::complete(int64_t poolid, uint64_t epoch, uint64_t size,
utime_t& ut, string& etag, string& content_type, bufferlist *acl_bl, RGWObjCategory category, ceph::real_time& ut, string& etag, string& content_type, bufferlist *acl_bl, RGWObjCategory category,
list<rgw_obj_key> *remove_objs) list<rgw_obj_key> *remove_objs)
{ {
if (blind) { if (blind) {
@ -9269,13 +9272,14 @@ int RGWRados::olh_init_modification_impl(RGWObjState& state, rgw_obj& olh_obj, s
bufferlist bl; bufferlist bl;
RGWOLHPendingInfo pending_info; RGWOLHPendingInfo pending_info;
pending_info.time = ceph_clock_now(cct); pending_info.time = real_clock::now();
::encode(pending_info, bl); ::encode(pending_info, bl);
#define OLH_PENDING_TAG_LEN 32 #define OLH_PENDING_TAG_LEN 32
/* tag will start with current time epoch, this so that entries are sorted by time */ /* tag will start with current time epoch, this so that entries are sorted by time */
char buf[32]; char buf[32];
snprintf(buf, sizeof(buf), "%016llx", (unsigned long long)pending_info.time.sec()); utime_t ut(pending_info.time);
snprintf(buf, sizeof(buf), "%016llx", (unsigned long long)ut.sec());
*op_tag = buf; *op_tag = buf;
string s; string s;
@ -9318,7 +9322,7 @@ int RGWRados::bucket_index_link_olh(RGWObjState& olh_state, rgw_obj& obj_instanc
const string& op_tag, const string& op_tag,
struct rgw_bucket_dir_entry_meta *meta, struct rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, uint64_t olh_epoch,
time_t unmod_since) real_time unmod_since)
{ {
rgw_rados_ref ref; rgw_rados_ref ref;
rgw_bucket bucket; rgw_bucket bucket;
@ -9618,7 +9622,7 @@ int RGWRados::update_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, RGWBucketInf
} }
int RGWRados::set_olh(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, rgw_obj& target_obj, bool delete_marker, rgw_bucket_dir_entry_meta *meta, int RGWRados::set_olh(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, rgw_obj& target_obj, bool delete_marker, rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, time_t unmod_since) uint64_t olh_epoch, real_time unmod_since)
{ {
string op_tag; string op_tag;
@ -9798,7 +9802,7 @@ void RGWRados::check_pending_olh_entries(map<string, bufferlist>& pending_entrie
{ {
map<string, bufferlist>::iterator iter = pending_entries.begin(); map<string, bufferlist>::iterator iter = pending_entries.begin();
utime_t now = ceph_clock_now(cct); real_time now = real_clock::now();
while (iter != pending_entries.end()) { while (iter != pending_entries.end()) {
bufferlist::iterator biter = iter->second.begin(); bufferlist::iterator biter = iter->second.begin();
@ -9814,7 +9818,7 @@ void RGWRados::check_pending_olh_entries(map<string, bufferlist>& pending_entrie
map<string, bufferlist>::iterator cur_iter = iter; map<string, bufferlist>::iterator cur_iter = iter;
++iter; ++iter;
if (now - pending_info.time >= cct->_conf->rgw_olh_pending_timeout_sec) { if (now - pending_info.time >= timespan(cct->_conf->rgw_olh_pending_timeout_sec)) {
(*rm_pending_entries)[cur_iter->first] = cur_iter->second; (*rm_pending_entries)[cur_iter->first] = cur_iter->second;
pending_entries.erase(cur_iter); pending_entries.erase(cur_iter);
} else { } else {
@ -9908,7 +9912,7 @@ int RGWRados::follow_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, rgw_obj& olh
return 0; return 0;
} }
int RGWRados::raw_obj_stat(rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64_t *epoch, int RGWRados::raw_obj_stat(rgw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch,
map<string, bufferlist> *attrs, bufferlist *first_chunk, map<string, bufferlist> *attrs, bufferlist *first_chunk,
RGWObjVersionTracker *objv_tracker) RGWObjVersionTracker *objv_tracker)
{ {
@ -9921,7 +9925,7 @@ int RGWRados::raw_obj_stat(rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64
map<string, bufferlist> unfiltered_attrset; map<string, bufferlist> unfiltered_attrset;
uint64_t size = 0; uint64_t size = 0;
time_t mtime = 0; struct timespec mtime_ts;
ObjectReadOperation op; ObjectReadOperation op;
if (objv_tracker) { if (objv_tracker) {
@ -9931,7 +9935,7 @@ int RGWRados::raw_obj_stat(rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64
op.getxattrs(&unfiltered_attrset, NULL); op.getxattrs(&unfiltered_attrset, NULL);
} }
if (psize || pmtime) { if (psize || pmtime) {
op.stat(&size, &mtime, NULL); op.stat2(&size, &mtime_ts, NULL);
} }
if (first_chunk) { if (first_chunk) {
op.read(0, cct->_conf->rgw_max_chunk_size, first_chunk, NULL); op.read(0, cct->_conf->rgw_max_chunk_size, first_chunk, NULL);
@ -9949,7 +9953,7 @@ int RGWRados::raw_obj_stat(rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64
if (psize) if (psize)
*psize = size; *psize = size;
if (pmtime) if (pmtime)
*pmtime = mtime; *pmtime = ceph::real_clock::from_timespec(mtime_ts);
if (attrs) { if (attrs) {
filter_attrset(unfiltered_attrset, RGW_ATTR_PREFIX, attrs); filter_attrset(unfiltered_attrset, RGW_ATTR_PREFIX, attrs);
} }
@ -10141,7 +10145,7 @@ void RGWRados::get_bucket_instance_obj(rgw_bucket& bucket, rgw_obj& obj)
} }
int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info, int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info,
time_t *pmtime, map<string, bufferlist> *pattrs) real_time *pmtime, map<string, bufferlist> *pattrs)
{ {
int pos = meta_key.find(':'); int pos = meta_key.find(':');
if (pos < 0) { if (pos < 0) {
@ -10153,7 +10157,7 @@ int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta
} }
int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, rgw_bucket& bucket, RGWBucketInfo& info, int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, rgw_bucket& bucket, RGWBucketInfo& info,
time_t *pmtime, map<string, bufferlist> *pattrs) real_time *pmtime, map<string, bufferlist> *pattrs)
{ {
string oid; string oid;
if (bucket.oid.empty()) { if (bucket.oid.empty()) {
@ -10166,7 +10170,7 @@ int RGWRados::get_bucket_instance_info(RGWObjectCtx& obj_ctx, rgw_bucket& bucket
} }
int RGWRados::get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, string& oid, RGWBucketInfo& info, int RGWRados::get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, string& oid, RGWBucketInfo& info,
time_t *pmtime, map<string, bufferlist> *pattrs, real_time *pmtime, map<string, bufferlist> *pattrs,
rgw_cache_entry_info *cache_info) rgw_cache_entry_info *cache_info)
{ {
ldout(cct, 20) << "reading from " << get_zone_params().domain_root << ":" << oid << dendl; ldout(cct, 20) << "reading from " << get_zone_params().domain_root << ":" << oid << dendl;
@ -10194,7 +10198,7 @@ int RGWRados::get_bucket_entrypoint_info(RGWObjectCtx& obj_ctx,
const string& bucket_name, const string& bucket_name,
RGWBucketEntryPoint& entry_point, RGWBucketEntryPoint& entry_point,
RGWObjVersionTracker *objv_tracker, RGWObjVersionTracker *objv_tracker,
time_t *pmtime, real_time *pmtime,
map<string, bufferlist> *pattrs, map<string, bufferlist> *pattrs,
rgw_cache_entry_info *cache_info) rgw_cache_entry_info *cache_info)
{ {
@ -10222,7 +10226,7 @@ int RGWRados::convert_old_bucket_info(RGWObjectCtx& obj_ctx,
const string& bucket_name) const string& bucket_name)
{ {
RGWBucketEntryPoint entry_point; RGWBucketEntryPoint entry_point;
time_t ep_mtime; real_time ep_mtime;
RGWObjVersionTracker ot; RGWObjVersionTracker ot;
map<string, bufferlist> attrs; map<string, bufferlist> attrs;
RGWBucketInfo info; RGWBucketInfo info;
@ -10256,7 +10260,7 @@ int RGWRados::convert_old_bucket_info(RGWObjectCtx& obj_ctx,
int RGWRados::get_bucket_info(RGWObjectCtx& obj_ctx, int RGWRados::get_bucket_info(RGWObjectCtx& obj_ctx,
const string& tenant, const string& bucket_name, RGWBucketInfo& info, const string& tenant, const string& bucket_name, RGWBucketInfo& info,
time_t *pmtime, map<string, bufferlist> *pattrs) real_time *pmtime, map<string, bufferlist> *pattrs)
{ {
bucket_info_entry e; bucket_info_entry e;
string bucket_entry; string bucket_entry;
@ -10274,7 +10278,7 @@ int RGWRados::get_bucket_info(RGWObjectCtx& obj_ctx,
bufferlist bl; bufferlist bl;
RGWBucketEntryPoint entry_point; RGWBucketEntryPoint entry_point;
time_t ep_mtime; real_time ep_mtime;
RGWObjVersionTracker ot; RGWObjVersionTracker ot;
rgw_cache_entry_info entry_cache_info; rgw_cache_entry_info entry_cache_info;
int ret = get_bucket_entrypoint_info(obj_ctx, tenant, bucket_name, entry_point, &ot, &ep_mtime, pattrs, &entry_cache_info); int ret = get_bucket_entrypoint_info(obj_ctx, tenant, bucket_name, entry_point, &ot, &ep_mtime, pattrs, &entry_cache_info);
@ -10340,7 +10344,7 @@ int RGWRados::get_bucket_info(RGWObjectCtx& obj_ctx,
} }
int RGWRados::put_bucket_entrypoint_info(const string& tenant_name, const string& bucket_name, RGWBucketEntryPoint& entry_point, int RGWRados::put_bucket_entrypoint_info(const string& tenant_name, const string& bucket_name, RGWBucketEntryPoint& entry_point,
bool exclusive, RGWObjVersionTracker& objv_tracker, time_t mtime, bool exclusive, RGWObjVersionTracker& objv_tracker, real_time mtime,
map<string, bufferlist> *pattrs) map<string, bufferlist> *pattrs)
{ {
bufferlist epbl; bufferlist epbl;
@ -10351,7 +10355,7 @@ int RGWRados::put_bucket_entrypoint_info(const string& tenant_name, const string
} }
int RGWRados::put_bucket_instance_info(RGWBucketInfo& info, bool exclusive, int RGWRados::put_bucket_instance_info(RGWBucketInfo& info, bool exclusive,
time_t mtime, map<string, bufferlist> *pattrs) real_time mtime, map<string, bufferlist> *pattrs)
{ {
info.has_instance_obj = true; info.has_instance_obj = true;
bufferlist bl; bufferlist bl;
@ -10363,7 +10367,7 @@ int RGWRados::put_bucket_instance_info(RGWBucketInfo& info, bool exclusive,
return rgw_bucket_instance_store_info(this, key, bl, exclusive, pattrs, &info.objv_tracker, mtime); return rgw_bucket_instance_store_info(this, key, bl, exclusive, pattrs, &info.objv_tracker, mtime);
} }
int RGWRados::put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, time_t mtime, obj_version *pep_objv, int RGWRados::put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, real_time mtime, obj_version *pep_objv,
map<string, bufferlist> *pattrs, bool create_entry_point) map<string, bufferlist> *pattrs, bool create_entry_point)
{ {
bufferlist bl; bufferlist bl;
@ -10888,7 +10892,7 @@ int RGWRados::cls_obj_complete_op(BucketShard& bs, RGWModifyOp op, string& tag,
rgw_bucket_dir_entry_meta dir_meta; rgw_bucket_dir_entry_meta dir_meta;
dir_meta.size = ent.size; dir_meta.size = ent.size;
dir_meta.accounted_size = ent.size; dir_meta.accounted_size = ent.size;
dir_meta.mtime = utime_t(ent.mtime, 0); dir_meta.mtime = ent.mtime;
dir_meta.etag = ent.etag; dir_meta.etag = ent.etag;
dir_meta.owner = ent.owner.to_str(); dir_meta.owner = ent.owner.to_str();
dir_meta.owner_display_name = ent.owner_display_name; dir_meta.owner_display_name = ent.owner_display_name;
@ -11202,7 +11206,7 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx,
ACLOwner owner; ACLOwner owner;
object.size = astate->size; object.size = astate->size;
object.mtime = utime_t(astate->mtime, 0); object.mtime = astate->mtime;
map<string, bufferlist>::iterator iter = astate->attrset.find(RGW_ATTR_ETAG); map<string, bufferlist>::iterator iter = astate->attrset.find(RGW_ATTR_ETAG);
if (iter != astate->attrset.end()) { if (iter != astate->attrset.end()) {
@ -11245,7 +11249,7 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx,
list_state.ver.pool = io_ctx.get_id(); list_state.ver.pool = io_ctx.get_id();
list_state.ver.epoch = astate->epoch; list_state.ver.epoch = astate->epoch;
list_state.meta.size = object.size; list_state.meta.size = object.size;
list_state.meta.mtime.set_from_double(double(object.mtime)); list_state.meta.mtime = object.mtime;
list_state.meta.category = main_category; list_state.meta.category = main_category;
list_state.meta.etag = etag; list_state.meta.etag = etag;
list_state.meta.content_type = content_type; list_state.meta.content_type = content_type;
@ -11831,17 +11835,17 @@ RGWOpStateSingleOp::RGWOpStateSingleOp(RGWRados *store, const string& cid, const
} }
int RGWOpStateSingleOp::set_state(RGWOpState::OpState state) { int RGWOpStateSingleOp::set_state(RGWOpState::OpState state) {
last_update = ceph_clock_now(cct); last_update = real_clock::now();
cur_state = state; cur_state = state;
return os.set_state(client_id, op_id, object, state); return os.set_state(client_id, op_id, object, state);
} }
int RGWOpStateSingleOp::renew_state() { int RGWOpStateSingleOp::renew_state() {
utime_t now = ceph_clock_now(cct); real_time now = real_clock::now();
int rate_limit_sec = cct->_conf->rgw_opstate_ratelimit_sec; int rate_limit_sec = cct->_conf->rgw_opstate_ratelimit_sec;
if (rate_limit_sec && now - last_update < rate_limit_sec) { if (rate_limit_sec && now - last_update < timespan(rate_limit_sec)) {
return 0; return 0;
} }

View File

@ -8,6 +8,7 @@
#include "include/Context.h" #include "include/Context.h"
#include "common/RefCountedObj.h" #include "common/RefCountedObj.h"
#include "common/RWLock.h" #include "common/RWLock.h"
#include "common/ceph_time.h"
#include "rgw_common.h" #include "rgw_common.h"
#include "cls/rgw/cls_rgw_types.h" #include "cls/rgw/cls_rgw_types.h"
#include "cls/version/cls_version_types.h" #include "cls/version/cls_version_types.h"
@ -92,7 +93,7 @@ struct RGWOLHInfo {
WRITE_CLASS_ENCODER(RGWOLHInfo) WRITE_CLASS_ENCODER(RGWOLHInfo)
struct RGWOLHPendingInfo { struct RGWOLHPendingInfo {
utime_t time; ceph::real_time time;
RGWOLHPendingInfo() {} RGWOLHPendingInfo() {}
@ -113,9 +114,9 @@ struct RGWOLHPendingInfo {
WRITE_CLASS_ENCODER(RGWOLHPendingInfo) WRITE_CLASS_ENCODER(RGWOLHPendingInfo)
struct RGWUsageBatch { struct RGWUsageBatch {
map<utime_t, rgw_usage_log_entry> m; map<ceph::real_time, rgw_usage_log_entry> m;
void insert(utime_t& t, rgw_usage_log_entry& entry, bool *account) { void insert(ceph::real_time& t, rgw_usage_log_entry& entry, bool *account) {
bool exists = m.find(t) != m.end(); bool exists = m.find(t) != m.end();
*account = !exists; *account = !exists;
m[t].aggregate(entry); m[t].aggregate(entry);
@ -579,7 +580,7 @@ struct RGWUploadPartInfo {
uint32_t num; uint32_t num;
uint64_t size; uint64_t size;
string etag; string etag;
utime_t modified; ceph::real_time modified;
RGWObjManifest manifest; RGWObjManifest manifest;
RGWUploadPartInfo() : num(0), size(0) {} RGWUploadPartInfo() : num(0), size(0) {}
@ -614,7 +615,7 @@ struct RGWObjState {
bool has_attrs; bool has_attrs;
bool exists; bool exists;
uint64_t size; uint64_t size;
time_t mtime; ceph::real_time mtime;
uint64_t epoch; uint64_t epoch;
bufferlist obj_tag; bufferlist obj_tag;
string write_tag; string write_tag;
@ -637,7 +638,7 @@ struct RGWObjState {
map<string, bufferlist> attrset; map<string, bufferlist> attrset;
RGWObjState() : is_atomic(false), has_attrs(0), exists(false), RGWObjState() : is_atomic(false), has_attrs(0), exists(false),
size(0), mtime(0), epoch(0), fake_tag(false), has_manifest(false), size(0), epoch(0), fake_tag(false), has_manifest(false),
has_data(false), prefetch_data(false), keep_tail(false), is_olh(false), has_data(false), prefetch_data(false), keep_tail(false), is_olh(false),
pg_ver(0), zone_short_id(0) {} pg_ver(0), zone_short_id(0) {}
RGWObjState(const RGWObjState& rhs) : obj (rhs.obj) { RGWObjState(const RGWObjState& rhs) : obj (rhs.obj) {
@ -1264,7 +1265,7 @@ struct objexp_hint_entry {
string bucket_name; string bucket_name;
string bucket_id; string bucket_id;
rgw_obj_key obj_key; rgw_obj_key obj_key;
utime_t exp_time; ceph::real_time exp_time;
void encode(bufferlist& bl) const { void encode(bufferlist& bl) const {
ENCODE_START(2, 1, bl); ENCODE_START(2, 1, bl);
@ -1609,7 +1610,7 @@ class RGWOpStateSingleOp
CephContext *cct; CephContext *cct;
RGWOpState::OpState cur_state; RGWOpState::OpState cur_state;
utime_t last_update; ceph::real_time last_update;
public: public:
RGWOpStateSingleOp(RGWRados *store, const string& cid, const string& oid, const string& obj); RGWOpStateSingleOp(RGWRados *store, const string& cid, const string& oid, const string& obj);
@ -1785,7 +1786,7 @@ class RGWRados
void remove_rgw_head_obj(librados::ObjectWriteOperation& op); void remove_rgw_head_obj(librados::ObjectWriteOperation& op);
void cls_obj_check_prefix_exist(librados::ObjectOperation& op, const string& prefix, bool fail_if_exist); void cls_obj_check_prefix_exist(librados::ObjectOperation& op, const string& prefix, bool fail_if_exist);
void cls_obj_check_mtime(librados::ObjectOperation& op, const utime_t& mtime, RGWCheckMTimeType type); void cls_obj_check_mtime(librados::ObjectOperation& op, const real_time& mtime, RGWCheckMTimeType type);
protected: protected:
CephContext *cct; CephContext *cct;
@ -2037,7 +2038,7 @@ public:
RGWBucketInfo& bucket_info, RGWBucketInfo& bucket_info,
obj_version *pobjv, obj_version *pobjv,
obj_version *pep_objv, obj_version *pep_objv,
time_t creation_time, ceph::real_time creation_time,
rgw_bucket *master_bucket, rgw_bucket *master_bucket,
bool exclusive = true); bool exclusive = true);
virtual int add_bucket_placement(std::string& new_pool); virtual int add_bucket_placement(std::string& new_pool);
@ -2078,7 +2079,7 @@ public:
} state; } state;
struct StatParams { struct StatParams {
time_t *lastmod; ceph::real_time *lastmod;
uint64_t *obj_size; uint64_t *obj_size;
map<string, bufferlist> *attrs; map<string, bufferlist> *attrs;
struct rgw_err *perr; struct rgw_err *perr;
@ -2174,8 +2175,8 @@ public:
} state; } state;
struct ConditionParams { struct ConditionParams {
const time_t *mod_ptr; const ceph::real_time *mod_ptr;
const time_t *unmod_ptr; const ceph::real_time *unmod_ptr;
uint32_t mod_zone_id; uint32_t mod_zone_id;
uint64_t mod_pg_ver; uint64_t mod_pg_ver;
const char *if_match; const char *if_match;
@ -2187,7 +2188,7 @@ public:
} conds; } conds;
struct Params { struct Params {
time_t *lastmod; ceph::real_time *lastmod;
uint64_t *read_size; uint64_t *read_size;
uint64_t *obj_size; uint64_t *obj_size;
map<string, bufferlist> *attrs; map<string, bufferlist> *attrs;
@ -2208,25 +2209,25 @@ public:
RGWRados::Object *target; RGWRados::Object *target;
struct MetaParams { struct MetaParams {
time_t *mtime; ceph::real_time *mtime;
map<std::string, bufferlist>* rmattrs; map<std::string, bufferlist>* rmattrs;
const bufferlist *data; const bufferlist *data;
RGWObjManifest *manifest; RGWObjManifest *manifest;
const string *ptag; const string *ptag;
list<rgw_obj_key> *remove_objs; list<rgw_obj_key> *remove_objs;
time_t set_mtime; ceph::real_time set_mtime;
rgw_user owner; rgw_user owner;
RGWObjCategory category; RGWObjCategory category;
int flags; int flags;
const char *if_match; const char *if_match;
const char *if_nomatch; const char *if_nomatch;
uint64_t olh_epoch; uint64_t olh_epoch;
time_t delete_at; ceph::real_time delete_at;
bool canceled; bool canceled;
MetaParams() : mtime(NULL), rmattrs(NULL), data(NULL), manifest(NULL), ptag(NULL), MetaParams() : mtime(NULL), rmattrs(NULL), data(NULL), manifest(NULL), ptag(NULL),
remove_objs(NULL), set_mtime(0), category(RGW_OBJ_CATEGORY_MAIN), flags(0), remove_objs(NULL), category(RGW_OBJ_CATEGORY_MAIN), flags(0),
if_match(NULL), if_nomatch(NULL), olh_epoch(0), delete_at(0), canceled(false) {} if_match(NULL), if_nomatch(NULL), olh_epoch(0), canceled(false) {}
} meta; } meta;
explicit Write(RGWRados::Object *_target) : target(_target) {} explicit Write(RGWRados::Object *_target) : target(_target) {}
@ -2246,11 +2247,11 @@ public:
string marker_version_id; string marker_version_id;
uint32_t bilog_flags; uint32_t bilog_flags;
list<rgw_obj_key> *remove_objs; list<rgw_obj_key> *remove_objs;
utime_t expiration_time; ceph::real_time expiration_time;
time_t unmod_since; ceph::real_time unmod_since;
time_t mtime; /* for setting delete marker mtime */ ceph::real_time mtime; /* for setting delete marker mtime */
DeleteParams() : versioning_status(0), olh_epoch(0), bilog_flags(0), remove_objs(NULL), unmod_since(0), mtime(0) {} DeleteParams() : versioning_status(0), olh_epoch(0), bilog_flags(0), remove_objs(NULL) {}
} params; } params;
struct DeleteResult { struct DeleteResult {
@ -2273,10 +2274,10 @@ public:
RGWObjManifest manifest; RGWObjManifest manifest;
bool has_manifest; bool has_manifest;
uint64_t size; uint64_t size;
time_t mtime; struct timespec mtime;
map<string, bufferlist> attrs; map<string, bufferlist> attrs;
Result() : has_manifest(false), size(0), mtime(0) {} Result() : has_manifest(false), size(0) {}
} result; } result;
struct State { struct State {
@ -2350,7 +2351,7 @@ public:
int prepare(RGWModifyOp); int prepare(RGWModifyOp);
int complete(int64_t poolid, uint64_t epoch, uint64_t size, int complete(int64_t poolid, uint64_t epoch, uint64_t size,
utime_t& ut, string& etag, string& content_type, ceph::real_time& ut, string& etag, string& content_type,
bufferlist *acl_bl, RGWObjCategory category, bufferlist *acl_bl, RGWObjCategory category,
list<rgw_obj_key> *remove_objs); list<rgw_obj_key> *remove_objs);
int complete_del(int64_t poolid, uint64_t epoch, int complete_del(int64_t poolid, uint64_t epoch,
@ -2386,11 +2387,11 @@ public:
}; };
/** Write/overwrite an object to the bucket storage. */ /** Write/overwrite an object to the bucket storage. */
virtual int put_system_obj_impl(rgw_obj& obj, uint64_t size, time_t *mtime, virtual int put_system_obj_impl(rgw_obj& obj, uint64_t size, ceph::real_time *mtime,
map<std::string, bufferlist>& attrs, int flags, map<std::string, bufferlist>& attrs, int flags,
bufferlist& data, bufferlist& data,
RGWObjVersionTracker *objv_tracker, RGWObjVersionTracker *objv_tracker,
time_t set_mtime /* 0 for don't set */); ceph::real_time set_mtime /* 0 for don't set */);
virtual int put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl, virtual int put_system_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl,
off_t ofs, bool exclusive); off_t ofs, bool exclusive);
@ -2400,8 +2401,8 @@ public:
off_t ofs, bool exclusive, void **handle); off_t ofs, bool exclusive, void **handle);
int put_system_obj(void *ctx, rgw_obj& obj, const char *data, size_t len, bool exclusive, int put_system_obj(void *ctx, rgw_obj& obj, const char *data, size_t len, bool exclusive,
time_t *mtime, map<std::string, bufferlist>& attrs, RGWObjVersionTracker *objv_tracker, ceph::real_time *mtime, map<std::string, bufferlist>& attrs, RGWObjVersionTracker *objv_tracker,
time_t set_mtime) { ceph::real_time set_mtime) {
bufferlist bl; bufferlist bl;
bl.append(data, len); bl.append(data, len);
int flags = PUT_OBJ_CREATE; int flags = PUT_OBJ_CREATE;
@ -2430,10 +2431,10 @@ public:
rgw_obj& src_obj, rgw_obj& src_obj,
RGWBucketInfo& dest_bucket_info, RGWBucketInfo& dest_bucket_info,
RGWBucketInfo& src_bucket_info, RGWBucketInfo& src_bucket_info,
time_t *src_mtime, ceph::real_time *src_mtime,
time_t *mtime, ceph::real_time *mtime,
const time_t *mod_ptr, const ceph::real_time *mod_ptr,
const time_t *unmod_ptr, const ceph::real_time *unmod_ptr,
const char *if_match, const char *if_match,
const char *if_nomatch, const char *if_nomatch,
AttrsMod attrs_mod, AttrsMod attrs_mod,
@ -2441,7 +2442,7 @@ public:
map<string, bufferlist>& attrs, map<string, bufferlist>& attrs,
RGWObjCategory category, RGWObjCategory category,
uint64_t olh_epoch, uint64_t olh_epoch,
time_t delete_at, ceph::real_time delete_at,
string *version_id, string *version_id,
string *ptag, string *ptag,
string *petag, string *petag,
@ -2455,7 +2456,7 @@ public:
RGWRados::Object::Read& read_op, RGWRados::Object::Read& read_op,
const rgw_user& user_id, const rgw_user& user_id,
rgw_obj& dest_obj, rgw_obj& dest_obj,
time_t *mtime); ceph::real_time *mtime);
/** /**
* Copy an object. * Copy an object.
* dest_obj: the object to copy into * dest_obj: the object to copy into
@ -2481,10 +2482,10 @@ public:
rgw_obj& src_obj, rgw_obj& src_obj,
RGWBucketInfo& dest_bucket_info, RGWBucketInfo& dest_bucket_info,
RGWBucketInfo& src_bucket_info, RGWBucketInfo& src_bucket_info,
time_t *src_mtime, ceph::real_time *src_mtime,
time_t *mtime, ceph::real_time *mtime,
const time_t *mod_ptr, const ceph::real_time *mod_ptr,
const time_t *unmod_ptr, const ceph::real_time *unmod_ptr,
const char *if_match, const char *if_match,
const char *if_nomatch, const char *if_nomatch,
AttrsMod attrs_mod, AttrsMod attrs_mod,
@ -2492,7 +2493,7 @@ public:
map<std::string, bufferlist>& attrs, map<std::string, bufferlist>& attrs,
RGWObjCategory category, RGWObjCategory category,
uint64_t olh_epoch, uint64_t olh_epoch,
time_t delete_at, ceph::real_time delete_at,
string *version_id, string *version_id,
string *ptag, string *ptag,
string *petag, string *petag,
@ -2506,12 +2507,12 @@ public:
rgw_obj& dest_obj, rgw_obj& dest_obj,
rgw_obj& src_obj, rgw_obj& src_obj,
uint64_t max_chunk_size, uint64_t max_chunk_size,
time_t *mtime, ceph::real_time *mtime,
time_t set_mtime, ceph::real_time set_mtime,
map<string, bufferlist>& attrs, map<string, bufferlist>& attrs,
RGWObjCategory category, RGWObjCategory category,
uint64_t olh_epoch, uint64_t olh_epoch,
time_t delete_at, ceph::real_time delete_at,
string *version_id, string *version_id,
string *ptag, string *ptag,
string *petag, string *petag,
@ -2543,7 +2544,7 @@ public:
rgw_obj& src_obj, rgw_obj& src_obj,
int versioning_status, int versioning_status,
uint16_t bilog_flags = 0, uint16_t bilog_flags = 0,
const utime_t& expiration_time = utime_t()); const ceph::real_time& expiration_time = ceph::real_time());
/* Delete a system object */ /* Delete a system object */
virtual int delete_system_obj(rgw_obj& src_obj, RGWObjVersionTracker *objv_tracker = NULL); virtual int delete_system_obj(rgw_obj& src_obj, RGWObjVersionTracker *objv_tracker = NULL);
@ -2592,7 +2593,7 @@ public:
RGWRados::SystemObject::Read::GetObjState& state, RGWRados::SystemObject::Read::GetObjState& state,
rgw_obj& obj, rgw_obj& obj,
map<string, bufferlist> *attrs, map<string, bufferlist> *attrs,
time_t *lastmod, ceph::real_time *lastmod,
uint64_t *obj_size, uint64_t *obj_size,
RGWObjVersionTracker *objv_tracker); RGWObjVersionTracker *objv_tracker);
@ -2624,7 +2625,7 @@ public:
* a simple object read without keeping state * a simple object read without keeping state
*/ */
virtual int raw_obj_stat(rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64_t *epoch, virtual int raw_obj_stat(rgw_obj& obj, uint64_t *psize, ceph::real_time *pmtime, uint64_t *epoch,
map<string, bufferlist> *attrs, bufferlist *first_chunk, map<string, bufferlist> *attrs, bufferlist *first_chunk,
RGWObjVersionTracker *objv_tracker); RGWObjVersionTracker *objv_tracker);
@ -2637,7 +2638,7 @@ public:
int bucket_index_link_olh(RGWObjState& olh_state, rgw_obj& obj_instance, bool delete_marker, int bucket_index_link_olh(RGWObjState& olh_state, rgw_obj& obj_instance, bool delete_marker,
const string& op_tag, struct rgw_bucket_dir_entry_meta *meta, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, uint64_t olh_epoch,
time_t unmod_since); ceph::real_time unmod_since);
int bucket_index_unlink_instance(rgw_obj& obj_instance, const string& op_tag, uint64_t olh_epoch); int bucket_index_unlink_instance(rgw_obj& obj_instance, const string& op_tag, uint64_t olh_epoch);
int bucket_index_read_olh_log(RGWObjState& state, rgw_obj& obj_instance, uint64_t ver_marker, int bucket_index_read_olh_log(RGWObjState& state, rgw_obj& obj_instance, uint64_t ver_marker,
map<uint64_t, vector<rgw_bucket_olh_log_entry> > *log, bool *is_truncated); map<uint64_t, vector<rgw_bucket_olh_log_entry> > *log, bool *is_truncated);
@ -2648,7 +2649,7 @@ public:
uint64_t *plast_ver); uint64_t *plast_ver);
int update_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, RGWBucketInfo& bucket_info, rgw_obj& obj); int update_olh(RGWObjectCtx& obj_ctx, RGWObjState *state, RGWBucketInfo& bucket_info, rgw_obj& obj);
int set_olh(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, rgw_obj& target_obj, bool delete_marker, rgw_bucket_dir_entry_meta *meta, int set_olh(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, rgw_obj& target_obj, bool delete_marker, rgw_bucket_dir_entry_meta *meta,
uint64_t olh_epoch, time_t unmod_since); uint64_t olh_epoch, ceph::real_time unmod_since);
int unlink_obj_instance(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, rgw_obj& target_obj, int unlink_obj_instance(RGWObjectCtx& obj_ctx, RGWBucketInfo& bucket_info, rgw_obj& target_obj,
uint64_t olh_epoch); uint64_t olh_epoch);
@ -2703,15 +2704,15 @@ public:
void get_bucket_meta_oid(rgw_bucket& bucket, string& oid); void get_bucket_meta_oid(rgw_bucket& bucket, string& oid);
int put_bucket_entrypoint_info(const string& tenant_name, const string& bucket_name, RGWBucketEntryPoint& entry_point, int put_bucket_entrypoint_info(const string& tenant_name, const string& bucket_name, RGWBucketEntryPoint& entry_point,
bool exclusive, RGWObjVersionTracker& objv_tracker, time_t mtime, bool exclusive, RGWObjVersionTracker& objv_tracker, ceph::real_time mtime,
map<string, bufferlist> *pattrs); map<string, bufferlist> *pattrs);
int put_bucket_instance_info(RGWBucketInfo& info, bool exclusive, time_t mtime, map<string, bufferlist> *pattrs); int put_bucket_instance_info(RGWBucketInfo& info, bool exclusive, ceph::real_time mtime, map<string, bufferlist> *pattrs);
int get_bucket_entrypoint_info(RGWObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name, int get_bucket_entrypoint_info(RGWObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name,
RGWBucketEntryPoint& entry_point, RGWObjVersionTracker *objv_tracker, RGWBucketEntryPoint& entry_point, RGWObjVersionTracker *objv_tracker,
time_t *pmtime, map<string, bufferlist> *pattrs, rgw_cache_entry_info *cache_info = NULL); ceph::real_time *pmtime, map<string, bufferlist> *pattrs, rgw_cache_entry_info *cache_info = NULL);
int get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs); int get_bucket_instance_info(RGWObjectCtx& obj_ctx, const string& meta_key, RGWBucketInfo& info, ceph::real_time *pmtime, map<string, bufferlist> *pattrs);
int get_bucket_instance_info(RGWObjectCtx& obj_ctx, rgw_bucket& bucket, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs); int get_bucket_instance_info(RGWObjectCtx& obj_ctx, rgw_bucket& bucket, RGWBucketInfo& info, ceph::real_time *pmtime, map<string, bufferlist> *pattrs);
int get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, string& oid, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs, int get_bucket_instance_from_oid(RGWObjectCtx& obj_ctx, string& oid, RGWBucketInfo& info, ceph::real_time *pmtime, map<string, bufferlist> *pattrs,
rgw_cache_entry_info *cache_info = NULL); rgw_cache_entry_info *cache_info = NULL);
int convert_old_bucket_info(RGWObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name); int convert_old_bucket_info(RGWObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name);
@ -2719,8 +2720,8 @@ public:
virtual int get_bucket_info(RGWObjectCtx& obj_ctx, virtual int get_bucket_info(RGWObjectCtx& obj_ctx,
const string& tenant_name, const string& bucket_name, const string& tenant_name, const string& bucket_name,
RGWBucketInfo& info, RGWBucketInfo& info,
time_t *pmtime, map<string, bufferlist> *pattrs = NULL); ceph::real_time *pmtime, map<string, bufferlist> *pattrs = NULL);
virtual int put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, time_t mtime, obj_version *pep_objv, virtual int put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, ceph::real_time mtime, obj_version *pep_objv,
map<string, bufferlist> *pattrs, bool create_entry_point); map<string, bufferlist> *pattrs, bool create_entry_point);
int cls_rgw_init_index(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid); int cls_rgw_init_index(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid);
@ -2757,31 +2758,31 @@ public:
void shard_name(const string& prefix, unsigned max_shards, const string& key, string& name, int *shard_id); void shard_name(const string& prefix, unsigned max_shards, const string& key, string& name, int *shard_id);
void shard_name(const string& prefix, unsigned max_shards, const string& section, const string& key, string& name); void shard_name(const string& prefix, unsigned max_shards, const string& section, const string& key, string& name);
void shard_name(const string& prefix, unsigned shard_id, string& name); void shard_name(const string& prefix, unsigned shard_id, string& name);
void time_log_prepare_entry(cls_log_entry& entry, const utime_t& ut, const string& section, const string& key, bufferlist& bl); void time_log_prepare_entry(cls_log_entry& entry, const ceph::real_time& ut, const string& section, const string& key, bufferlist& bl);
int time_log_add_init(librados::IoCtx& io_ctx); int time_log_add_init(librados::IoCtx& io_ctx);
int time_log_add(const string& oid, list<cls_log_entry>& entries, int time_log_add(const string& oid, list<cls_log_entry>& entries,
librados::AioCompletion *completion, bool monotonic_inc = true); librados::AioCompletion *completion, bool monotonic_inc = true);
int time_log_add(const string& oid, const utime_t& ut, const string& section, const string& key, bufferlist& bl); int time_log_add(const string& oid, const ceph::real_time& ut, const string& section, const string& key, bufferlist& bl);
int time_log_list(const string& oid, utime_t& start_time, utime_t& end_time, int time_log_list(const string& oid, const ceph::real_time& start_time, const ceph::real_time& end_time,
int max_entries, list<cls_log_entry>& entries, int max_entries, list<cls_log_entry>& entries,
const string& marker, string *out_marker, bool *truncated); const string& marker, string *out_marker, bool *truncated);
int time_log_info(const string& oid, cls_log_header *header); int time_log_info(const string& oid, cls_log_header *header);
int time_log_info_async(librados::IoCtx& io_ctx, const string& oid, cls_log_header *header, librados::AioCompletion *completion); int time_log_info_async(librados::IoCtx& io_ctx, const string& oid, cls_log_header *header, librados::AioCompletion *completion);
int time_log_trim(const string& oid, const utime_t& start_time, const utime_t& end_time, int time_log_trim(const string& oid, const ceph::real_time& start_time, const ceph::real_time& end_time,
const string& from_marker, const string& to_marker); const string& from_marker, const string& to_marker);
string objexp_hint_get_shardname(int shard_num); string objexp_hint_get_shardname(int shard_num);
int objexp_key_shard(const rgw_obj_key& key); int objexp_key_shard(const rgw_obj_key& key);
void objexp_get_shard(int shard_num, void objexp_get_shard(int shard_num,
string& shard); /* out */ string& shard); /* out */
int objexp_hint_add(const utime_t& delete_at, int objexp_hint_add(const ceph::real_time& delete_at,
const string& tenant_name, const string& tenant_name,
const string& bucket_name, const string& bucket_name,
const string& bucket_id, const string& bucket_id,
const rgw_obj_key& obj_key); const rgw_obj_key& obj_key);
int objexp_hint_list(const string& oid, int objexp_hint_list(const string& oid,
const utime_t& start_time, const ceph::real_time& start_time,
const utime_t& end_time, const ceph::real_time& end_time,
const int max_entries, const int max_entries,
const string& marker, const string& marker,
list<cls_timeindex_entry>& entries, /* out */ list<cls_timeindex_entry>& entries, /* out */
@ -2790,12 +2791,12 @@ public:
int objexp_hint_parse(cls_timeindex_entry &ti_entry, int objexp_hint_parse(cls_timeindex_entry &ti_entry,
objexp_hint_entry& hint_entry); /* out */ objexp_hint_entry& hint_entry); /* out */
int objexp_hint_trim(const string& oid, int objexp_hint_trim(const string& oid,
const utime_t& start_time, const ceph::real_time& start_time,
const utime_t& end_time, const ceph::real_time& end_time,
const string& from_marker = std::string(), const string& from_marker = std::string(),
const string& to_marker = std::string()); const string& to_marker = std::string());
int lock_exclusive(rgw_bucket& pool, const string& oid, utime_t& duration, string& zone_id, string& owner_id); int lock_exclusive(rgw_bucket& pool, const string& oid, ceph::timespan& duration, string& zone_id, string& owner_id);
int unlock(rgw_bucket& pool, const string& oid, string& zone_id, string& owner_id); int unlock(rgw_bucket& pool, const string& oid, string& zone_id, string& owner_id);
void update_gc_chain(rgw_obj& head_obj, RGWObjManifest& manifest, cls_rgw_obj_chain *chain); void update_gc_chain(rgw_obj& head_obj, RGWObjManifest& manifest, cls_rgw_obj_chain *chain);
@ -3039,8 +3040,8 @@ protected:
RGWBucketInfo bucket_info; RGWBucketInfo bucket_info;
bool canceled; bool canceled;
virtual int do_complete(string& etag, time_t *mtime, time_t set_mtime, virtual int do_complete(string& etag, ceph::real_time *mtime, ceph::real_time set_mtime,
map<string, bufferlist>& attrs, time_t delete_at, map<string, bufferlist>& attrs, ceph::real_time delete_at,
const char *if_match = NULL, const char *if_nomatch = NULL) = 0; const char *if_match = NULL, const char *if_nomatch = NULL) = 0;
public: public:
@ -3055,8 +3056,8 @@ public:
virtual void complete_hash(MD5 *hash) { virtual void complete_hash(MD5 *hash) {
assert(0); assert(0);
} }
virtual int complete(string& etag, time_t *mtime, time_t set_mtime, virtual int complete(string& etag, ceph::real_time *mtime, ceph::real_time set_mtime,
map<string, bufferlist>& attrs, time_t delete_at, map<string, bufferlist>& attrs, ceph::real_time delete_at,
const char *if_match = NULL, const char *if_nomatch = NULL); const char *if_match = NULL, const char *if_nomatch = NULL);
CephContext *ctx(); CephContext *ctx();
@ -3128,8 +3129,8 @@ protected:
RGWObjManifest::generator manifest_gen; RGWObjManifest::generator manifest_gen;
int write_data(bufferlist& bl, off_t ofs, void **phandle, bool exclusive); int write_data(bufferlist& bl, off_t ofs, void **phandle, bool exclusive);
virtual int do_complete(string& etag, time_t *mtime, time_t set_mtime, virtual int do_complete(string& etag, ceph::real_time *mtime, ceph::real_time set_mtime,
map<string, bufferlist>& attrs, time_t delete_at, map<string, bufferlist>& attrs, ceph::real_time delete_at,
const char *if_match = NULL, const char *if_nomatch = NULL); const char *if_match = NULL, const char *if_nomatch = NULL);
int prepare_next_part(off_t ofs); int prepare_next_part(off_t ofs);

View File

@ -468,12 +468,14 @@ void dump_redirect(struct req_state *s, const string& redirect)
STREAM_IO(s)->print("Location: %s\r\n", redirect.c_str()); STREAM_IO(s)->print("Location: %s\r\n", redirect.c_str());
} }
void dump_time_header(struct req_state *s, const char *name, time_t t) void dump_time_header(struct req_state *s, const char *name, real_time t)
{ {
utime_t ut(t);
time_t secs = (time_t)ut.sec();
char timestr[TIME_BUF_SIZE]; char timestr[TIME_BUF_SIZE];
struct tm result; struct tm result;
struct tm *tmp = gmtime_r(&t, &result); struct tm *tmp = gmtime_r(&secs, &result);
if (tmp == NULL) if (tmp == NULL)
return; return;
@ -486,34 +488,42 @@ void dump_time_header(struct req_state *s, const char *name, time_t t)
} }
} }
void dump_last_modified(struct req_state *s, time_t t) void dump_last_modified(struct req_state *s, real_time t)
{ {
dump_time_header(s, "Last-Modified", t); dump_time_header(s, "Last-Modified", t);
} }
void dump_epoch_header(struct req_state *s, const char *name, time_t t) void dump_epoch_header(struct req_state *s, const char *name, real_time t)
{ {
char buf[32]; utime_t ut(t);
snprintf(buf, sizeof(buf), "%lld", (long long)t); char sec_buf[32], nsec_buf[32];
snprintf(sec_buf, sizeof(sec_buf), "%lld", (long long)ut.sec());
snprintf(nsec_buf, sizeof(nsec_buf), "%09lld", (long long)ut.nsec());
int r = STREAM_IO(s)->print("%s: %s\r\n", name, buf); int r = STREAM_IO(s)->print("%s: %s.%s\r\n", name, sec_buf, nsec_buf);
if (r < 0) { if (r < 0) {
ldout(s->cct, 0) << "ERROR: s->cio->print() returned err=" << r << dendl; ldout(s->cct, 0) << "ERROR: s->cio->print() returned err=" << r << dendl;
} }
} }
void dump_time(struct req_state *s, const char *name, time_t *t) void dump_time(struct req_state *s, const char *name, real_time *t)
{ {
utime_t ut(*t);
char buf[TIME_BUF_SIZE]; char buf[TIME_BUF_SIZE];
struct tm result; struct tm result;
struct tm *tmp = gmtime_r(t, &result); time_t epoch = ut.sec();
struct tm *tmp = gmtime_r(&epoch, &result);
if (tmp == NULL) if (tmp == NULL)
return; return;
if (strftime(buf, sizeof(buf), "%Y-%m-%dT%T.000Z", tmp) == 0) if (strftime(buf, sizeof(buf), "%Y-%m-%dT%T", tmp) == 0)
return; return;
s->formatter->dump_string(name, buf); char buf2[TIME_BUF_SIZE];
snprintf(buf2, sizeof(buf2), "%s.%03dZ", buf, (int)(ut.usec() / 1000));
s->formatter->dump_string(name, buf2);
} }
void dump_owner(struct req_state *s, rgw_user& id, string& name, void dump_owner(struct req_state *s, rgw_user& id, string& name,

View File

@ -484,16 +484,16 @@ extern void dump_string_header(struct req_state *s, const char *name,
const char *val); const char *val);
extern void dump_content_length(struct req_state *s, uint64_t len); extern void dump_content_length(struct req_state *s, uint64_t len);
extern void dump_etag(struct req_state *s, const char *etag); extern void dump_etag(struct req_state *s, const char *etag);
extern void dump_epoch_header(struct req_state *s, const char *name, time_t t); extern void dump_epoch_header(struct req_state *s, const char *name, real_time t);
extern void dump_time_header(struct req_state *s, const char *name, time_t t); extern void dump_time_header(struct req_state *s, const char *name, real_time t);
extern void dump_last_modified(struct req_state *s, time_t t); extern void dump_last_modified(struct req_state *s, real_time t);
extern void abort_early(struct req_state* s, RGWOp* op, int err, extern void abort_early(struct req_state* s, RGWOp* op, int err,
RGWHandler* handler); RGWHandler* handler);
extern void dump_range(struct req_state* s, uint64_t ofs, uint64_t end, extern void dump_range(struct req_state* s, uint64_t ofs, uint64_t end,
uint64_t total_size); uint64_t total_size);
extern void dump_continue(struct req_state *s); extern void dump_continue(struct req_state *s);
extern void list_all_buckets_end(struct req_state *s); extern void list_all_buckets_end(struct req_state *s);
extern void dump_time(struct req_state *s, const char *name, time_t *t); extern void dump_time(struct req_state *s, const char *name, real_time *t);
extern void dump_bucket_from_state(struct req_state *s); extern void dump_bucket_from_state(struct req_state *s);
extern void dump_uri_from_state(struct req_state *s); extern void dump_uri_from_state(struct req_state *s);
extern void dump_redirect(struct req_state *s, const string& redirect); extern void dump_redirect(struct req_state *s, const string& redirect);

View File

@ -10,6 +10,7 @@
#include "common/ceph_crypto_cms.h" #include "common/ceph_crypto_cms.h"
#include "common/armor.h" #include "common/armor.h"
#include "common/strtol.h" #include "common/strtol.h"
#include "include/str_list.h"
#define dout_subsys ceph_subsys_rgw #define dout_subsys ceph_subsys_rgw
@ -532,25 +533,54 @@ void set_str_from_headers(map<string, string>& out_headers, const string& header
} }
} }
int RGWRESTStreamWriteRequest::complete(string& etag, time_t *mtime) static int parse_rgwx_mtime(CephContext *cct, const string& s, ceph::real_time *rt)
{
string err;
vector<string> vec;
get_str_vec(s, ".", vec);
if (vec.empty()) {
return -EINVAL;
}
long secs = strict_strtol(vec[0].c_str(), 10, &err);
long nsecs = 0;
if (!err.empty()) {
ldout(cct, 0) << "ERROR: failed converting mtime (" << s << ") to real_time " << dendl;
return -EINVAL;
}
if (vec.size() > 1) {
nsecs = strict_strtol(vec[1].c_str(), 10, &err);
if (!err.empty()) {
ldout(cct, 0) << "ERROR: failed converting mtime (" << s << ") to real_time " << dendl;
return -EINVAL;
}
}
*rt = utime_t(secs, nsecs).to_real_time();
return 0;
}
int RGWRESTStreamWriteRequest::complete(string& etag, real_time *mtime)
{ {
int ret = http_manager.complete_requests(); int ret = http_manager.complete_requests();
if (ret < 0) if (ret < 0)
return ret; return ret;
set_str_from_headers(out_headers, "ETAG", etag); set_str_from_headers(out_headers, "ETAG", etag);
if (mtime) { if (mtime) {
string mtime_str; string mtime_str;
set_str_from_headers(out_headers, "RGWX_MTIME", mtime_str); set_str_from_headers(out_headers, "RGWX_MTIME", mtime_str);
string err;
long t = strict_strtol(mtime_str.c_str(), 10, &err);
if (!err.empty()) {
ldout(cct, 0) << "ERROR: failed converting mtime (" << mtime_str << ") to int " << dendl;
return -EINVAL;
}
*mtime = (time_t)t;
}
ret = parse_rgwx_mtime(cct, mtime_str, mtime);
if (ret < 0) {
return ret;
}
}
return status; return status;
} }
@ -639,20 +669,15 @@ int RGWRESTStreamRWRequest::get_resource(RGWAccessKey& key, map<string, string>&
return 0; return 0;
} }
int RGWRESTStreamRWRequest::complete(string& etag, time_t *mtime, map<string, string>& attrs) int RGWRESTStreamRWRequest::complete(string& etag, real_time *mtime, map<string, string>& attrs)
{ {
set_str_from_headers(out_headers, "ETAG", etag); set_str_from_headers(out_headers, "ETAG", etag);
if (mtime) { if (mtime) {
string mtime_str; string mtime_str;
set_str_from_headers(out_headers, "RGWX_MTIME", mtime_str); set_str_from_headers(out_headers, "RGWX_MTIME", mtime_str);
if (!mtime_str.empty()) { int ret = parse_rgwx_mtime(cct, mtime_str, mtime);
string err; if (ret < 0) {
long t = strict_strtol(mtime_str.c_str(), 10, &err); return ret;
if (!err.empty()) {
ldout(cct, 0) << "ERROR: failed converting mtime (" << mtime_str << ") to int " << dendl;
return -EINVAL;
}
*mtime = (time_t)t;
} }
} }

View File

@ -79,7 +79,7 @@ public:
lock("RGWRESTStreamWriteRequest"), cb(NULL), http_manager(_cct) {} lock("RGWRESTStreamWriteRequest"), cb(NULL), http_manager(_cct) {}
~RGWRESTStreamWriteRequest(); ~RGWRESTStreamWriteRequest();
int put_obj_init(RGWAccessKey& key, rgw_obj& obj, uint64_t obj_size, map<string, bufferlist>& attrs); int put_obj_init(RGWAccessKey& key, rgw_obj& obj, uint64_t obj_size, map<string, bufferlist>& attrs);
int complete(string& etag, time_t *mtime); int complete(string& etag, real_time *mtime);
RGWGetDataCB *get_out_cb() { return cb; } RGWGetDataCB *get_out_cb() { return cb; }
}; };
@ -109,7 +109,7 @@ public:
virtual ~RGWRESTStreamRWRequest() {} virtual ~RGWRESTStreamRWRequest() {}
int get_obj(RGWAccessKey& key, map<string, string>& extra_headers, rgw_obj& obj); int get_obj(RGWAccessKey& key, map<string, string>& extra_headers, rgw_obj& obj);
int get_resource(RGWAccessKey& key, map<string, string>& extra_headers, const string& resource, RGWHTTPManager *mgr = NULL); int get_resource(RGWAccessKey& key, map<string, string>& extra_headers, const string& resource, RGWHTTPManager *mgr = NULL);
int complete(string& etag, time_t *mtime, map<string, string>& attrs); int complete(string& etag, real_time *mtime, map<string, string>& attrs);
void set_outbl(bufferlist& _outbl) { void set_outbl(bufferlist& _outbl) {
outbl.swap(_outbl); outbl.swap(_outbl);

View File

@ -87,7 +87,7 @@ int RGWRESTConn::put_obj_init(const rgw_user& uid, rgw_obj& obj, uint64_t obj_si
return (*req)->put_obj_init(key, obj, obj_size, attrs); return (*req)->put_obj_init(key, obj, obj_size, attrs);
} }
int RGWRESTConn::complete_request(RGWRESTStreamWriteRequest *req, string& etag, time_t *mtime) int RGWRESTConn::complete_request(RGWRESTStreamWriteRequest *req, string& etag, real_time *mtime)
{ {
int ret = req->complete(etag, mtime); int ret = req->complete(etag, mtime);
delete req; delete req;
@ -95,13 +95,13 @@ int RGWRESTConn::complete_request(RGWRESTStreamWriteRequest *req, string& etag,
return ret; return ret;
} }
static void set_date_header(const time_t *t, map<string, string>& headers, const string& header_name) static void set_date_header(const real_time *t, map<string, string>& headers, const string& header_name)
{ {
if (!t) { if (!t) {
return; return;
} }
stringstream s; stringstream s;
utime_t tm = utime_t(*t, 0); utime_t tm = utime_t(*t);
tm.asctime(s); tm.asctime(s);
headers[header_name] = s.str(); headers[header_name] = s.str();
} }
@ -116,7 +116,7 @@ static void set_header(T val, map<string, string>& headers, const string& header
int RGWRESTConn::get_obj(const rgw_user& uid, req_info *info /* optional */, rgw_obj& obj, int RGWRESTConn::get_obj(const rgw_user& uid, req_info *info /* optional */, rgw_obj& obj,
const time_t *mod_ptr, const time_t *unmod_ptr, const real_time *mod_ptr, const real_time *unmod_ptr,
uint32_t mod_zone_id, uint64_t mod_pg_ver, uint32_t mod_zone_id, uint64_t mod_pg_ver,
bool prepend_metadata, RGWGetDataCB *cb, RGWRESTStreamReadRequest **req) bool prepend_metadata, RGWGetDataCB *cb, RGWRESTStreamReadRequest **req)
{ {
@ -166,7 +166,7 @@ int RGWRESTConn::get_obj(const rgw_user& uid, req_info *info /* optional */, rgw
return (*req)->get_obj(key, extra_headers, obj); return (*req)->get_obj(key, extra_headers, obj);
} }
int RGWRESTConn::complete_request(RGWRESTStreamReadRequest *req, string& etag, time_t *mtime, map<string, string>& attrs) int RGWRESTConn::complete_request(RGWRESTStreamReadRequest *req, string& etag, real_time *mtime, map<string, string>& attrs)
{ {
int ret = req->complete(etag, mtime, attrs); int ret = req->complete(etag, mtime, attrs);
delete req; delete req;

View File

@ -88,13 +88,13 @@ public:
/* async request */ /* async request */
int put_obj_init(const rgw_user& uid, rgw_obj& obj, uint64_t obj_size, int put_obj_init(const rgw_user& uid, rgw_obj& obj, uint64_t obj_size,
map<string, bufferlist>& attrs, RGWRESTStreamWriteRequest **req); map<string, bufferlist>& attrs, RGWRESTStreamWriteRequest **req);
int complete_request(RGWRESTStreamWriteRequest *req, string& etag, time_t *mtime); int complete_request(RGWRESTStreamWriteRequest *req, string& etag, ceph::real_time *mtime);
int get_obj(const rgw_user& uid, req_info *info /* optional */, rgw_obj& obj, int get_obj(const rgw_user& uid, req_info *info /* optional */, rgw_obj& obj,
const time_t *mod_ptr, const time_t *unmod_ptr, const ceph::real_time *mod_ptr, const ceph::real_time *unmod_ptr,
uint32_t mod_zone_id, uint64_t mod_pg_ver, uint32_t mod_zone_id, uint64_t mod_pg_ver,
bool prepend_metadata, RGWGetDataCB *cb, RGWRESTStreamReadRequest **req); bool prepend_metadata, RGWGetDataCB *cb, RGWRESTStreamReadRequest **req);
int complete_request(RGWRESTStreamReadRequest *req, string& etag, time_t *mtime, map<string, string>& attrs); int complete_request(RGWRESTStreamReadRequest *req, string& etag, ceph::real_time *mtime, map<string, string>& attrs);
int get_resource(const string& resource, int get_resource(const string& resource,
param_list_t *extra_params, param_list_t *extra_params,

View File

@ -24,7 +24,7 @@
#define LOG_CLASS_LIST_MAX_ENTRIES (1000) #define LOG_CLASS_LIST_MAX_ENTRIES (1000)
#define dout_subsys ceph_subsys_rgw #define dout_subsys ceph_subsys_rgw
static int parse_date_str(string& in, utime_t& out) { static int parse_date_str(string& in, real_time& out) {
uint64_t epoch = 0; uint64_t epoch = 0;
uint64_t nsec = 0; uint64_t nsec = 0;
@ -34,7 +34,7 @@ static int parse_date_str(string& in, utime_t& out) {
return -EINVAL; return -EINVAL;
} }
} }
out = utime_t(epoch, nsec); out = utime_t(epoch, nsec).to_real_time();
return 0; return 0;
} }
@ -46,8 +46,8 @@ void RGWOp_MDLog_List::execute() {
et = s->info.args.get("end-time"), et = s->info.args.get("end-time"),
marker = s->info.args.get("marker"), marker = s->info.args.get("marker"),
err; err;
utime_t ut_st, real_time ut_st,
ut_et; ut_et;
void *handle; void *handle;
unsigned shard_id, max_entries = LOG_CLASS_LIST_MAX_ENTRIES; unsigned shard_id, max_entries = LOG_CLASS_LIST_MAX_ENTRIES;
@ -184,8 +184,8 @@ void RGWOp_MDLog_Delete::execute() {
period = s->info.args.get("period"), period = s->info.args.get("period"),
shard = s->info.args.get("id"), shard = s->info.args.get("id"),
err; err;
utime_t ut_st, real_time ut_st,
ut_et; ut_et;
unsigned shard_id; unsigned shard_id;
http_ret = 0; http_ret = 0;
@ -259,8 +259,8 @@ void RGWOp_MDLog_Lock::execute() {
http_ret = -EINVAL; http_ret = -EINVAL;
return; return;
} }
utime_t time(dur, 0); http_ret = meta_log.lock_exclusive(shard_id, timespan(dur), zone_id,
http_ret = meta_log.lock_exclusive(shard_id, time, zone_id, locker_id); locker_id);
if (http_ret == -EBUSY) if (http_ret == -EBUSY)
http_ret = -ERR_LOCKED; http_ret = -ERR_LOCKED;
} }
@ -545,8 +545,8 @@ void RGWOp_DATALog_List::execute() {
max_entries_str = s->info.args.get("max-entries"), max_entries_str = s->info.args.get("max-entries"),
marker = s->info.args.get("marker"), marker = s->info.args.get("marker"),
err; err;
utime_t ut_st, real_time ut_st,
ut_et; ut_et;
unsigned shard_id, max_entries = LOG_CLASS_LIST_MAX_ENTRIES; unsigned shard_id, max_entries = LOG_CLASS_LIST_MAX_ENTRIES;
s->info.args.get_bool("extra-info", &extra_info, false); s->info.args.get_bool("extra-info", &extra_info, false);
@ -695,8 +695,7 @@ void RGWOp_DATALog_Lock::execute() {
http_ret = -EINVAL; http_ret = -EINVAL;
return; return;
} }
utime_t time(dur, 0); http_ret = store->data_log->lock_exclusive(shard_id, timespan(dur), zone_id, locker_id);
http_ret = store->data_log->lock_exclusive(shard_id, time, zone_id, locker_id);
if (http_ret == -EBUSY) if (http_ret == -EBUSY)
http_ret = -ERR_LOCKED; http_ret = -ERR_LOCKED;
} }
@ -783,8 +782,8 @@ void RGWOp_DATALog_Delete::execute() {
end_marker = s->info.args.get("end-marker"), end_marker = s->info.args.get("end-marker"),
shard = s->info.args.get("id"), shard = s->info.args.get("id"),
err; err;
utime_t ut_st, real_time ut_st,
ut_et; ut_et;
unsigned shard_id; unsigned shard_id;
http_ret = 0; http_ret = 0;

View File

@ -250,8 +250,7 @@ void RGWOp_Metadata_Lock::execute() {
http_ret = -EINVAL; http_ret = -EINVAL;
return; return;
} }
utime_t time(dur, 0); http_ret = store->meta_mgr->lock_exclusive(metadata_key, timespan(dur), lock_id);
http_ret = store->meta_mgr->lock_exclusive(metadata_key, time, lock_id);
if (http_ret == -EBUSY) if (http_ret == -EBUSY)
http_ret = -ERR_LOCKED; http_ret = -ERR_LOCKED;
} }

View File

@ -148,7 +148,7 @@ void RGWOp_OBJLog_DeleteBounds::execute() {
static int bucket_instance_to_bucket(RGWRados *store, const string& bucket_instance, rgw_bucket& bucket) { static int bucket_instance_to_bucket(RGWRados *store, const string& bucket_instance, rgw_bucket& bucket) {
RGWBucketInfo bucket_info; RGWBucketInfo bucket_info;
time_t mtime; real_time mtime;
RGWObjectCtx obj_ctx(store); RGWObjectCtx obj_ctx(store);
int r = store->get_bucket_instance_info(obj_ctx, bucket_instance, bucket_info, &mtime, NULL); int r = store->get_bucket_instance_info(obj_ctx, bucket_instance, bucket_info, &mtime, NULL);

View File

@ -159,7 +159,8 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,
JSONFormatter jf; JSONFormatter jf;
jf.open_object_section("obj_metadata"); jf.open_object_section("obj_metadata");
encode_json("attrs", attrs, &jf); encode_json("attrs", attrs, &jf);
encode_json("mtime", lastmod, &jf); utime_t ut(lastmod);
encode_json("mtime", ut, &jf);
jf.close_section(); jf.close_section();
stringstream ss; stringstream ss;
jf.flush(ss); jf.flush(ss);
@ -169,7 +170,7 @@ int RGWGetObj_ObjStore_S3::send_response_data(bufferlist& bl, off_t bl_ofs,
total_len += metadata_bl.length(); total_len += metadata_bl.length();
} }
if (s->system_request && lastmod) { if (s->system_request && !real_clock::is_zero(lastmod)) {
/* we end up dumping mtime in two different methods, a bit redundant */ /* we end up dumping mtime in two different methods, a bit redundant */
dump_epoch_header(s, "Rgwx-Mtime", lastmod); dump_epoch_header(s, "Rgwx-Mtime", lastmod);
uint64_t pg_ver = 0; uint64_t pg_ver = 0;
@ -488,7 +489,6 @@ void RGWListBucket_ObjStore_S3::send_versioned_response()
vector<RGWObjEnt>::iterator iter; vector<RGWObjEnt>::iterator iter;
for (iter = objs.begin(); iter != objs.end(); ++iter) { for (iter = objs.begin(); iter != objs.end(); ++iter) {
time_t mtime = iter->mtime.sec();
const char *section_name = (iter->is_delete_marker() ? "DeleteMarker" const char *section_name = (iter->is_delete_marker() ? "DeleteMarker"
: "Version"); : "Version");
s->formatter->open_object_section(section_name); s->formatter->open_object_section(section_name);
@ -514,7 +514,7 @@ void RGWListBucket_ObjStore_S3::send_versioned_response()
} }
s->formatter->dump_string("VersionId", version_id); s->formatter->dump_string("VersionId", version_id);
s->formatter->dump_bool("IsLatest", iter->is_current()); s->formatter->dump_bool("IsLatest", iter->is_current());
dump_time(s, "LastModified", &mtime); dump_time(s, "LastModified", &iter->mtime);
if (!iter->is_delete_marker()) { if (!iter->is_delete_marker()) {
s->formatter->dump_format("ETag", "\"%s\"", iter->etag.c_str()); s->formatter->dump_format("ETag", "\"%s\"", iter->etag.c_str());
s->formatter->dump_int("Size", iter->size); s->formatter->dump_int("Size", iter->size);
@ -588,8 +588,7 @@ void RGWListBucket_ObjStore_S3::send_response()
} else { } else {
s->formatter->dump_string("Key", iter->key.name); s->formatter->dump_string("Key", iter->key.name);
} }
time_t mtime = iter->mtime.sec(); dump_time(s, "LastModified", &iter->mtime);
dump_time(s, "LastModified", &mtime);
s->formatter->dump_format("ETag", "\"%s\"", iter->etag.c_str()); s->formatter->dump_format("ETag", "\"%s\"", iter->etag.c_str());
s->formatter->dump_int("Size", iter->size); s->formatter->dump_int("Size", iter->size);
s->formatter->dump_string("StorageClass", "STANDARD"); s->formatter->dump_string("StorageClass", "STANDARD");
@ -1068,7 +1067,7 @@ void RGWPutObj_ObjStore_S3::send_response()
dump_etag(s, etag.c_str()); dump_etag(s, etag.c_str());
dump_content_length(s, 0); dump_content_length(s, 0);
} }
if (s->system_request && mtime) { if (s->system_request && !real_clock::is_zero(mtime)) {
dump_epoch_header(s, "Rgwx-Mtime", mtime); dump_epoch_header(s, "Rgwx-Mtime", mtime);
} }
dump_errno(s); dump_errno(s);
@ -1571,7 +1570,7 @@ int RGWPostObj_ObjStore_S3::get_policy()
/* try to store user if it not already exists */ /* try to store user if it not already exists */
if (rgw_get_user_info_by_uid(store, uid, user_info) < 0) { if (rgw_get_user_info_by_uid(store, uid, user_info) < 0) {
int ret = rgw_store_user_info(store, user_info, NULL, NULL, 0, true); int ret = rgw_store_user_info(store, user_info, NULL, NULL, real_time(), true);
if (ret < 0) { if (ret < 0) {
ldout(store->ctx(), 10) ldout(store->ctx(), 10)
<< "NOTICE: failed to store new user's info: ret=" << "NOTICE: failed to store new user's info: ret="
@ -1593,7 +1592,7 @@ int RGWPostObj_ObjStore_S3::get_policy()
/* try to store user if it not already exists */ /* try to store user if it not already exists */
if (rgw_get_user_info_by_uid(store, user_info.user_id, if (rgw_get_user_info_by_uid(store, user_info.user_id,
user_info) < 0) { user_info) < 0) {
int ret = rgw_store_user_info(store, user_info, NULL, NULL, 0, true); int ret = rgw_store_user_info(store, user_info, NULL, NULL, real_time(), true);
if (ret < 0) { if (ret < 0) {
ldout(store->ctx(), 10) ldout(store->ctx(), 10)
<< "NOTICE: failed to store new user's info: ret=" << ret << "NOTICE: failed to store new user's info: ret=" << ret
@ -1864,11 +1863,12 @@ int RGWDeleteObj_ObjStore_S3::get_params()
string if_unmod_decoded; string if_unmod_decoded;
url_decode(if_unmod_str, if_unmod_decoded); url_decode(if_unmod_str, if_unmod_decoded);
uint64_t epoch; uint64_t epoch;
if (utime_t::parse_date(if_unmod_decoded, &epoch, NULL) < 0) { uint64_t nsec;
if (utime_t::parse_date(if_unmod_decoded, &epoch, &nsec) < 0) {
ldout(s->cct, 10) << "failed to parse time: " << if_unmod_decoded << dendl; ldout(s->cct, 10) << "failed to parse time: " << if_unmod_decoded << dendl;
return -EINVAL; return -EINVAL;
} }
unmod_since = epoch; unmod_since = utime_t(epoch, nsec).to_real_time();
} }
return 0; return 0;
@ -2410,16 +2410,9 @@ void RGWListMultipart_ObjStore_S3::send_response()
for (; iter != parts.end(); ++iter) { for (; iter != parts.end(); ++iter) {
RGWUploadPartInfo& info = iter->second; RGWUploadPartInfo& info = iter->second;
time_t sec = info.modified.sec();
struct tm tmp;
gmtime_r(&sec, &tmp);
char buf[TIME_BUF_SIZE];
s->formatter->open_object_section("Part"); s->formatter->open_object_section("Part");
if (strftime(buf, sizeof(buf), "%Y-%m-%dT%T.000Z", &tmp) > 0) { dump_time(s, "LastModified", &info.modified);
s->formatter->dump_string("LastModified", buf);
}
s->formatter->dump_unsigned("PartNumber", info.num); s->formatter->dump_unsigned("PartNumber", info.num);
s->formatter->dump_string("ETag", info.etag); s->formatter->dump_string("ETag", info.etag);
@ -2475,8 +2468,7 @@ void RGWListBucketMultiparts_ObjStore_S3::send_response()
dump_owner(s, s->user->user_id, s->user->display_name, "Initiator"); dump_owner(s, s->user->user_id, s->user->display_name, "Initiator");
dump_owner(s, s->user->user_id, s->user->display_name); dump_owner(s, s->user->user_id, s->user->display_name);
s->formatter->dump_string("StorageClass", "STANDARD"); s->formatter->dump_string("StorageClass", "STANDARD");
time_t mtime = iter->obj.mtime.sec(); dump_time(s, "Initiated", &iter->obj.mtime);
dump_time(s, "Initiated", &mtime);
s->formatter->close_section(); s->formatter->close_section();
} }
if (!common_prefixes.empty()) { if (!common_prefixes.empty()) {
@ -3231,7 +3223,7 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s)
s->aws4_auth->date = s->info.args.get("X-Amz-Date"); s->aws4_auth->date = s->info.args.get("X-Amz-Date");
struct tm date_t; struct tm date_t;
if (!parse_iso8601(s->aws4_auth->date.c_str(), &date_t, false)) if (!parse_iso8601(s->aws4_auth->date.c_str(), &date_t, NULL, false))
return -EPERM; return -EPERM;
s->aws4_auth->expires = s->info.args.get("X-Amz-Expires"); s->aws4_auth->expires = s->info.args.get("X-Amz-Expires");
@ -3352,7 +3344,7 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s)
const char *d = s->info.env->get("HTTP_X_AMZ_DATE"); const char *d = s->info.env->get("HTTP_X_AMZ_DATE");
struct tm t; struct tm t;
if (!parse_iso8601(d, &t, false)) { if (!parse_iso8601(d, &t, NULL, false)) {
dout(10) << "error reading date via http_x_amz_date" << dendl; dout(10) << "error reading date via http_x_amz_date" << dendl;
return -EACCES; return -EACCES;
} }
@ -3688,7 +3680,7 @@ int RGW_Auth_S3::authorize_v2(RGWRados *store, struct req_state *s)
rgw_user uid(project_id); rgw_user uid(project_id);
/* try to store user if it not already exists */ /* try to store user if it not already exists */
if (rgw_get_user_info_by_uid(store, uid, *(s->user)) < 0) { if (rgw_get_user_info_by_uid(store, uid, *(s->user)) < 0) {
int ret = rgw_store_user_info(store, *(s->user), NULL, NULL, 0, true); int ret = rgw_store_user_info(store, *(s->user), NULL, NULL, real_time(), true);
if (ret < 0) if (ret < 0)
dout(10) << "NOTICE: failed to store new user's info: ret=" dout(10) << "NOTICE: failed to store new user's info: ret="
<< ret << dendl; << ret << dendl;
@ -3716,7 +3708,7 @@ int RGW_Auth_S3::authorize_v2(RGWRados *store, struct req_state *s)
s->user->display_name = token.id; // cn? s->user->display_name = token.id; // cn?
if (rgw_get_user_info_by_uid(store, s->user->user_id, if (rgw_get_user_info_by_uid(store, s->user->user_id,
*(s->user)) < 0) { *(s->user)) < 0) {
int ret = rgw_store_user_info(store, *(s->user), NULL, NULL, 0, true); int ret = rgw_store_user_info(store, *(s->user), NULL, NULL, real_time(), true);
if (ret < 0) { if (ret < 0) {
dout(10) << "NOTICE: failed to store new user's info: ret=" << ret dout(10) << "NOTICE: failed to store new user's info: ret=" << ret
<< dendl; << dendl;

View File

@ -272,8 +272,7 @@ void RGWListBucket_ObjStore_SWIFT::send_response()
} }
s->formatter->dump_string("content_type", single_content_type); s->formatter->dump_string("content_type", single_content_type);
} }
time_t mtime = iter->mtime.sec(); dump_time(s, "last_modified", &iter->mtime);
dump_time(s, "last_modified", &mtime);
s->formatter->close_section(); s->formatter->close_section();
} }
@ -327,8 +326,9 @@ static void dump_container_metadata(struct req_state *s, RGWBucketEnt& bucket)
{ {
char buf[32]; char buf[32];
/* Adding X-Timestamp to keep align with Swift API */ /* Adding X-Timestamp to keep align with Swift API */
snprintf(buf, sizeof(buf), "%lld.00000", utime_t ut(s->bucket_info.creation_time);
(long long)s->bucket_info.creation_time); snprintf(buf, sizeof(buf), "%lld.%05d",
(long long)ut.sec(), (int)(ut.usec() / 10));
STREAM_IO(s)->print("X-Timestamp: %s\r\n", buf); STREAM_IO(s)->print("X-Timestamp: %s\r\n", buf);
snprintf(buf, sizeof(buf), "%lld", (long long)bucket.count); snprintf(buf, sizeof(buf), "%lld", (long long)bucket.count);
STREAM_IO(s)->print("X-Container-Object-Count: %s\r\n", buf); STREAM_IO(s)->print("X-Container-Object-Count: %s\r\n", buf);
@ -515,10 +515,10 @@ void RGWDeleteBucket_ObjStore_SWIFT::send_response()
rgw_flush_formatter_and_reset(s, s->formatter); rgw_flush_formatter_and_reset(s, s->formatter);
} }
static int get_delete_at_param(req_state *s, time_t *delete_at) static int get_delete_at_param(req_state *s, real_time *delete_at)
{ {
/* Handle Swift object expiration. */ /* Handle Swift object expiration. */
utime_t delat_proposal; real_time delat_proposal;
string x_delete = s->info.env->get("HTTP_X_DELETE_AFTER", ""); string x_delete = s->info.env->get("HTTP_X_DELETE_AFTER", "");
if (x_delete.empty()) { if (x_delete.empty()) {
@ -526,7 +526,7 @@ static int get_delete_at_param(req_state *s, time_t *delete_at)
} else { } else {
/* X-Delete-After HTTP is present. It means we need add its value /* X-Delete-After HTTP is present. It means we need add its value
* to the current time. */ * to the current time. */
delat_proposal = ceph_clock_now(g_ceph_context); delat_proposal = real_clock::now();
} }
if (x_delete.empty()) { if (x_delete.empty()) {
@ -539,12 +539,12 @@ static int get_delete_at_param(req_state *s, time_t *delete_at)
return -EINVAL; return -EINVAL;
} }
delat_proposal += utime_t(ts, 0); delat_proposal += timespan(ts);
if (delat_proposal < ceph_clock_now(g_ceph_context)) { if (delat_proposal < real_clock::now()) {
return -EINVAL; return -EINVAL;
} }
*delete_at = delat_proposal.sec(); *delete_at = delat_proposal;
return 0; return 0;
} }
@ -1090,7 +1090,10 @@ int RGWGetObj_ObjStore_SWIFT::send_response_data(bufferlist& bl,
dump_content_length(s, total_len); dump_content_length(s, total_len);
dump_last_modified(s, lastmod); dump_last_modified(s, lastmod);
STREAM_IO(s)->print("X-Timestamp: %lld.00000\r\n", (long long)lastmod); {
utime_t ut(lastmod);
STREAM_IO(s)->print("X-Timestamp: %lld.%05d\r\n", (long long)ut.sec(), (int)(ut.usec() / 10));
}
if (is_slo) { if (is_slo) {
STREAM_IO(s)->print("X-Static-Large-Object: True\r\n"); STREAM_IO(s)->print("X-Static-Large-Object: True\r\n");
} }

View File

@ -418,7 +418,7 @@ int RGWSwift::update_user_info(RGWRados *store, struct rgw_swift_auth_info *info
user_info.user_id = info->user; user_info.user_id = info->user;
user_info.display_name = info->display_name; user_info.display_name = info->display_name;
int ret = rgw_store_user_info(store, user_info, NULL, NULL, 0, true); int ret = rgw_store_user_info(store, user_info, NULL, NULL, real_time(), true);
if (ret < 0) { if (ret < 0) {
ldout(cct, 0) << "ERROR: failed to store new user's info: ret=" << ret << dendl; ldout(cct, 0) << "ERROR: failed to store new user's info: ret=" << ret << dendl;
return ret; return ret;

View File

@ -48,7 +48,7 @@ RGWCoroutine *RGWSyncErrorLogger::log_error_cr(const string& source_zone, const
rgw_sync_error_info info(source_zone, error_code, message); rgw_sync_error_info info(source_zone, error_code, message);
bufferlist bl; bufferlist bl;
::encode(info, bl); ::encode(info, bl);
store->time_log_prepare_entry(entry, ceph_clock_now(store->ctx()), section, name, bl); store->time_log_prepare_entry(entry, real_clock::now(), section, name, bl);
uint32_t shard_id = counter.inc() % num_shards; uint32_t shard_id = counter.inc() % num_shards;
@ -122,12 +122,13 @@ void rgw_mdlog_info::decode_json(JSONObj *obj) {
JSONDecoder::decode_json("realm_epoch", realm_epoch, obj); JSONDecoder::decode_json("realm_epoch", realm_epoch, obj);
} }
void rgw_mdlog_entry::decode_json(JSONObj *obj) { void rgw_mdlog_entry::decode_json(JSONObj *obj) {
JSONDecoder::decode_json("id", id, obj); JSONDecoder::decode_json("id", id, obj);
JSONDecoder::decode_json("section", section, obj); JSONDecoder::decode_json("section", section, obj);
JSONDecoder::decode_json("name", name, obj); JSONDecoder::decode_json("name", name, obj);
JSONDecoder::decode_json("timestamp", timestamp, obj); utime_t ut;
JSONDecoder::decode_json("timestamp", ut, obj);
timestamp = ut.to_real_time();
JSONDecoder::decode_json("data", log_data, obj); JSONDecoder::decode_json("data", log_data, obj);
} }
@ -375,8 +376,8 @@ class RGWAsyncReadMDLogEntries : public RGWAsyncRadosRequest {
protected: protected:
int _send_request() { int _send_request() {
utime_t from_time; real_time from_time;
utime_t end_time; real_time end_time;
void *handle; void *handle;
@ -1081,13 +1082,13 @@ public:
marker_oid(_marker_oid), marker_oid(_marker_oid),
sync_marker(_marker) {} sync_marker(_marker) {}
RGWCoroutine *store_marker(const string& new_marker, uint64_t index_pos, const utime_t& timestamp) { RGWCoroutine *store_marker(const string& new_marker, uint64_t index_pos, const real_time& timestamp) {
sync_marker.marker = new_marker; sync_marker.marker = new_marker;
if (index_pos > 0) { if (index_pos > 0) {
sync_marker.pos = index_pos; sync_marker.pos = index_pos;
} }
if (timestamp.sec() > 0) { if (!real_clock::is_zero(timestamp)) {
sync_marker.timestamp = timestamp; sync_marker.timestamp = timestamp;
} }
@ -1422,7 +1423,7 @@ public:
for (; iter != entries.end(); ++iter) { for (; iter != entries.end(); ++iter) {
ldout(sync_env->cct, 20) << __func__ << ": full sync: " << iter->first << dendl; ldout(sync_env->cct, 20) << __func__ << ": full sync: " << iter->first << dendl;
total_entries++; total_entries++;
if (!marker_tracker->start(iter->first, total_entries, utime_t())) { if (!marker_tracker->start(iter->first, total_entries, real_time())) {
ldout(sync_env->cct, 0) << "ERROR: cannot start syncing " << iter->first << ". Duplicate entry?" << dendl; ldout(sync_env->cct, 0) << "ERROR: cannot start syncing " << iter->first << ". Duplicate entry?" << dendl;
} else { } else {
// fetch remote and write locally // fetch remote and write locally
@ -1570,7 +1571,7 @@ public:
continue; continue;
} }
ldout(sync_env->cct, 20) << __func__ << ":" << __LINE__ << ": shard_id=" << shard_id << " log_entry: " << log_iter->id << ":" << log_iter->section << ":" << log_iter->name << ":" << log_iter->timestamp << dendl; ldout(sync_env->cct, 20) << __func__ << ":" << __LINE__ << ": shard_id=" << shard_id << " log_entry: " << log_iter->id << ":" << log_iter->section << ":" << log_iter->name << ":" << log_iter->timestamp << dendl;
if (!marker_tracker->start(log_iter->id, 0, log_iter->timestamp)) { if (!marker_tracker->start(log_iter->id, 0, log_iter->timestamp.to_real_time())) {
ldout(sync_env->cct, 0) << "ERROR: cannot start syncing " << log_iter->id << ". Duplicate entry?" << dendl; ldout(sync_env->cct, 0) << "ERROR: cannot start syncing " << log_iter->id << ". Duplicate entry?" << dendl;
} else { } else {
raw_key = log_iter->section + ":" + log_iter->name; raw_key = log_iter->section + ":" + log_iter->name;
@ -2124,7 +2125,7 @@ int RGWCloneMetaLogCoroutine::state_store_mdlog_entries()
dest_entry.id = entry.id; dest_entry.id = entry.id;
dest_entry.section = entry.section; dest_entry.section = entry.section;
dest_entry.name = entry.name; dest_entry.name = entry.name;
dest_entry.timestamp = entry.timestamp; dest_entry.timestamp = utime_t(entry.timestamp);
::encode(entry.log_data, dest_entry.data); ::encode(entry.log_data, dest_entry.data);

View File

@ -25,7 +25,7 @@ struct rgw_mdlog_entry {
string id; string id;
string section; string section;
string name; string name;
utime_t timestamp; ceph::real_time timestamp;
RGWMetadataLogData log_data; RGWMetadataLogData log_data;
void decode_json(JSONObj *obj); void decode_json(JSONObj *obj);
@ -34,7 +34,7 @@ struct rgw_mdlog_entry {
id = le.id; id = le.id;
section = le.section; section = le.section;
name = le.name; name = le.name;
timestamp = le.timestamp; timestamp = le.timestamp.to_real_time();
try { try {
bufferlist::iterator iter = le.data.begin(); bufferlist::iterator iter = le.data.begin();
::decode(log_data, iter); ::decode(log_data, iter);
@ -231,7 +231,7 @@ class RGWMetaSyncStatusManager {
map<int, rgw_obj> shard_objs; map<int, rgw_obj> shard_objs;
struct utime_shard { struct utime_shard {
utime_t ts; real_time ts;
int shard_id; int shard_id;
utime_shard() : shard_id(-1) {} utime_shard() : shard_id(-1) {}
@ -283,10 +283,10 @@ template <class T, class K>
class RGWSyncShardMarkerTrack { class RGWSyncShardMarkerTrack {
struct marker_entry { struct marker_entry {
uint64_t pos; uint64_t pos;
utime_t timestamp; real_time timestamp;
marker_entry() : pos(0) {} marker_entry() : pos(0) {}
marker_entry(uint64_t _p, const utime_t& _ts) : pos(_p), timestamp(_ts) {} marker_entry(uint64_t _p, const real_time& _ts) : pos(_p), timestamp(_ts) {}
}; };
typename std::map<T, marker_entry> pending; typename std::map<T, marker_entry> pending;
@ -300,14 +300,14 @@ class RGWSyncShardMarkerTrack {
protected: protected:
typename std::set<K> need_retry_set; typename std::set<K> need_retry_set;
virtual RGWCoroutine *store_marker(const T& new_marker, uint64_t index_pos, const utime_t& timestamp) = 0; virtual RGWCoroutine *store_marker(const T& new_marker, uint64_t index_pos, const real_time& timestamp) = 0;
virtual void handle_finish(const T& marker) { } virtual void handle_finish(const T& marker) { }
public: public:
RGWSyncShardMarkerTrack(int _window_size) : window_size(_window_size), updates_since_flush(0) {} RGWSyncShardMarkerTrack(int _window_size) : window_size(_window_size), updates_since_flush(0) {}
virtual ~RGWSyncShardMarkerTrack() {} virtual ~RGWSyncShardMarkerTrack() {}
bool start(const T& pos, int index_pos, const utime_t& timestamp) { bool start(const T& pos, int index_pos, const real_time& timestamp) {
if (pending.find(pos) != pending.end()) { if (pending.find(pos) != pending.end()) {
return false; return false;
} }
@ -315,7 +315,7 @@ public:
return true; return true;
} }
void try_update_high_marker(const T& pos, int index_pos, const utime_t& timestamp) { void try_update_high_marker(const T& pos, int index_pos, const real_time& timestamp) {
if (!(pos <= high_marker)) { if (!(pos <= high_marker)) {
high_marker = pos; high_marker = pos;
high_entry = marker_entry(index_pos, timestamp); high_entry = marker_entry(index_pos, timestamp);

View File

@ -19,7 +19,7 @@
static map<string, string> ext_mime_map; static map<string, string> ext_mime_map;
int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, string& oid, const char *data, size_t size, bool exclusive, int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, string& oid, const char *data, size_t size, bool exclusive,
RGWObjVersionTracker *objv_tracker, time_t set_mtime, map<string, bufferlist> *pattrs) RGWObjVersionTracker *objv_tracker, real_time set_mtime, map<string, bufferlist> *pattrs)
{ {
map<string,bufferlist> no_attrs; map<string,bufferlist> no_attrs;
if (!pattrs) if (!pattrs)
@ -39,7 +39,7 @@ int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, string& oid, cons
} }
int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bucket, const string& key, bufferlist& bl, int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bucket, const string& key, bufferlist& bl,
RGWObjVersionTracker *objv_tracker, time_t *pmtime, map<string, bufferlist> *pattrs, RGWObjVersionTracker *objv_tracker, real_time *pmtime, map<string, bufferlist> *pattrs,
rgw_cache_entry_info *cache_info) rgw_cache_entry_info *cache_info)
{ {
struct rgw_err err; struct rgw_err err;

View File

@ -7,6 +7,7 @@
#include <string> #include <string>
#include "include/types.h" #include "include/types.h"
#include "common/ceph_time.h"
#include "rgw_common.h" #include "rgw_common.h"
class RGWRados; class RGWRados;
@ -16,9 +17,9 @@ struct RGWObjVersionTracker;
struct obj_version; struct obj_version;
int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, string& oid, const char *data, size_t size, bool exclusive, int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, string& oid, const char *data, size_t size, bool exclusive,
RGWObjVersionTracker *objv_tracker, time_t set_mtime, map<string, bufferlist> *pattrs = NULL); RGWObjVersionTracker *objv_tracker, real_time set_mtime, map<string, bufferlist> *pattrs = NULL);
int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bucket, const string& key, bufferlist& bl, int rgw_get_system_obj(RGWRados *rgwstore, RGWObjectCtx& obj_ctx, rgw_bucket& bucket, const string& key, bufferlist& bl,
RGWObjVersionTracker *objv_tracker, time_t *pmtime, map<string, bufferlist> *pattrs = NULL, RGWObjVersionTracker *objv_tracker, real_time *pmtime, map<string, bufferlist> *pattrs = NULL,
rgw_cache_entry_info *cache_info = NULL); rgw_cache_entry_info *cache_info = NULL);
int rgw_tools_init(CephContext *cct); int rgw_tools_init(CephContext *cct);

View File

@ -95,7 +95,7 @@ int rgw_store_user_info(RGWRados *store,
RGWUserInfo& info, RGWUserInfo& info,
RGWUserInfo *old_info, RGWUserInfo *old_info,
RGWObjVersionTracker *objv_tracker, RGWObjVersionTracker *objv_tracker,
time_t mtime, real_time mtime,
bool exclusive, bool exclusive,
map<string, bufferlist> *pattrs) map<string, bufferlist> *pattrs)
{ {
@ -169,7 +169,7 @@ int rgw_store_user_info(RGWRados *store,
if (!old_info || if (!old_info ||
old_info->user_email.compare(info.user_email) != 0) { /* only if new index changed */ old_info->user_email.compare(info.user_email) != 0) { /* only if new index changed */
ret = rgw_put_system_obj(store, store->get_zone_params().user_email_pool, info.user_email, ret = rgw_put_system_obj(store, store->get_zone_params().user_email_pool, info.user_email,
link_bl.c_str(), link_bl.length(), exclusive, NULL, 0); link_bl.c_str(), link_bl.length(), exclusive, NULL, real_time());
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
@ -184,7 +184,7 @@ int rgw_store_user_info(RGWRados *store,
ret = rgw_put_system_obj(store, store->get_zone_params().user_keys_pool, k.id, ret = rgw_put_system_obj(store, store->get_zone_params().user_keys_pool, k.id,
link_bl.c_str(), link_bl.length(), exclusive, link_bl.c_str(), link_bl.length(), exclusive,
NULL, 0); NULL, real_time());
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
@ -198,7 +198,7 @@ int rgw_store_user_info(RGWRados *store,
ret = rgw_put_system_obj(store, store->get_zone_params().user_swift_pool, k.id, ret = rgw_put_system_obj(store, store->get_zone_params().user_swift_pool, k.id,
link_bl.c_str(), link_bl.length(), exclusive, link_bl.c_str(), link_bl.length(), exclusive,
NULL, 0); NULL, real_time());
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
@ -209,13 +209,13 @@ int rgw_store_user_info(RGWRados *store,
struct user_info_entry { struct user_info_entry {
RGWUserInfo info; RGWUserInfo info;
RGWObjVersionTracker objv_tracker; RGWObjVersionTracker objv_tracker;
time_t mtime; real_time mtime;
}; };
static RGWChainedCacheImpl<user_info_entry> uinfo_cache; static RGWChainedCacheImpl<user_info_entry> uinfo_cache;
int rgw_get_user_info_from_index(RGWRados *store, string& key, rgw_bucket& bucket, RGWUserInfo& info, int rgw_get_user_info_from_index(RGWRados *store, string& key, rgw_bucket& bucket, RGWUserInfo& info,
RGWObjVersionTracker *objv_tracker, time_t *pmtime) RGWObjVersionTracker *objv_tracker, real_time *pmtime)
{ {
user_info_entry e; user_info_entry e;
if (uinfo_cache.find(key, &e)) { if (uinfo_cache.find(key, &e)) {
@ -271,7 +271,7 @@ int rgw_get_user_info_by_uid(RGWRados *store,
const rgw_user& uid, const rgw_user& uid,
RGWUserInfo& info, RGWUserInfo& info,
RGWObjVersionTracker *objv_tracker, RGWObjVersionTracker *objv_tracker,
time_t *pmtime, real_time *pmtime,
rgw_cache_entry_info *cache_info, rgw_cache_entry_info *cache_info,
map<string, bufferlist> *pattrs) map<string, bufferlist> *pattrs)
{ {
@ -308,7 +308,7 @@ int rgw_get_user_info_by_uid(RGWRados *store,
* returns: 0 on success, -ERR# on failure (including nonexistence) * returns: 0 on success, -ERR# on failure (including nonexistence)
*/ */
int rgw_get_user_info_by_email(RGWRados *store, string& email, RGWUserInfo& info, int rgw_get_user_info_by_email(RGWRados *store, string& email, RGWUserInfo& info,
RGWObjVersionTracker *objv_tracker, time_t *pmtime) RGWObjVersionTracker *objv_tracker, real_time *pmtime)
{ {
return rgw_get_user_info_from_index(store, email, store->get_zone_params().user_email_pool, info, objv_tracker, pmtime); return rgw_get_user_info_from_index(store, email, store->get_zone_params().user_email_pool, info, objv_tracker, pmtime);
} }
@ -318,7 +318,7 @@ int rgw_get_user_info_by_email(RGWRados *store, string& email, RGWUserInfo& info
* returns: 0 on success, -ERR# on failure (including nonexistence) * returns: 0 on success, -ERR# on failure (including nonexistence)
*/ */
extern int rgw_get_user_info_by_swift(RGWRados *store, string& swift_name, RGWUserInfo& info, extern int rgw_get_user_info_by_swift(RGWRados *store, string& swift_name, RGWUserInfo& info,
RGWObjVersionTracker *objv_tracker, time_t *pmtime) RGWObjVersionTracker *objv_tracker, real_time *pmtime)
{ {
return rgw_get_user_info_from_index(store, swift_name, store->get_zone_params().user_swift_pool, info, objv_tracker, pmtime); return rgw_get_user_info_from_index(store, swift_name, store->get_zone_params().user_swift_pool, info, objv_tracker, pmtime);
} }
@ -328,7 +328,7 @@ extern int rgw_get_user_info_by_swift(RGWRados *store, string& swift_name, RGWUs
* returns: 0 on success, -ERR# on failure (including nonexistence) * returns: 0 on success, -ERR# on failure (including nonexistence)
*/ */
extern int rgw_get_user_info_by_access_key(RGWRados *store, string& access_key, RGWUserInfo& info, extern int rgw_get_user_info_by_access_key(RGWRados *store, string& access_key, RGWUserInfo& info,
RGWObjVersionTracker *objv_tracker, time_t *pmtime) RGWObjVersionTracker *objv_tracker, real_time *pmtime)
{ {
return rgw_get_user_info_from_index(store, access_key, store->get_zone_params().user_keys_pool, info, objv_tracker, pmtime); return rgw_get_user_info_from_index(store, access_key, store->get_zone_params().user_keys_pool, info, objv_tracker, pmtime);
} }
@ -1803,7 +1803,7 @@ int RGWUser::update(RGWUserAdminOpState& op_state, std::string *err_msg)
} }
if (is_populated()) { if (is_populated()) {
ret = rgw_store_user_info(store, user_info, &old_info, &op_state.objv, 0, false); ret = rgw_store_user_info(store, user_info, &old_info, &op_state.objv, real_time(), false);
if (ret < 0) { if (ret < 0) {
set_err_msg(err_msg, "unable to store user info"); set_err_msg(err_msg, "unable to store user info");
return ret; return ret;
@ -1815,7 +1815,7 @@ int RGWUser::update(RGWUserAdminOpState& op_state, std::string *err_msg)
return ret; return ret;
} }
} else { } else {
ret = rgw_store_user_info(store, user_info, NULL, &op_state.objv, 0, false); ret = rgw_store_user_info(store, user_info, NULL, &op_state.objv, real_time(), false);
if (ret < 0) { if (ret < 0) {
set_err_msg(err_msg, "unable to store user info"); set_err_msg(err_msg, "unable to store user info");
return ret; return ret;
@ -2569,7 +2569,7 @@ struct RGWUserCompleteInfo {
class RGWUserMetadataObject : public RGWMetadataObject { class RGWUserMetadataObject : public RGWMetadataObject {
RGWUserCompleteInfo uci; RGWUserCompleteInfo uci;
public: public:
RGWUserMetadataObject(const RGWUserCompleteInfo& _uci, obj_version& v, time_t m) RGWUserMetadataObject(const RGWUserCompleteInfo& _uci, obj_version& v, real_time m)
: uci(_uci) { : uci(_uci) {
objv = v; objv = v;
mtime = m; mtime = m;
@ -2587,7 +2587,7 @@ public:
int get(RGWRados *store, string& entry, RGWMetadataObject **obj) { int get(RGWRados *store, string& entry, RGWMetadataObject **obj) {
RGWUserCompleteInfo uci; RGWUserCompleteInfo uci;
RGWObjVersionTracker objv_tracker; RGWObjVersionTracker objv_tracker;
time_t mtime; real_time mtime;
rgw_user uid(entry); rgw_user uid(entry);
@ -2604,7 +2604,7 @@ public:
} }
int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker, int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker,
time_t mtime, JSONObj *obj, sync_type_t sync_mode) { real_time mtime, JSONObj *obj, sync_type_t sync_mode) {
RGWUserCompleteInfo uci; RGWUserCompleteInfo uci;
try { try {
@ -2621,7 +2621,7 @@ public:
rgw_user uid(entry); rgw_user uid(entry);
RGWUserInfo old_info; RGWUserInfo old_info;
time_t orig_mtime; real_time orig_mtime;
int ret = rgw_get_user_info_by_uid(store, uid, old_info, &objv_tracker, &orig_mtime); int ret = rgw_get_user_info_by_uid(store, uid, old_info, &objv_tracker, &orig_mtime);
if (ret < 0 && ret != -ENOENT) if (ret < 0 && ret != -ENOENT)
return ret; return ret;

View File

@ -63,7 +63,7 @@ extern int rgw_store_user_info(RGWRados *store,
RGWUserInfo& info, RGWUserInfo& info,
RGWUserInfo *old_info, RGWUserInfo *old_info,
RGWObjVersionTracker *objv_tracker, RGWObjVersionTracker *objv_tracker,
time_t mtime, real_time mtime,
bool exclusive, bool exclusive,
map<string, bufferlist> *pattrs = NULL); map<string, bufferlist> *pattrs = NULL);
@ -75,7 +75,7 @@ extern int rgw_get_user_info_by_uid(RGWRados *store,
const rgw_user& user_id, const rgw_user& user_id,
RGWUserInfo& info, RGWUserInfo& info,
RGWObjVersionTracker *objv_tracker = NULL, RGWObjVersionTracker *objv_tracker = NULL,
time_t *pmtime = NULL, real_time *pmtime = NULL,
rgw_cache_entry_info *cache_info = NULL, rgw_cache_entry_info *cache_info = NULL,
map<string, bufferlist> *pattrs = NULL); map<string, bufferlist> *pattrs = NULL);
/** /**
@ -83,19 +83,19 @@ extern int rgw_get_user_info_by_uid(RGWRados *store,
* returns: 0 on success, -ERR# on failure (including nonexistence) * returns: 0 on success, -ERR# on failure (including nonexistence)
*/ */
extern int rgw_get_user_info_by_email(RGWRados *store, string& email, RGWUserInfo& info, extern int rgw_get_user_info_by_email(RGWRados *store, string& email, RGWUserInfo& info,
RGWObjVersionTracker *objv_tracker = NULL, time_t *pmtime = NULL); RGWObjVersionTracker *objv_tracker = NULL, real_time *pmtime = NULL);
/** /**
* Given an swift username, finds the user info associated with it. * Given an swift username, finds the user info associated with it.
* returns: 0 on success, -ERR# on failure (including nonexistence) * returns: 0 on success, -ERR# on failure (including nonexistence)
*/ */
extern int rgw_get_user_info_by_swift(RGWRados *store, string& swift_name, RGWUserInfo& info, extern int rgw_get_user_info_by_swift(RGWRados *store, string& swift_name, RGWUserInfo& info,
RGWObjVersionTracker *objv_tracker = NULL, time_t *pmtime = NULL); RGWObjVersionTracker *objv_tracker = NULL, real_time *pmtime = NULL);
/** /**
* Given an access key, finds the user info associated with it. * Given an access key, finds the user info associated with it.
* returns: 0 on success, -ERR# on failure (including nonexistence) * returns: 0 on success, -ERR# on failure (including nonexistence)
*/ */
extern int rgw_get_user_info_by_access_key(RGWRados *store, string& access_key, RGWUserInfo& info, extern int rgw_get_user_info_by_access_key(RGWRados *store, string& access_key, RGWUserInfo& info,
RGWObjVersionTracker *objv_tracker = NULL, time_t *pmtime = NULL); RGWObjVersionTracker *objv_tracker = NULL, real_time *pmtime = NULL);
/** /**
* Get all the custom metadata stored for user specified in @user_id * Get all the custom metadata stored for user specified in @user_id
* and put it into @attrs. * and put it into @attrs.