Skip to content
This repository has been archived by the owner on Dec 28, 2022. It is now read-only.

Commit

Permalink
Convert g_ceph_context to a pointer.
Browse files Browse the repository at this point in the history
Signed-off-by: Colin McCabe <[email protected]>
  • Loading branch information
cmccabe committed Jun 21, 2011
1 parent 89dca91 commit 112e569
Show file tree
Hide file tree
Showing 100 changed files with 542 additions and 548 deletions.
10 changes: 5 additions & 5 deletions src/cauthtool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main(int argc, const char **argv)

global_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY,
CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
common_init_finish(&g_ceph_context);
common_init_finish(g_ceph_context);
EntityName ename(g_conf->name);

const char *me = argv[0];
Expand Down Expand Up @@ -130,7 +130,7 @@ int main(int argc, const char **argv)

if (gen_print_key) {
CryptoKey key;
key.create(&g_ceph_context, CEPH_CRYPTO_AES);
key.create(g_ceph_context, CEPH_CRYPTO_AES);
cout << key << std::endl;
return 0;
}
Expand Down Expand Up @@ -178,7 +178,7 @@ int main(int argc, const char **argv)

cout << "importing contents of " << import_keyring << " into " << fn << std::endl;
//other.print(cout);
keyring.import(&g_ceph_context, other);
keyring.import(g_ceph_context, other);
modified = true;
} else {
cerr << "can't open " << import_keyring << ": " << err << std::endl;
Expand All @@ -187,7 +187,7 @@ int main(int argc, const char **argv)
}
if (gen_key) {
EntityAuth eauth;
eauth.key.create(&g_ceph_context, CEPH_CRYPTO_AES);
eauth.key.create(g_ceph_context, CEPH_CRYPTO_AES);
keyring.add(ename, eauth);
modified = true;
}
Expand All @@ -211,7 +211,7 @@ int main(int argc, const char **argv)
cerr << "could not parse caps file " << caps_fn << std::endl;
exit(1);
}
complain_about_parse_errors(&g_ceph_context, &parse_errors);
complain_about_parse_errors(g_ceph_context, &parse_errors);
map<string, bufferlist> caps;
const char *key_names[] = { "mon", "osd", "mds", NULL };
for (int i=0; key_names[i]; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/cconf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
global_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(&g_ceph_context);
common_init_finish(g_ceph_context);

std::string val;
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
Expand Down
6 changes: 3 additions & 3 deletions src/cfuse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int main(int argc, const char **argv, const char *envp[]) {
}

// get monmap
MonClient mc(&g_ceph_context);
MonClient mc(g_ceph_context);
int ret = mc.build_initial_monmap();
if (ret == -EINVAL)
usage();
Expand All @@ -90,7 +90,7 @@ int main(int argc, const char **argv, const char *envp[]) {
return -1;

// start up network
SimpleMessenger *messenger = new SimpleMessenger(&g_ceph_context);
SimpleMessenger *messenger = new SimpleMessenger(g_ceph_context);
messenger->register_entity(entity_name_t::CLIENT());
Client *client = new Client(messenger, &mc);
if (filer_flags) {
Expand All @@ -110,7 +110,7 @@ int main(int argc, const char **argv, const char *envp[]) {
childpid = fork();
}

common_init_finish(&g_ceph_context);
common_init_finish(g_ceph_context);

if (childpid == 0) {
//cout << "child, mounting" << std::endl;
Expand Down
50 changes: 25 additions & 25 deletions src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void Client::init()
char hostname[80];
gethostname(hostname, 79);
snprintf(s, sizeof(s), "clients.%s.%d", hostname, getpid());
client_logger = new ProfLogger(&g_ceph_context, s, &client_logtype);
client_logger = new ProfLogger(g_ceph_context, s, &client_logtype);
}
client_logger_lock.Unlock();
}
Expand Down Expand Up @@ -961,7 +961,7 @@ int Client::make_request(MetaRequest *request,
bufferlist *pdirbl)
{
// time the call
utime_t start = ceph_clock_now(&g_ceph_context);
utime_t start = ceph_clock_now(g_ceph_context);

bool nojournal = false;
int op = request->get_op();
Expand Down Expand Up @@ -1066,7 +1066,7 @@ int Client::make_request(MetaRequest *request,

// -- log times --
if (client_logger) {
utime_t lat = ceph_clock_now(&g_ceph_context);
utime_t lat = ceph_clock_now(g_ceph_context);
lat -= request->sent_stamp;
dout(20) << "lat " << lat << dendl;
client_logger->favg(l_c_lat,(double)lat);
Expand Down Expand Up @@ -1249,7 +1249,7 @@ void Client::send_request(MetaRequest *request, int mds)
r->releases = request->cap_releases;

if (request->mds == -1) {
request->sent_stamp = ceph_clock_now(&g_ceph_context);
request->sent_stamp = ceph_clock_now(g_ceph_context);
dout(20) << "send_request set sent_stamp to " << request->sent_stamp << dendl;
}
request->mds = mds;
Expand Down Expand Up @@ -1504,7 +1504,7 @@ void Client::handle_mds_map(MMDSMap* m)
dout(1) << "handle_mds_map epoch " << m->get_epoch() << dendl;

MDSMap *oldmap = mdsmap;
mdsmap = new MDSMap(&g_ceph_context);
mdsmap = new MDSMap(g_ceph_context);
mdsmap->decode(m->get_encoded());

// reset session
Expand Down Expand Up @@ -1691,7 +1691,7 @@ void Client::handle_lease(MClientLease *m)

void Client::release_lease(Inode *in, Dentry *dn, int mask)
{
utime_t now = ceph_clock_now(&g_ceph_context);
utime_t now = ceph_clock_now(g_ceph_context);

assert(dn);

Expand Down Expand Up @@ -1846,7 +1846,7 @@ int Client::get_caps(Inode *in, int need, int want, int *got, loff_t endoff)
void Client::cap_delay_requeue(Inode *in)
{
dout(10) << "cap_delay_requeue on " << *in << dendl;
in->hold_caps_until = ceph_clock_now(&g_ceph_context);
in->hold_caps_until = ceph_clock_now(g_ceph_context);
in->hold_caps_until += 5.0;

delayed_caps.push_back(&in->cap_item);
Expand Down Expand Up @@ -1956,7 +1956,7 @@ void Client::check_caps(Inode *in, bool is_delayed)
else
in->hold_caps_until = utime_t();

utime_t now = ceph_clock_now(&g_ceph_context);
utime_t now = ceph_clock_now(g_ceph_context);

map<int,InodeCap*>::iterator it = in->caps.begin();
while (it != in->caps.end()) {
Expand Down Expand Up @@ -3190,7 +3190,7 @@ void Client::tick()
tick_event = new C_C_Tick(this);
timer.add_event_after(g_conf->client_tick_interval, tick_event);

utime_t now = ceph_clock_now(&g_ceph_context);
utime_t now = ceph_clock_now(g_ceph_context);

if (mdsmap->get_epoch()) {
// renew caps?
Expand Down Expand Up @@ -3226,7 +3226,7 @@ void Client::tick()
void Client::renew_caps()
{
dout(10) << "renew_caps()" << dendl;
last_cap_renew = ceph_clock_now(&g_ceph_context);
last_cap_renew = ceph_clock_now(g_ceph_context);

for (map<int,MDSSession*>::iterator p = mds_sessions.begin();
p != mds_sessions.end();
Expand All @@ -3240,7 +3240,7 @@ void Client::renew_caps()
void Client::renew_caps(const int mds) {
dout(10) << "renew_caps mds" << mds << dendl;
MDSSession *session = mds_sessions[mds];
session->last_cap_renew_request = ceph_clock_now(&g_ceph_context);
session->last_cap_renew_request = ceph_clock_now(g_ceph_context);
uint64_t seq = ++session->cap_renew_seq;
messenger->send_message(new MClientSession(CEPH_SESSION_REQUEST_RENEWCAPS, seq),
mdsmap->get_inst(mds));
Expand Down Expand Up @@ -3310,7 +3310,7 @@ int Client::_lookup(Inode *dir, const string& dname, Inode **target)
<< dendl;

// is dn lease valid?
utime_t now = ceph_clock_now(&g_ceph_context);
utime_t now = ceph_clock_now(g_ceph_context);
if (dn->lease_mds >= 0 &&
dn->lease_ttl > now &&
mds_sessions.count(dn->lease_mds)) {
Expand Down Expand Up @@ -3357,7 +3357,7 @@ int Client::get_or_create(Inode *dir, const char* name,
Dentry *dn = *pdn = dir->dir->dentries[name];

// is dn lease valid?
utime_t now = ceph_clock_now(&g_ceph_context);
utime_t now = ceph_clock_now(g_ceph_context);
if (dn->inode &&
dn->lease_mds >= 0 &&
dn->lease_ttl > now &&
Expand Down Expand Up @@ -3673,7 +3673,7 @@ int Client::_setattr(Inode *in, struct stat *attr, int mask, int uid, int gid)

if (!mask) {
// caller just needs us to bump the ctime
in->ctime = ceph_clock_now(&g_ceph_context);
in->ctime = ceph_clock_now(g_ceph_context);
if (issued & CEPH_CAP_AUTH_EXCL)
mark_caps_dirty(in, CEPH_CAP_AUTH_EXCL);
else if (issued & CEPH_CAP_FILE_EXCL)
Expand All @@ -3686,19 +3686,19 @@ int Client::_setattr(Inode *in, struct stat *attr, int mask, int uid, int gid)

if (in->caps_issued_mask(CEPH_CAP_AUTH_EXCL)) {
if (mask & CEPH_SETATTR_MODE) {
in->ctime = ceph_clock_now(&g_ceph_context);
in->ctime = ceph_clock_now(g_ceph_context);
in->mode = (in->mode & ~07777) | (attr->st_mode & 07777);
mark_caps_dirty(in, CEPH_CAP_AUTH_EXCL);
mask &= ~CEPH_SETATTR_MODE;
}
if (mask & CEPH_SETATTR_UID) {
in->ctime = ceph_clock_now(&g_ceph_context);
in->ctime = ceph_clock_now(g_ceph_context);
in->uid = attr->st_uid;
mark_caps_dirty(in, CEPH_CAP_AUTH_EXCL);
mask &= ~CEPH_SETATTR_UID;
}
if (mask & CEPH_SETATTR_GID) {
in->ctime = ceph_clock_now(&g_ceph_context);
in->ctime = ceph_clock_now(g_ceph_context);
in->gid = attr->st_gid;
mark_caps_dirty(in, CEPH_CAP_AUTH_EXCL);
mask &= ~CEPH_SETATTR_GID;
Expand All @@ -3710,7 +3710,7 @@ int Client::_setattr(Inode *in, struct stat *attr, int mask, int uid, int gid)
in->mtime = utime_t(attr->st_mtim.tv_sec, attr->st_mtim.tv_nsec);
if (mask & CEPH_SETATTR_ATIME)
in->atime = utime_t(attr->st_atim.tv_sec, attr->st_atim.tv_nsec);
in->ctime = ceph_clock_now(&g_ceph_context);
in->ctime = ceph_clock_now(g_ceph_context);
in->time_warp_seq++;
mark_caps_dirty(in, CEPH_CAP_FILE_EXCL);
mask &= ~(CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME);
Expand Down Expand Up @@ -5055,7 +5055,7 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf)
dout(10) << "cur file size is " << in->size << dendl;

// time it.
utime_t start = ceph_clock_now(&g_ceph_context);
utime_t start = ceph_clock_now(g_ceph_context);

// copy into fresh buffer (since our write may be resub, async)
bufferptr bp;
Expand Down Expand Up @@ -5083,14 +5083,14 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf)

// async, caching, non-blocking.
objectcacher->file_write(&in->oset, &in->layout, in->snaprealm->get_snap_context(),
offset, size, bl, ceph_clock_now(&g_ceph_context), 0);
offset, size, bl, ceph_clock_now(g_ceph_context), 0);

put_cap_ref(in, CEPH_CAP_FILE_BUFFER);
} else {
/*
// atomic, synchronous, blocking.
objectcacher->file_atomic_sync_write(in->ino, &in->layout, in->snaprealm->get_snap_context(),
offset, size, bl, ceph_clock_now(&g_ceph_context), 0, client_lock);
offset, size, bl, ceph_clock_now(g_ceph_context), 0, client_lock);
*/
// simple, non-atomic sync write
Mutex flock("Client::_write flock");
Expand All @@ -5103,7 +5103,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

filer->write_trunc(in->ino, &in->layout, in->snaprealm->get_snap_context(),
offset, size, bl, ceph_clock_now(&g_ceph_context), filer_flags,
offset, size, bl, ceph_clock_now(g_ceph_context), filer_flags,
in->truncate_size, in->truncate_seq,
onfinish, onsafe);

Expand All @@ -5112,7 +5112,7 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf)
}

// time
utime_t lat = ceph_clock_now(&g_ceph_context);
utime_t lat = ceph_clock_now(g_ceph_context);
lat -= start;
if (client_logger)
client_logger->favg(l_c_wrlat,(double)lat);
Expand All @@ -5135,7 +5135,7 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf)
}

// mtime
in->mtime = ceph_clock_now(&g_ceph_context);
in->mtime = ceph_clock_now(g_ceph_context);
mark_caps_dirty(in, CEPH_CAP_FILE_WR);

put_cap_ref(in, CEPH_CAP_FILE_WR);
Expand Down Expand Up @@ -5474,7 +5474,7 @@ int Client::ll_lookup(vinodeno_t parent, const char *name, struct stat *attr, in
Inode *diri = 0;
Inode *in = 0;
int r = 0;
utime_t now = ceph_clock_now(&g_ceph_context);
utime_t now = ceph_clock_now(g_ceph_context);

if (inode_map.count(parent) == 0) {
dout(1) << "ll_lookup " << parent << " " << name << " -> ENOENT (parent DNE... WTF)" << dendl;
Expand Down
4 changes: 2 additions & 2 deletions src/client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ class Inode {
/*cout << "cap_gen " << cap->session-> cap_gen << std::endl
<< "session gen " << cap->gen << std::endl
<< "cap expire " << cap->session->cap_ttl << std::endl
<< "cur time " << ceph_clock_now(&g_ceph_context) << std::endl;*/
<< "cur time " << ceph_clock_now(g_ceph_context) << std::endl;*/
if ((cap->session->cap_gen <= cap->gen)
&& (ceph_clock_now(&g_ceph_context) < cap->session->cap_ttl)) {
&& (ceph_clock_now(g_ceph_context) < cap->session->cap_ttl)) {
return true;
}
//if we make it here, the capabilities aren't up-to-date
Expand Down
Loading

0 comments on commit 112e569

Please sign in to comment.