Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

common: new timekeeping common code, and Objecter conversion #5782

Merged
merged 6 commits into from
Dec 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ set(libcommon_files
common/escape.c
common/io_priority.cc
common/Clock.cc
common/ceph_time.cc
common/Throttle.cc
common/Timer.cc
common/Finisher.cc
Expand Down
55 changes: 29 additions & 26 deletions src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7333,13 +7333,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 @@ -7354,13 +7354,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 @@ -7902,8 +7902,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 @@ -7927,7 +7929,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 @@ -10577,7 +10579,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 @@ -10743,12 +10745,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 @@ -11375,17 +11378,17 @@ 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,
nullsnapc, ceph_clock_now(cct), 0, &rd_cond, NULL);
nullsnapc, 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,
nullsnapc, ceph_clock_now(cct), 0, &wr_cond, NULL);
nullsnapc, ceph::real_clock::now(cct), 0, &wr_cond, NULL);

client_lock.Unlock();
int rd_ret = rd_cond.wait();
Expand Down
12 changes: 7 additions & 5 deletions src/client/ObjecterWriteback.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ 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,
ceph_tid_t journal_tid, Context *oncommit) {
uint64_t off, uint64_t len,
const SnapContext& snapc, const bufferlist &bl,
ceph::real_time mtime, uint64_t trunc_size,
__u32 trunc_seq, ceph_tid_t journal_tid,
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),
new C_OnFinisher(new C_Lock(m_lock,
oncommit),
m_finisher));
}

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
30 changes: 23 additions & 7 deletions src/common/Cond.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
Expand All @@ -7,23 +7,24 @@
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*
*/


#ifndef CEPH_COND_H
#define CEPH_COND_H

#include <time.h>

#include "Mutex.h"
#include "Clock.h"
#include <pthread.h>

#include "include/Context.h"

#include <pthread.h>
#include "common/ceph_time.h"
#include "common/Mutex.h"
#include "common/Clock.h"


class Cond {
// my bits
Expand Down Expand Up @@ -73,12 +74,27 @@ class Cond {

return r;
}

int WaitInterval(CephContext *cct, Mutex &mutex, utime_t interval) {
utime_t when = ceph_clock_now(cct);
when += interval;
return WaitUntil(mutex, when);
}

template<typename Duration>
int WaitInterval(CephContext *cct, Mutex &mutex, Duration interval) {
ceph::real_time when(ceph::real_clock::now(cct));
when += interval;

struct timespec ts = ceph::real_clock::to_timespec(when);

mutex._pre_unlock();
int r = pthread_cond_timedwait(&_c, &mutex._m, &ts);
mutex._post_lock();

return r;
}

int SloppySignal() {
int r = pthread_cond_broadcast(&_c);
return r;
Expand Down
5 changes: 4 additions & 1 deletion src/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ libcommon_internal_la_SOURCES = \
common/cmdparse.cc \
common/escape.c \
common/io_priority.cc \
common/ceph_time.cc \
common/Clock.cc \
common/Throttle.cc \
common/Timer.cc \
Expand Down Expand Up @@ -263,7 +264,9 @@ noinst_HEADERS += \
common/valgrind.h \
common/TracepointProvider.h \
common/event_socket.h \
common/PluginRegistry.h
common/PluginRegistry.h \
common/ceph_time.h \
common/ceph_timer.h

if ENABLE_XIO
noinst_HEADERS += \
Expand Down