Skip to content

Commit

Permalink
time: Update OSDC for C++11 Time
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam C. Emerson committed Sep 10, 2015
1 parent b29fb0f commit 504885f
Show file tree
Hide file tree
Showing 34 changed files with 468 additions and 419 deletions.
59 changes: 31 additions & 28 deletions src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7091,13 +7091,13 @@ int Client::uninline_data(Inode *in, Context *onfinish)
create_ops.create(false);

objecter->mutate(oid,
OSDMap::file_to_object_locator(in->layout),
create_ops,
in->snaprealm->get_snap_context(),
ceph_clock_now(cct),
0,
NULL,
NULL);
OSDMap::file_to_object_locator(in->layout),
create_ops,
in->snaprealm->get_snap_context(),
ceph::real_clock::now(cct),
0,
NULL,
NULL);

bufferlist inline_version_bl;
::encode(in->inline_version, inline_version_bl);
Expand All @@ -7112,13 +7112,13 @@ int Client::uninline_data(Inode *in, Context *onfinish)
uninline_ops.setxattr("inline_version", stringify(in->inline_version));

objecter->mutate(oid,
OSDMap::file_to_object_locator(in->layout),
uninline_ops,
in->snaprealm->get_snap_context(),
ceph_clock_now(cct),
0,
NULL,
onfinish);
OSDMap::file_to_object_locator(in->layout),
uninline_ops,
in->snaprealm->get_snap_context(),
ceph::real_clock::now(cct),
0,
NULL,
onfinish);

return 0;
}
Expand Down Expand Up @@ -7660,8 +7660,10 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf,
get_cap_ref(in, CEPH_CAP_FILE_BUFFER);

// async, caching, non-blocking.
r = objectcacher->file_write(&in->oset, &in->layout, in->snaprealm->get_snap_context(),
offset, size, bl, ceph_clock_now(cct), 0);
r = objectcacher->file_write(&in->oset, &in->layout,
in->snaprealm->get_snap_context(),
offset, size, bl, ceph::real_clock::now(cct),
0);
put_cap_ref(in, CEPH_CAP_FILE_BUFFER);

if (r < 0)
Expand All @@ -7685,7 +7687,7 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf,
get_cap_ref(in, CEPH_CAP_FILE_BUFFER); // released by onsafe callback

r = filer->write_trunc(in->ino, &in->layout, in->snaprealm->get_snap_context(),
offset, size, bl, ceph_clock_now(cct), 0,
offset, size, bl, ceph::real_clock::now(cct), 0,
in->truncate_size, in->truncate_seq,
onfinish, new C_OnFinisher(onsafe, &objecter_finisher));
if (r < 0)
Expand Down Expand Up @@ -10323,7 +10325,7 @@ int Client::ll_write_block(Inode *in, uint64_t blockid,
length,
fakesnap,
bl,
ceph_clock_now(cct),
ceph::real_clock::now(cct),
0,
onack,
onsafe);
Expand Down Expand Up @@ -10489,12 +10491,13 @@ int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length)

_invalidate_inode_cache(in, offset, length);
r = filer->zero(in->ino, &in->layout,
in->snaprealm->get_snap_context(),
offset, length,
ceph_clock_now(cct),
0, true, onfinish, new C_OnFinisher(onsafe, &objecter_finisher));
in->snaprealm->get_snap_context(),
offset, length,
ceph::real_clock::now(cct),
0, true, onfinish,
new C_OnFinisher(onsafe, &objecter_finisher));
if (r < 0)
goto done;
goto done;

in->mtime = ceph_clock_now(cct);
mark_caps_dirty(in, CEPH_CAP_FILE_WR);
Expand Down Expand Up @@ -11107,19 +11110,19 @@ int Client::check_pool_perm(Inode *in, int need)

C_SaferCond rd_cond;
ObjectOperation rd_op;
rd_op.stat(NULL, (utime_t*)NULL, NULL);
rd_op.stat(NULL, (ceph::real_time*)nullptr, NULL);

objecter->mutate(oid, OSDMap::file_to_object_locator(in->layout), rd_op,
in->snaprealm->get_snap_context(), ceph_clock_now(cct), 0,
&rd_cond, NULL);
in->snaprealm->get_snap_context(),
ceph::real_clock::now(cct), 0, &rd_cond, NULL);

C_SaferCond wr_cond;
ObjectOperation wr_op;
wr_op.create(true);

objecter->mutate(oid, OSDMap::file_to_object_locator(in->layout), wr_op,
in->snaprealm->get_snap_context(), ceph_clock_now(cct), 0,
&wr_cond, NULL);
in->snaprealm->get_snap_context(),
ceph::real_clock::now(cct), 0, &wr_cond, NULL);

client_lock.Unlock();
int rd_ret = rd_cond.wait();
Expand Down
5 changes: 3 additions & 2 deletions src/client/ObjecterWriteback.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ class ObjecterWriteback : public WritebackHandler {

virtual ceph_tid_t write(const object_t& oid, const object_locator_t& oloc,
uint64_t off, uint64_t len, const SnapContext& snapc,
const bufferlist &bl, utime_t mtime, uint64_t trunc_size,
__u32 trunc_seq, Context *oncommit) {
const bufferlist &bl, ceph::real_time mtime,
uint64_t trunc_size, __u32 trunc_seq,
Context *oncommit) {
return m_objecter->write_trunc(oid, oloc, off, len, snapc, bl, mtime, 0,
trunc_size, trunc_seq, NULL,
new C_OnFinisher(new C_Lock(m_lock, oncommit),
Expand Down
18 changes: 11 additions & 7 deletions src/client/SyntheticClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
lock.Lock();
object_locator_t oloc(SYNCLIENT_FIRST_POOL);
uint64_t size;
utime_t mtime;
ceph::real_time mtime;
client->objecter->stat(oid, oloc, CEPH_NOSNAP, &size, &mtime, 0, new C_SafeCond(&lock, &cond, &ack));
while (!ack) cond.Wait(lock);
lock.Unlock();
Expand Down Expand Up @@ -1471,7 +1471,8 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
bufferlist bl;
bl.push_back(bp);
SnapContext snapc;
client->objecter->write(oid, oloc, off, len, snapc, bl, ceph_clock_now(client->cct), 0,
client->objecter->write(oid, oloc, off, len, snapc, bl,
ceph::real_clock::now(client->cct), 0,
new C_SafeCond(&lock, &cond, &ack),
safeg.new_sub());
safeg.activate();
Expand All @@ -1487,7 +1488,8 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only)
object_locator_t oloc(SYNCLIENT_FIRST_POOL);
lock.Lock();
SnapContext snapc;
client->objecter->zero(oid, oloc, off, len, snapc, ceph_clock_now(client->cct), 0,
client->objecter->zero(oid, oloc, off, len, snapc,
ceph::real_clock::now(client->cct), 0,
new C_SafeCond(&lock, &cond, &ack),
safeg.new_sub());
safeg.activate();
Expand Down Expand Up @@ -1636,7 +1638,7 @@ int SyntheticClient::full_walk(string& basedir)
actual.nsubdirs++;
else
actual.nfiles++;

// print
char *tm = ctime(&st.st_mtime);
tm[strlen(tm)-1] = 0;
Expand Down Expand Up @@ -2264,10 +2266,11 @@ int SyntheticClient::create_objects(int nobj, int osize, int inflight)
dout(6) << "create_objects " << i << "/" << (nobj+1) << dendl;
}
dout(10) << "writing " << oid << dendl;

starts.push_back(ceph_clock_now(client->cct));
client->client_lock.Lock();
client->objecter->write(oid, oloc, 0, osize, snapc, bl, ceph_clock_now(client->cct), 0,
client->objecter->write(oid, oloc, 0, osize, snapc, bl,
ceph::real_clock::now(client->cct), 0,
new C_Ref(lock, cond, &unack),
new C_Ref(lock, cond, &unsafe));
client->client_lock.Unlock();
Expand Down Expand Up @@ -2370,7 +2373,8 @@ int SyntheticClient::object_rw(int nobj, int osize, int wrpc,
op.op.extent.length = osize;
op.indata = bl;
m.ops.push_back(op);
client->objecter->mutate(oid, oloc, m, snapc, ceph_clock_now(client->cct), 0,
client->objecter->mutate(oid, oloc, m, snapc,
ceph::real_clock::now(client->cct), 0,
NULL, new C_Ref(lock, cond, &unack));
} else {
dout(10) << "read from " << oid << dendl;
Expand Down
53 changes: 27 additions & 26 deletions src/librados/IoCtxImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#undef dout_prefix
#define dout_prefix *_dout << "librados: "

using ceph::real_time;
using ceph::real_clock;

librados::IoCtxImpl::IoCtxImpl() :
ref_cnt(0), client(NULL), poolid(0), assert_ver(0), last_objver(0),
notify_timeout(30), aio_write_list_lock("librados::IoCtxImpl::aio_write_list_lock"),
Expand Down Expand Up @@ -233,7 +236,6 @@ int librados::IoCtxImpl::selfmanaged_snap_rollback_object(const object_t& oid,
::SnapContext& snapc,
uint64_t snapid)
{
utime_t ut = ceph_clock_now(client->cct);
int reply;

Mutex mylock("IoCtxImpl::snap_rollback::mylock");
Expand All @@ -245,8 +247,8 @@ int librados::IoCtxImpl::selfmanaged_snap_rollback_object(const object_t& oid,
prepare_assert_ops(&op);
op.rollback(snapid);
objecter->mutate(oid, oloc,
op, snapc, ut, 0,
onack, NULL, NULL);
op, snapc, ceph::real_clock::now(client->cct), 0,
onack, NULL, NULL);

mylock.Lock();
while (!done) cond.Wait(mylock);
Expand Down Expand Up @@ -491,12 +493,10 @@ int librados::IoCtxImpl::clone_range(const object_t& dst_oid,
int librados::IoCtxImpl::operate(const object_t& oid, ::ObjectOperation *o,
time_t *pmtime, int flags)
{
utime_t ut;
if (pmtime) {
ut = utime_t(*pmtime, 0);
} else {
ut = ceph_clock_now(client->cct);
}
ceph::real_time ut =
pmtime ?
ceph::real_clock::from_time_t(*pmtime) :
ceph::real_clock::now(client->cct);

/* can't write to a snapshot */
if (snap_seq != CEPH_NOSNAP)
Expand All @@ -516,8 +516,8 @@ int librados::IoCtxImpl::operate(const object_t& oid, ::ObjectOperation *o,
int op = o->ops[0].op.op;
ldout(client->cct, 10) << ceph_osd_op_name(op) << " oid=" << oid << " nspace=" << oloc.nspace << dendl;
Objecter::Op *objecter_op = objecter->prepare_mutate_op(oid, oloc,
*o, snapc, ut, flags,
NULL, oncommit, &ver);
*o, snapc, ut, flags,
NULL, oncommit, &ver);
objecter->op_submit(objecter_op);

mylock.Lock();
Expand Down Expand Up @@ -589,7 +589,7 @@ int librados::IoCtxImpl::aio_operate(const object_t& oid,
::ObjectOperation *o, AioCompletionImpl *c,
const SnapContext& snap_context, int flags)
{
utime_t ut = ceph_clock_now(client->cct);
auto ut = ceph::real_clock::now(client->cct);
/* can't write to a snapshot */
if (snap_seq != CEPH_NOSNAP)
return -EROFS;
Expand All @@ -600,8 +600,8 @@ int librados::IoCtxImpl::aio_operate(const object_t& oid,
c->io = this;
queue_aio_write(c);

c->tid = objecter->mutate(oid, oloc, *o, snap_context, ut, flags, onack, oncommit,
&c->objver);
c->tid = objecter->mutate(oid, oloc, *o, snap_context, ut, flags, onack,
oncommit, &c->objver);

return 0;
}
Expand Down Expand Up @@ -685,7 +685,7 @@ int librados::IoCtxImpl::aio_write(const object_t &oid, AioCompletionImpl *c,
const bufferlist& bl, size_t len,
uint64_t off)
{
utime_t ut = ceph_clock_now(client->cct);
auto ut = ceph::real_clock::now(client->cct);
ldout(client->cct, 20) << "aio_write " << oid << " " << off << "~" << len << " snapc=" << snapc << " snap_seq=" << snap_seq << dendl;

if (len > UINT_MAX/2)
Expand All @@ -710,7 +710,7 @@ int librados::IoCtxImpl::aio_write(const object_t &oid, AioCompletionImpl *c,
int librados::IoCtxImpl::aio_append(const object_t &oid, AioCompletionImpl *c,
const bufferlist& bl, size_t len)
{
utime_t ut = ceph_clock_now(client->cct);
auto ut = ceph::real_clock::now(client->cct);

if (len > UINT_MAX/2)
return -E2BIG;
Expand All @@ -735,7 +735,7 @@ int librados::IoCtxImpl::aio_write_full(const object_t &oid,
AioCompletionImpl *c,
const bufferlist& bl)
{
utime_t ut = ceph_clock_now(client->cct);
auto ut = ceph::real_clock::now(client->cct);

if (bl.length() > UINT_MAX/2)
return -E2BIG;
Expand All @@ -758,7 +758,7 @@ int librados::IoCtxImpl::aio_write_full(const object_t &oid,

int librados::IoCtxImpl::aio_remove(const object_t &oid, AioCompletionImpl *c)
{
utime_t ut = ceph_clock_now(client->cct);
auto ut = ceph::real_clock::now(client->cct);

/* can't write to a snapshot */
if (snap_seq != CEPH_NOSNAP)
Expand All @@ -785,8 +785,8 @@ int librados::IoCtxImpl::aio_stat(const object_t& oid, AioCompletionImpl *c,

c->io = this;
c->tid = objecter->stat(oid, oloc,
snap_seq, psize, &onack->mtime, 0,
onack, &c->objver);
snap_seq, psize, &onack->mtime, 0,
onack, &c->objver);

return 0;
}
Expand Down Expand Up @@ -820,7 +820,7 @@ int librados::IoCtxImpl::hit_set_get(uint32_t hash, AioCompletionImpl *c,
c->io = this;

::ObjectOperation rd;
rd.hit_set_get(utime_t(stamp, 0), pbl, 0);
rd.hit_set_get(ceph::real_clock::from_time_t(stamp), pbl, 0);
object_locator_t oloc(poolid);
c->tid = objecter->pg_read(hash, oloc, rd, NULL, 0, onack, NULL, NULL);
return 0;
Expand Down Expand Up @@ -975,7 +975,7 @@ int librados::IoCtxImpl::sparse_read(const object_t& oid,
int librados::IoCtxImpl::stat(const object_t& oid, uint64_t *psize, time_t *pmtime)
{
uint64_t size;
utime_t mtime;
real_time mtime;

if (!psize)
psize = &size;
Expand All @@ -986,7 +986,7 @@ int librados::IoCtxImpl::stat(const object_t& oid, uint64_t *psize, time_t *pmti
int r = operate_read(oid, &rd, NULL);

if (r >= 0 && pmtime) {
*pmtime = mtime.sec();
*pmtime = real_clock::to_time_t(mtime);
}

return r;
Expand Down Expand Up @@ -1110,7 +1110,7 @@ int librados::IoCtxImpl::watch(const object_t& oid,
wr.watch(*handle, CEPH_OSD_WATCH_OP_WATCH);
bufferlist bl;
objecter->linger_watch(linger_op, wr,
snapc, ceph_clock_now(NULL), bl,
snapc, ceph::real_clock::now(), bl,
&onfinish,
&objver);

Expand Down Expand Up @@ -1156,7 +1156,8 @@ int librados::IoCtxImpl::unwatch(uint64_t cookie)
prepare_assert_ops(&wr);
wr.watch(cookie, CEPH_OSD_WATCH_OP_UNWATCH);
objecter->mutate(linger_op->target.base_oid, oloc, wr,
snapc, ceph_clock_now(client->cct), 0, NULL, &onfinish, &ver);
snapc, ceph::real_clock::now(client->cct), 0, NULL,
&onfinish, &ver);
objecter->linger_cancel(linger_op);

int r = onfinish.wait();
Expand Down Expand Up @@ -1344,7 +1345,7 @@ void librados::IoCtxImpl::C_aio_stat_Ack::finish(int r)
c->cond.Signal();

if (r >= 0 && pmtime) {
*pmtime = mtime.sec();
*pmtime = real_clock::to_time_t(mtime);
}

if (c->callback_complete) {
Expand Down
2 changes: 1 addition & 1 deletion src/librados/IoCtxImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ struct librados::IoCtxImpl {
struct C_aio_stat_Ack : public Context {
librados::AioCompletionImpl *c;
time_t *pmtime;
utime_t mtime;
ceph::real_time mtime;
C_aio_stat_Ack(AioCompletionImpl *_c, time_t *pm);
void finish(int r);
};
Expand Down

0 comments on commit 504885f

Please sign in to comment.